Dmitry V. Levin [Mon, 12 Jan 2015 17:17:14 +0000 (17:17 +0000)]
s390x: adjust some syscall entries
According to linux/arch/s390/include/uapi/asm/unistd.h, readdir is
defined both on s390 and s390x, while getrlimit, _llseek, sendfile64,
and fadvise64_64 are defined on s390 only.
Dmitry V. Levin [Sun, 11 Jan 2015 01:04:54 +0000 (04:04 +0300)]
Create generic 32-bit syscallent.h
Since arc/syscallent.h, metag/syscallent.h, or1k/syscallent.h, and
tile/syscallent1.h share a lot of identical syscall entries described in
<asm-generic/unistd.h>, move these entries to a new file 32/syscallent.h
using the following automated conversion with subsequent correction of
whitespace indentation:
sed -e 's|^[[:space:]]*\({[^}]\+},\)[[:space:]]*/\*[[:space:]]\([[:space:]]*[0-9]\+\)[[:space:]]*\*/|[\2] = \1|' -e '/^[[:space:]]*\[[[:space:]]*2\(4[4-9]\|5[0-9]\)/d' linux/arc/syscallent.h
* linux/32/syscallent.h: New file.
* Makefile.am (EXTRA_DIST): Add it.
* linux/arc/syscallent.h: Include "32/syscallent.h",
remove generic 32-bit syscall entries, use designated initializers.
* linux/metag/syscallent.h: Likewise.
* linux/or1k/syscallent.h: Likewise.
* linux/tile/syscallent1.h: Likewise.
Dmitry V. Levin [Sun, 11 Jan 2015 00:15:24 +0000 (03:15 +0300)]
s390: fix fadvise64 and fadvise64_64 syscall entries
* linux/s390/syscallent.h (fadvise64, fadvise64_64): Change sys_func to
printargs until special parsers for 31-bit 31 s390 emulation wrappers
are written.
Dmitry V. Levin [Sat, 10 Jan 2015 17:51:37 +0000 (20:51 +0300)]
Create generic 64-bit syscallent.h
Since aarch64/syscallent1.h and tile/syscallent.h share a lot of
identical syscall entries described in <asm-generic/unistd.h>, move
these entries to a new file 64/syscallent.h using the following
automated conversion with subsequent correction of whitespace
indentation:
sed -e 's|^[[:space:]]*\({[^}]\+},\)[[:space:]]*/\*[[:space:]]\([[:space:]]*[0-9]\+\)[[:space:]]*\*/|[\2] = \1|' -e '/^\[[[:space:]]*2\(4[4-9]\|5[0-9]\)\]/d' linux/tile/syscallent.h
* linux/64/syscallent.h: New file.
* Makefile.am (EXTRA_DIST): Add it.
* linux/aarch64/syscallent1.h: Include "64/syscallent.h",
remove generic 64-bit syscall entries, use designated initializers.
* linux/tile/syscallent.h: Likewise.
Dmitry V. Levin [Sat, 10 Jan 2015 19:01:35 +0000 (22:01 +0300)]
Fix indirect ipc subcall handling
indirect_ipccall used to guess whether currently decoded ipc syscall is
an indirect subcall or not based on generic knowledge, while there is a
robust method to identify indirect ipc subcalls.
* defs.h (TRACE_INDIRECT_SUBCALL): New flag.
* ipc.c (indirect_ipccall): Check it.
* linux/subcall.h: Set it.
Dmitry V. Levin [Sat, 10 Jan 2015 00:08:58 +0000 (00:08 +0000)]
Fix fanotify_mark decoding on 32-bit architectures
The fanotify_mark syscall takes a 64-bit mask, and on 32-bit
architectures it is split up into two syscall arguments.
* configure.ac (AC_CHECK_FUNCS): Add fanotify_mark.
(AC_CHECK_HEADERS): Add sys/fanotify.h.
* defs.h (getllval): New prototype.
* util.c (getllval): New function based on printllval.
(printllval): Use getllval.
* fanotify.c (sys_fanotify_mark): Use getllval to properly decode
64-bit mask and two syscall arguments followed by it.
* tests/fanotify_mark.c: New file.
* tests/fanotify_mark.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add fanotify_mark.
(TESTS): Add fanotify_mark.test.
* tests/.gitignore: Add fanotify_mark.
Dmitry V. Levin [Fri, 9 Jan 2015 04:53:19 +0000 (04:53 +0000)]
v4l2: fix build on systems with older kernel headers
* v4l2.c (print_v4l2_format_fmt): Do not use
V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY unless it is defined.
(v4l2_ioctl): Do not use VIDIOC_ENUM_FRAMESIZES and
VIDIOC_ENUM_FRAMEINTERVALS unless they are defined.
Dmitry V. Levin [Thu, 8 Jan 2015 19:11:05 +0000 (19:11 +0000)]
ioctlent.sh: handle linux/aufs_type.h properly
Before this change, ioctlent.sh could not recognize unusual constants
defined by linux/aufs_type.h, resulting to ioctls.h with references to
these constants without appropriate definitions in ioctldefs.h.
* linux/ioctlent.sh: Update the regexp that is used to lookup constants
referenced by generated ioctls.h.
Dmitry V. Levin [Thu, 8 Jan 2015 15:08:16 +0000 (15:08 +0000)]
Fix printing of time_t values set in the distant future
* util.c (sprinttime): Increase buffer size.
* tests/stat64-v.test: Try to set modification time of the sample file
to a value set in the distant future.
Dmitry V. Levin [Thu, 8 Jan 2015 01:14:53 +0000 (01:14 +0000)]
file.c: group related parsers together
* file.c (sys_stat, sys_fstat): Collect in one place right before
the definition of printstat64.
(sys_stat64, sys_fstat64): Collect in one place right after the
definition of printstat64.
Dmitry V. Levin [Sun, 28 Dec 2014 18:41:20 +0000 (21:41 +0300)]
x32: use generic printstat/printstat64 parsers
* file.c (printstat) [X32]: Define.
(printstat64) [X32]: Use "struct stat64" instead of "struct stat".
Use printstat for x32 personality processes.
(printstat64_x32): Remove.
(sys_stat64, sys_fstat64) [X32]: Use printstat64 instead of
printstat64_x32.
Dmitry V. Levin [Sun, 28 Dec 2014 16:41:24 +0000 (16:41 +0000)]
x32: remove redundant definitions
* file.c [X32]: Do not define "struct stat" and "struct
__old_kernel_stat" locally, use definitions provided by <asm/stat.h>.
Do not define "struct stat64" exclusively, reuse another definition
added earlier for X86_64.
Dmitry V. Levin [Sun, 28 Dec 2014 18:15:25 +0000 (18:15 +0000)]
Convert do_printstat to a template function
* printstat.h: New file.
* Makefile.am (strace_SOURCES): Add it.
* file.c: Include "printstat.h".
(do_printstat): Move to printstat.h, parametrize its name
and struct stat.
Dmitry V. Levin [Sun, 28 Dec 2014 18:00:39 +0000 (18:00 +0000)]
file.c: prepare realprintstat for parametrization
* file.c (realprintstat): Adjust format strings so that all 64-bit
integer fields are printed with %llu format, and %u format is used for
all the rest. Rename to do_printstat.
(printstat, printoldstat): Update callers.
Dmitry V. Levin [Wed, 7 Jan 2015 19:30:37 +0000 (19:30 +0000)]
tests: check verbose decoding of 32-bit and 64-bit struct stat
* tests/stat.c: New file.
* tests/stat32.c: Likewise.
* tests/stat32-v.test: New file.
* tests/stat64-v.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add stat and stat32.
(stat_CFLAGS): Define.
(TESTS): Add stat32-v.test and stat64-v.test.
* tests/.gitignore: Add stat and stat32.
Mike Frysinger [Wed, 31 Dec 2014 00:08:50 +0000 (19:08 -0500)]
timerfd: update flags decoding
The current code only decodes TFD_TIMER_ABSTIME when the kernel has
a bunch of newer flags. We have to handle fallbacks for all of them
since the kernel doesn't currently export things to userspace.
* time.c: Include fcntl.h for O_* defines.
(TFD_TIMER_ABSTIME): Move to xlat/timerfdflags.in.
* xlat/timerfdflags.in: Add more definitions.
Dmitry V. Levin [Fri, 26 Dec 2014 23:29:26 +0000 (23:29 +0000)]
Make -yy output for inet sockets consistent with unix domain sockets
Prepend -yy output generated for INET/INET6 TCP/UDP sockets with their
protocol name obtained using getxattr.
* socketutils.c (inet_parse_response): Add proto_name argument.
Print proto_name for connected and unconnected sockets.
(receive_responses): Add proto_name argument, pass it to the parser.
(inet_print): Add proto_name argument, pass it to receive_responses.
(unix_parse_response): Add proto_name argument.
(print_sockaddr_by_inode): Pass protocol name to inet_print calls.
* tests/net-yy-accept.awk: Update to match new output format.
* tests/net-yy-connect.awk: Likewise.
Dmitry V. Levin [Thu, 25 Dec 2014 00:32:23 +0000 (00:32 +0000)]
tests: robustify unix domain socket decoding test
Unix domain socket address family name is not universally decoded as
AF_LOCAL, other names like AF_UNIX and AF_FILE are valid synonyms.
Similarly, PF_UNIX and PF_FILE are valid synonyms for PF_LOCAL.
Some test regexps have to be properly initialized before they could
be used, so make sure they are initialized before use.
Masatake YAMATO [Wed, 24 Dec 2014 11:59:32 +0000 (20:59 +0900)]
tests: add a test for decoding unix domain socket addresses
* tests/unix-yy-accept.awk: New file.
* tests/unix-yy-connect.awk: New file.
* tests/unix-yy.test: New test.
* tests/Makefile.am (TESTS): Add it.
(EXTRA_DIST): Add unix-yy-accept.awk and unix-yy-connect.awk.
Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Masatake YAMATO [Wed, 24 Dec 2014 11:59:31 +0000 (20:59 +0900)]
Support unix domain sockets in -yy option
This change extends -yy option to handle unix domain sockets:
their peer addresses will be printed, similar to inet sockets.
For a listening socket, its socket inode and socket path are printed.
For an accepted socket, its socket inode, the peer inode, and the
socket path are printed.
For a client socket, its socket inode and the peer inode are printed.
An example of a server side communication using netcat:
* linux/unix_diag.h: New file.
* socketutils.c (send_query): Rename to inet_send_query.
(parse_response): Rename to inet_parse_response.
(unix_print, unix_send_query, unix_parse_response): New functions.
(receive_responses): Add a new argument named parser: a function for
handling protocol specific data parts of diag messages.
(print_sockaddr_by_inode): Call unix_print.
Replace NETLINK_INET_DIAG with NETLINK_SOCK_DIAG, they are equal
but NETLINK_SOCK_DIAG looks more generic.
Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Masatake YAMATO [Wed, 10 Dec 2014 03:55:06 +0000 (12:55 +0900)]
Use the protocol name of a socket as a hint for peer address resolution
To resolve the peer address of socket, all combinations of families
(AF_INET, AF_INET6) and protocols(IPPROTO_TCP, IPPROTO_UDP) were tried.
This change utilizes the protocol name obtained via getxattr to specify
the right combination.
* socketutils.c (inet_print): New helper function.
(print_sockaddr_by_inode): Use it. Utilize the protocol name
associated with the given inode for resolving the peer socket
address. If the protocol name is NULL, resolve the address
by trying combinations of families and protocols as before.
* defs.h (print_sockaddr_by_inode): Update prototype.
* util.c (printfd): Pass the protocol name associated with
the given path to print_sockaddr_by_inode as the 2nd argument.
Signed-off-by: Masatake YAMATO <yamato@redhat.com> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Dmitry V. Levin [Sun, 14 Dec 2014 13:30:54 +0000 (13:30 +0000)]
Fix decoding of getgroups, getgroups32, setgroups, and setgroups32 syscalls
Convert parsers of these syscalls to the same scheme as were applied to
parsers of other uid/gid related syscalls.
That is, define two sets of parsers on architectures that support
(either directly or via multiarch) 16-bit and 32-bit gid getgroups
and setgroups syscalls simultaneously, and reuse essentially the same
code by parametrizing uid_t and names of parser functions.
* groups.c: Remove.
(sys_getgroups, sys_setgroups): Move ...
* uid.c: ... here and parametrize their names.
* Makefile.am (strace_SOURCES): Remove groups.c.
* linux/syscall.h (sys_getgroups32, sys_setgroups32): Remove.
[NEED_UID16_PARSERS] (sys_getgroups16, sys_setgroups16): New prototypes.
* linux/arm/syscallent.h: Rename sys_[gs]etgroups to sys_[gs]etgroups16,
rename sys_[gs]etgroups32 to sys_[gs]etgroups.
* linux/bfin/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* tests/uid.c: Test for getgroups.
* tests/uid16.c: Likewise.
* tests/uid32.c: Test for getgroups32.
* tests/uid.awk: Test for getgroups/getgroups32 decoding.
* tests/uid.test: Trace getgroups/getgroups32 syscalls.
Dmitry V. Levin [Sat, 13 Dec 2014 21:49:01 +0000 (21:49 +0000)]
Fix decoding of 16-bit *chown and [gs]et*[gu]id syscalls
Define two sets of parsers on architectures that support (either
directly or via multiarch) 16-bit and 32-bit uid/gid syscalls
simultaneously. Since the code in these two sets is essentially
the same and the key difference between them is the size of uid_t,
implement it by parametrizing uid_t and names of parser functions.
* defs.h (NEED_UID16_PARSERS): New macro.
* linux/syscall.h [NEED_UID16_PARSERS] (sys_chown16, sys_fchown16,
sys_getresuid16, sys_getuid16, sys_setfsuid16, sys_setresuid16,
sys_setreuid16, sys_setuid16): New prototypes.
* linux/dummy.h (sys_geteuid16): Alias to sys_getuid16.
(sys_getegid16, sys_getgid16, sys_getresgid16, sys_setfsgid16,
sys_setgid16, sys_setregid16, sys_setresgid16): Alias to corresponding
sys_*uid16 functions.
* uid.c: Stop including <asm/posix_types.h>.
Parametrize uid_t and names of all exported functions.
(get_print_uid): New function.
(sys_getresuid): Use it.
(printuid): Check for (uid_t) -1.
* uid16.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* linux/arm/syscallent.h: Use sys_chown16, sys_fchown16, sys_getegid16,
sys_geteuid16, sys_getgid16, sys_getresgid16, sys_getresuid16,
sys_getuid16, sys_setfsgid16, sys_setfsuid16, sys_setgid16,
sys_setregid16, sys_setresgid16, sys_setresuid16, sys_setreuid16,
and sys_setuid16 parsers for *chown and [gs]et*[gu]id syscall entries.
* linux/bfin/syscallent.h: Likewise.
* linux/i386/syscallent.h: Likewise.
* linux/m68k/syscallent.h: Likewise.
* linux/microblaze/syscallent.h: Likewise.
* linux/s390/syscallent.h: Likewise.
* linux/sparc/syscallent.h: Likewise.
* linux/sh/syscallent.h: Likewise.
* linux/sh64/syscallent.h: Likewise.
* tests/uid16.c: New file.
* tests/uid16.test: New test.
* tests/Makefile.am (CHECK_PROGRAMS): Add uid16.
(TESTS): Add uid16.test.
* tests/.gitignore: Add uid16.
Dmitry V. Levin [Tue, 16 Dec 2014 00:31:53 +0000 (00:31 +0000)]
sh, sh64: fix uid/gid syscall entries
* linux/sh/syscallent.h: Replace printargs with real syscall
parsers in *chown32 and [gs]et*[gu]id32 syscall entries.
* linux/sh64/syscallent.h: Likewise.
Dmitry V. Levin [Tue, 16 Dec 2014 00:25:36 +0000 (00:25 +0000)]
sparc: fix uid/gid syscall entries
* linux/sparc/syscallent.h: Add "32" suffix to names
of [gs]etres[gu]id32 syscalls #108..112.
Fix entry for syscall #112 from setresgid32 to setregid32.
Dmitry V. Levin [Sat, 13 Dec 2014 01:34:47 +0000 (01:34 +0000)]
Update SWAP_FLAG_* constants
* swapon.c: Ensure that SWAP_FLAG_DISCARD_ONCE and
SWAP_FLAG_DISCARD_PAGES are defined.
* xlat/swap_flags.in: Add SWAP_FLAG_DISCARD_ONCE and
SWAP_FLAG_DISCARD_PAGES.
Dmitry V. Levin [Thu, 11 Dec 2014 19:25:02 +0000 (19:25 +0000)]
process.c: introduce XLAT_UOFF macro
Introduce XLAT_UOFF macro and use it to automatically transform
struct_user_offsets array into a more readable and compact form.
for n in $(sed -n 's/^[[:space:]]*{[[:space:]]*uoff(\([a-z_0-9]\+\)),.*/\1/p' process.c |sort -u); do
sed -i 's/^\([[:space:]]*\){[[:space:]]*uoff('"$n"'),[[:space:]]*"offsetof(struct user,[[:space:]]*'"$n"')"[[:space:]]*},$/\1XLAT_UOFF('"$n"'),/' process.c
done
* process.c (XLAT_UOFF): New macro.
(struct_user_offsets): Use it.
Dmitry V. Levin [Thu, 11 Dec 2014 19:25:02 +0000 (19:25 +0000)]
process.c: move clone, setns, unshare, and fork parsers to a separate file
* clone.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* process.c: Move sys_clone, sys_setns, sys_unshare, sys_fork, and
related code to clone.c.
Dmitry V. Levin [Thu, 11 Dec 2014 19:25:02 +0000 (19:25 +0000)]
process.c: move getgroups* and setgroups* parsers to a separate file
* groups.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* process.c: Move sys_setgroups, sys_getgroups, sys_setgroups32,
sys_getgroups32, and related code to groups.c.
Dmitry V. Levin [Thu, 11 Dec 2014 19:25:02 +0000 (19:25 +0000)]
process.c: move waitpid, wait4, osf_wait4, and waitid parsers to a separate file
* wait.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* process.c: Move sys_waitpid, sys_wait4, sys_osf_wait4, sys_waitid and
related code to wait.c.