]> granicus.if.org Git - strace/commit
x32: implement automatic argument truncation for compat syscalls
authorDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Dec 2016 01:52:20 +0000 (01:52 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 20 Dec 2016 05:10:21 +0000 (05:10 +0000)
commit6a360e2f3e63419eb36eea7c69268c7a1f5342b0
treeabec7ed5bbc9a4d09d3428b2bad14a97d8c917e6
parent874caabc0f3f930252de082d4189163997c6ead0
x32: implement automatic argument truncation for compat syscalls

x32 syscalls starting with number 512 are compat syscalls that operate
on compat types.  Set COMPAT_SYSCALL_TYPES flag to these syscall entries
and make get_syscall_args truncate arguments of syscalls that have this
flag set, to avoid unpleasant alternative of adding multiple
widen_to_ulong invocations to individual syscall parsers.

preadv, pwritev, preadv2, and pwritev2 are exceptions: while these
syscalls operate on compat types, the offset argument has a regular
64-bit type, so the automatic argument truncation cannot be applied.

* defs.h (COMPAT_SYSCALL_TYPES): New macro.
* syscall.c (CST): New macro, defined to COMPAT_SYSCALL_TYPES.
* linux/ia64/syscallent.h: Do not include "../i386/syscallent.h"
unless [CST > 0].
* linux/x32/syscallent.h [512..533, 536..545]: Add CST flag.
* linux/x86_64/get_syscall_args.c (get_syscall_args): Truncate arguments
of compat syscalls to 32-bit values.
* tests/ksysent.c (CST): New macro, defined to 0.
* tests/nsyscalls.c (CST): Likewise.
defs.h
linux/ia64/syscallent.h
linux/x32/syscallent.h
linux/x86_64/get_syscall_args.c
syscall.c
tests/ksysent.c
tests/nsyscalls.c