Skip to content

Commit

Permalink
Linux: Implements support for EFAULT with ppoll's timeout
Browse files Browse the repository at this point in the history
Only need to handle the timeout structure, the rest is handled in the
kernel itself.
  • Loading branch information
Sonicadvance1 committed Jan 26, 2024
1 parent 69ff984 commit 929193c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
15 changes: 13 additions & 2 deletions Source/Tools/LinuxEmulation/LinuxSyscalls/x32/FD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ namespace FEX::HLE::x32 {
struct timespec tp64{};
struct timespec *timed_ptr{};
if (timeout_ts) {
tp64 = *timeout_ts;
struct timespec32 timeout{};
if (FaultSafeMemcpy::CopyFromUser(&timeout, timeout_ts, sizeof(timeout)) == EFAULT) {
return -EFAULT;
}

tp64 = timeout;
timed_ptr = &tp64;
}

Expand All @@ -275,7 +280,13 @@ namespace FEX::HLE::x32 {
sigsetsize);

if (timeout_ts) {
*timeout_ts = tp64;
struct timespec32 timeout{};
timeout = tp64;

if (FaultSafeMemcpy::CopyToUser(timeout_ts, &timeout, sizeof(timeout)) == EFAULT) {
// Write to user memory failed, this can occur if the timeout is defined in read-only memory.
// This is okay to happen, kernel continues happily.
}
}

SYSCALL_ERRNO();
Expand Down
2 changes: 1 addition & 1 deletion Source/Tools/LinuxEmulation/LinuxSyscalls/x32/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ timespec32 {
int32_t tv_sec;
int32_t tv_nsec;

timespec32() = delete;
timespec32() = default;

operator timespec() const {
timespec spec{};
Expand Down

0 comments on commit 929193c

Please sign in to comment.