Support preadv2 and pwritev2 syscalls.#4066
Conversation
| case Arch::preadv: | ||
| /* ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt, | ||
| off_t offset, int flags); */ | ||
| case Arch::preadv2: { |
There was a problem hiding this comment.
It's possible that some future RWF_ flag will introduce behaviour that breaks rr. So it would be a good idea to define a set of flags that we know are ok with rr with preadv2 (all the flags currently defined, I think), and fail here with EINVAL if some flag outside that set is passed in. See below for why this is especially important for pwritev2.
| } | ||
|
|
||
| case Arch::pwritev: | ||
| case Arch::pwritev2: |
There was a problem hiding this comment.
If the RWF_APPEND flag is set then the kernel ignores the user's offset, but we'll compute an incorrect offset below and things will go wrong. (I think we already have an existing bug if the user passes O_APPEND to open(); in that case pwritev will ignore the offset and we compute the wrong offset.)
So let's do what I said above and specify a mask of flags we know we can handle correctly --- I think that's everything currently defined except for RWF_APPEND --- and return EINVAL if any other flags are set. That will require adding code in record_syscall.cc for pwritev2.
There was a problem hiding this comment.
Thanks for taking a look! Fixed
Previously these were marked UnsupportedSyscall, so rr expected the kernel to return ENOSYS; on modern kernels (Linux 4.6+) the syscall succeeds and rr hits a FATAL assertion. Fixes rr-debugger#3193. Handle them like their v1 counterparts, but with an additional flag whitelist: reject unknown RWF_* flags with EINVAL so that a future kernel addition whose semantics break rr can't silently go wrong. RWF_APPEND is additionally rejected for pwritev2 because the kernel would ignore the user's offset while FileMonitor would still compute it from the arguments and misrecord the write.
|
Thanks!!! |
These were marked as UnsupportedSyscall, causing rr to expect ENOSYS. On modern kernels that support them (Linux 4.6+), the syscall succeeds and rr hits a FATAL assertion. Handle them the same way as their v1 counterparts (preadv/pwritev).
Handle them like their v1 counterparts, but with an additional flag whitelist: reject unknown RWF_* flags with EINVAL so that a future kernel addition whose semantics break rr can't silently go wrong. RWF_APPEND is additionally rejected for pwritev2 because the kernel would ignore the user's offset while FileMonitor would still compute it from the arguments and misrecord the write.
Fixes #3193