Incorrect preadv/pwritev argument parsing on ARM EABI
Dima Kogan
dima at secretsauce.net
Wed Apr 16 09:28:40 UTC 2014
Dima Kogan <lists at dima.secretsauce.net> writes:
> Dima Kogan <lists at dima.secretsauce.net> writes:
>
>> Does anybody know what's going on? I can imagine anything from the
>> kernel being inconsistent with itself to glibc producing an incorrect
>> kernel interface.
>
> So I just checked to see what data the kernel returns in response to the
> pread() and preadv() calls in the example. The kernel sees the correct
> addresses in both of those calls, so libc is doing the right thing, and
> this is an strace bug/kernel weirdness.
I'll just keep replying to myself :)
I looked into this, and I know what's happening, and a patch is
attached.
preadv/pwritev have a 64-bit 'offset' argument in userspace. The system call,
however, has two separate 32-bit arguments. This is different from syscalls like
pread where the syscall has a 64-bit argument.
In the latter case, alignment requirements apply. In the former (preadv) case,
however, NO alignment requirements apply, since as far as the kernel is
concerned, there are no 64 bit arguments.
To be absolutely clear, here are the syscall definitions of preadv and pread
(I'm looking at fs/read_write.c in Linux 3.14):
SYSCALL_DEFINE4(pread64, unsigned int, fd, char __user *, buf,
size_t, count, loff_t, pos)
SYSCALL_DEFINE5(preadv, unsigned long, fd, const struct iovec __user *, vec,
unsigned long, vlen, unsigned long, pos_l, unsigned long, pos_h)
Note that pread64 has a single loff_t pos while preadv has a split pos.
This patch removes the alignment requirements from preadv and pwritev, so the
pos argument is reported correctly
dima
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-fixed-preadv-pwritev-offset-reporting.patch
Type: text/x-diff
Size: 1931 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20140416/a20ca980/attachment.bin>
More information about the Strace-devel
mailing list