FEX: open guest paths with the raw openat system call so host preloads cannot replace the file

This commit is contained in:
maxjivi05 committed 2026-12-02 18:51:47 -05:00
1 parent a3ef731d07
commit 225a0a85aa
1 file changed
+33
@@ -0,0 +1,33 @@
From a25384e1eaefad973d02412c757176b627aaf822 Mon Sep 17 00:00:00 2001
From: maxjivi05 <maxjividen@gmail.com>
Date: Wed, 2 Dec 2026 18:51:42 -0500
Subject: [PATCH] Open guest paths with the raw openat system call so host
preloads cannot replace the file
Builds on StonkGuy's anti-cheat emulation from https://github.com/StonkGuy/FEX (eac-2611, MIT).
---
Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp
index 62b6a2d27..2b0139ae0 100644
--- a/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp
+++ b/Source/Tools/LinuxEmulation/LinuxSyscalls/FileManagement.cpp
@@ -838,12 +838,12 @@ uint64_t FileManager::Open(const char* pathname, int flags, uint32_t mode) {
// Open through RootFS failed (probably nonexistent), so open directly.
if (fd == -1) {
- fd = ::open(SelfPath, flags, mode);
+ fd = ::syscall(SYSCALL_DEF(openat), AT_FDCWD, SelfPath, flags, mode);
}
ReplaceEmuFd(fd, flags, mode);
} else {
- fd = ::open(SelfPath, flags, mode);
+ fd = ::syscall(SYSCALL_DEF(openat), AT_FDCWD, SelfPath, flags, mode);
}
return fd;
--
2.43.0