mirror of
https://github.com/FEX-Emu/FEX.git
synced 2025-01-07 14:10:23 +00:00
Merge pull request #4041 from Sonicadvance1/fix_poll
LinuxSyscalls: With poll syscall, ensure fds is writable only if nfds is not zero
This commit is contained in:
commit
f77841d784
@ -31,6 +31,15 @@ $end_info$
|
||||
namespace FEX::HLE {
|
||||
void RegisterFD(FEX::HLE::SyscallHandler* Handler) {
|
||||
using namespace FEXCore::IR;
|
||||
REGISTER_SYSCALL_IMPL_FLAGS(poll, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY,
|
||||
[](FEXCore::Core::CpuStateFrame* Frame, struct pollfd* fds, nfds_t nfds, int timeout) -> uint64_t {
|
||||
if (nfds) {
|
||||
// fds is allowed to be garbage if nfds is zero.
|
||||
FaultSafeUserMemAccess::VerifyIsWritable(fds, sizeof(struct pollfd) * nfds);
|
||||
}
|
||||
uint64_t Result = ::poll(fds, nfds, timeout);
|
||||
SYSCALL_ERRNO();
|
||||
});
|
||||
|
||||
REGISTER_SYSCALL_IMPL_FLAGS(open, SyscallFlags::OPTIMIZETHROUGH | SyscallFlags::NOSYNCSTATEONENTRY,
|
||||
[](FEXCore::Core::CpuStateFrame* Frame, const char* pathname, int flags, uint32_t mode) -> uint64_t {
|
||||
|
@ -253,12 +253,6 @@ auto selectHandler = [](FEXCore::Core::CpuStateFrame* Frame, int nfds, fd_set32*
|
||||
};
|
||||
|
||||
void RegisterFD(FEX::HLE::SyscallHandler* Handler) {
|
||||
REGISTER_SYSCALL_IMPL_X32(poll, [](FEXCore::Core::CpuStateFrame* Frame, struct pollfd* fds, nfds_t nfds, int timeout) -> uint64_t {
|
||||
FaultSafeUserMemAccess::VerifyIsReadableOrNull(fds, sizeof(struct pollfd) * nfds);
|
||||
uint64_t Result = ::poll(fds, nfds, timeout);
|
||||
SYSCALL_ERRNO();
|
||||
});
|
||||
|
||||
REGISTER_SYSCALL_IMPL_X32(ppoll,
|
||||
[](FEXCore::Core::CpuStateFrame* Frame, struct pollfd* fds, nfds_t nfds, timespec32* timeout_ts,
|
||||
const uint64_t* sigmask, size_t sigsetsize) -> uint64_t {
|
||||
|
@ -29,12 +29,6 @@ $end_info$
|
||||
|
||||
namespace FEX::HLE::x64 {
|
||||
void RegisterFD(FEX::HLE::SyscallHandler* Handler) {
|
||||
REGISTER_SYSCALL_IMPL_X64(poll, [](FEXCore::Core::CpuStateFrame* Frame, struct pollfd* fds, nfds_t nfds, int timeout) -> uint64_t {
|
||||
FaultSafeUserMemAccess::VerifyIsWritable(fds, sizeof(struct pollfd) * nfds);
|
||||
uint64_t Result = ::poll(fds, nfds, timeout);
|
||||
SYSCALL_ERRNO();
|
||||
});
|
||||
|
||||
REGISTER_SYSCALL_IMPL_X64(
|
||||
select, [](FEXCore::Core::CpuStateFrame* Frame, int nfds, fd_set* readfds, fd_set* writefds, fd_set* exceptfds, struct timeval* timeout) -> uint64_t {
|
||||
///< All FD arrays need to be writable
|
||||
|
Loading…
Reference in New Issue
Block a user