Skip to content

Commit

Permalink
Linux: Disable EFAULT handler until we find something that uses it.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonicadvance1 committed Jan 18, 2024
1 parent 92ef9e7 commit cd9a1a3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
13 changes: 10 additions & 3 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/SignalDelegator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1471,9 +1471,16 @@ namespace FEX::HLE {
else if (Signal == SIGSEGV &&
(reinterpret_cast<void*>(ArchHelpers::Context::GetPc(UContext)) == FaultSafeMemcpy::CopyFromUser_FaultLocation ||
reinterpret_cast<void*>(ArchHelpers::Context::GetPc(UContext)) == FaultSafeMemcpy::CopyToUser_FaultLocation)) {
// Jump to the copy fault handler return trampoline to safely return EFAULT.
ArchHelpers::Context::SetPc(UContext, reinterpret_cast<uint64_t>(&FaultSafeMemcpy::CopyFaultTrampoline));
return;
// If you want to emulate EFAULT behaviour then enable this if-statement.
// Do this once we find an application that depends on this.
if constexpr (false) {
// Jump to the copy fault handler return trampoline to safely return EFAULT.
ArchHelpers::Context::SetPc(UContext, reinterpret_cast<uint64_t>(&FaultSafeMemcpy::CopyFaultTrampoline));
return;
}
else {
LogMan::Msg::AFmt("Received invalid data to syscall. Crashing now!");
}
}
else {
if (IsAsyncSignal(&SigInfo, Signal) && MustDeferSignal) {
Expand Down
2 changes: 2 additions & 0 deletions unittests/FEXLinuxTests/Known_Failures
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@ sigtest_samask.32
sigtest_samask.64
sigtest_sigmask.32
sigtest_sigmask.64

syscalls_efault.32
2 changes: 1 addition & 1 deletion unittests/FEXLinuxTests/tests/syscalls/syscalls_efault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TEST_CASE("poll") {
CHECK(errno == EFAULT);
}

TEST_CASE("ppoll") {
TEST_CASE("ppoll", "[!mayfail]") {
// ppoll can return EFAULT for arguements 1, 3, 4
struct pollfd *invalid_fds = reinterpret_cast<struct pollfd *>(mmap(nullptr, sysconf(_SC_PAGESIZE), PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
struct timespec *invalid_timespec = reinterpret_cast<struct timespec*>(mmap(nullptr, sysconf(_SC_PAGESIZE), PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0));
Expand Down

0 comments on commit cd9a1a3

Please sign in to comment.