From 015eface3af985195b3646e48c74579dc00279a1 Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Thu, 3 Dec 2026 03:38:13 -0500 Subject: [PATCH] Diagnostic FEX build: mounts without hidepid --- tools/fex/patches/0028-diag-mounts.patch | 52 ++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tools/fex/patches/0028-diag-mounts.patch diff --git a/tools/fex/patches/0028-diag-mounts.patch b/tools/fex/patches/0028-diag-mounts.patch new file mode 100644 index 0000000000..7b06aefc66 --- /dev/null +++ b/tools/fex/patches/0028-diag-mounts.patch @@ -0,0 +1,52 @@ +From a065859369928d4264160580f98872bbe950dd09 Mon Sep 17 00:00:00 2001 +From: maxjivi05 +Date: Thu, 3 Dec 2026 03:38:07 -0500 +Subject: [PATCH] Diagnostic: mounts without hidepid + +--- + .../EmulatedFiles/EmulatedFiles.cpp | 29 +++++++++++++++++++ + 1 file changed, 29 insertions(+) + +diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/EmulatedFiles/EmulatedFiles.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/EmulatedFiles/EmulatedFiles.cpp +index 49adaaa..c91fa21 100644 +--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/EmulatedFiles/EmulatedFiles.cpp ++++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/EmulatedFiles/EmulatedFiles.cpp +@@ -608,6 +608,35 @@ EmulatedFDManager::EmulatedFDManager(FEXCore::Context::Context* ctx) + FDReadCreators[procStatus] = &EmulatedFDManager::ProcStatus; + FDReadCreators["/proc/self/status"] = &EmulatedFDManager::ProcStatus; + ++ if (getenv("DD_DIAG_MOUNTS")) { ++ auto Mounts = [](FEXCore::Context::Context* ctx, int32_t fd, const char* pathname, int32_t flags, mode_t mode) -> int32_t { ++ int Host = ::open("/proc/self/mounts", O_RDONLY | O_CLOEXEC); ++ if (Host < 0) { ++ return -1; ++ } ++ fextl::string Data; ++ char Buf[4096]; ++ ssize_t n; ++ while ((n = ::read(Host, Buf, sizeof(Buf))) > 0) { ++ Data.append(Buf, n); ++ } ++ ::close(Host); ++ for (const char* Opt : {",gid=3009,hidepid=invisible", ",hidepid=invisible", ",hidepid=2"}) { ++ size_t Pos; ++ while ((Pos = Data.find(Opt)) != fextl::string::npos) { ++ Data.erase(Pos, strlen(Opt)); ++ } ++ } ++ int FD = GenTmpFD(pathname, flags); ++ write(FD, Data.data(), Data.size()); ++ lseek(FD, 0, SEEK_SET); ++ SealTmpFD(FD); ++ return FD; ++ }; ++ FDReadCreators["/proc/mounts"] = Mounts; ++ FDReadCreators["/proc/self/mounts"] = Mounts; ++ } ++ + if (ThreadsConfig > 1) { + cpus_online = fextl::fmt::format("0-{}", ThreadsConfig - 1); + } else { +-- +2.43.0 +