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 17, 2024
1 parent ca8d3f5 commit 92ef9e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 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,11 @@ namespace FEX::HLE::x32 {
sigsetsize);

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

// If the copy fails to update the timeout, then this is safe to ignore the result.
FaultSafeMemcpy::CopyToUser(timeout_ts, &timeout, sizeof(timeout));
}

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 92ef9e7

Please sign in to comment.