Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document, Detect, Implement EFAULT handling in syscall handler #3942

Open
Sonicadvance1 opened this issue Aug 11, 2024 · 0 comments
Open

Document, Detect, Implement EFAULT handling in syscall handler #3942

Sonicadvance1 opened this issue Aug 11, 2024 · 0 comments

Comments

@Sonicadvance1
Copy link
Member

Sonicadvance1 commented Aug 11, 2024

Started in #3375
Continued in #3941

Our syscall handlers aren't always robust against EFAULT and in most cases we can't even detect it.

In #3375 we added memcpy handlers, which adds some overhead and programmer burden towards implementing the EFAULT handling without any guidance towards which syscalls are most likely to hit the problem.

In #3941 we added validation handlers which resolve if an argument has zero protections, read-only, or read-write capable. This allows us to sprinkle simple LOGMAN handlers around that add zero overhead in release mode, and doesn't place the burden on the programmer to actually implement the EFAULT handling at the start.

There is still a burden that we need to go through our non-passthrough syscall handlers and add these bound checks to the passed in user-pointers, but this is significantly lower effort. In addition to being lower effort, it will help inform our decisions about which syscalls need EFAULT handling on its arguments, since it'll give an assert message and can be tracked back to a failing syscall.

An additional task will be implementing an optimized inline memcpy for the handlers introduced in #3375. Currently these are quite slow, since they only copy byte-by-byte. If the memcpy handler is inline then we can detect a PC range for fault detection while still maintaining good speeds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant