Dmitry V. Levin [Wed, 30 Dec 2015 23:00:43 +0000 (23:00 +0000)]
tests: add fork-f.test and vfork-f.test
Check how strace -f follows fork and vfork syscalls.
* tests/fork-f.c: New file.
* tests/fork-f.test: New test.
* tests/vfork-f.c: New file.
* tests/vfork-f.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add fork-f and vfork-f.
(TESTS): Add fork-f.test and vfork-f.test.
* tests/.gitignore: Add fork-f and vfork-f.
On architectures that use dedicated registers to report syscall errors,
check for syscall error condition regardless of SYSCALL_NEVER_FAILS flag
in the syscall entry. On architectures that use negated errno
semantics, there is no way to distinguish a syscall error from a valid
return code that looks like a syscall error, and the check for
SYSCALL_NEVER_FAILS flag remains the only way to tell one case
from another.
Dmitry V. Levin [Sun, 27 Dec 2015 00:18:35 +0000 (00:18 +0000)]
Handle unlikely errors from personality syscall
Despite being marked as SYSCALL_NEVER_FAILS, personality syscall still
might report a failure on some architectures due to obscure kernel
bugs. Check for this unlikely case and let users know that their
kernel has gone bananas.
* personality.c (SYS_FUNC(personality)): Do not parse syscall return
value in case of syserror.
Dmitry V. Levin [Sat, 26 Dec 2015 01:40:50 +0000 (01:40 +0000)]
Enhance personality syscall decoding
* xlat/personality_options.in: Split into ...
* xlat/personality_types.in: ... personality types and ...
* xlat/personality_flags.in: ... personality flags.
* personality.c: Include "xlat/personality_types.h"
and "xlat/personality_flags.h" instead of "xlat/personality_options.h".
(SYS_FUNC(personality)): Print PER_MASK part of personality as
a symbolic value, and the rest of personality as a set of flags.
* tests/personality.c (main): Add more test cases.
* tests/personality.test: Update.
Dmitry V. Levin [Thu, 24 Dec 2015 16:53:07 +0000 (16:53 +0000)]
Enhance personality syscall decoding
* personality.c (SYS_FUNC(personality)): On entering syscall,
print first argument not as a hex value but as a set of flags.
On exiting syscall, print return code as a set of flags.
* NEWS: Mention this enhancement.
Dmitry V. Levin [Thu, 17 Dec 2015 17:56:48 +0000 (17:56 +0000)]
Add copyright headers to some files which lack them
Before this change, all files that exist since 20th century had
copyright headers, while most files that appeared later didn't. This
change fixes the inconsistency by adding missing copyright headers.
It doesn't mean that copyright headers became maintained. In my view,
git history provides much better information on this subject and is much
more accurate than copyright headers.
Szabolcs Nagy [Tue, 15 Dec 2015 18:32:17 +0000 (18:32 +0000)]
Fix SYS_FUNC and SEN macros for musl
The syscall_name argument was subject to macro expansion because
it was passed down to other macros before it was prefixed.
musl libc defines lfs64 names as macros (e.g. fstat64 as fstat)
so SYS_FUNC(fstat64) was expanded to sys_fstat.
This change adds the prefix before the name is passed to other macros,
i.e. the argument of SYS_FUNC_NAME is already prefixed with sys_.
* defs.h (SYS_FUNC): Add sys_ prefix to SYS_FUNC_NAME's argument.
(SYS_FUNC_NAME): Do not add sys_ prefix to MPERS_FUNC_NAME's argument.
* linux/ia64/syscallent.h (SYS_FUNC_NAME): Do not add sys_ prefix
to MPERS_FUNC_NAME's argument.
* syscall.c (SEN_NAME): Remove.
(SEN): Replace SEN_NAME call with its definition. Add sys_ prefix
to SYS_FUNC_NAME's argument.
Dmitry V. Levin [Tue, 15 Dec 2015 12:58:42 +0000 (12:58 +0000)]
mpers.awk: make fillers added to the output structure more predictable
* mpers.awk (array_seq): New function.
(what_is): Use it for printing filler names. Tweak return types.
* mpers_test.sh: Use a more complicated sample type to test mpers
machinery.
The only platform which is known at this moment to fail the test
is CentOS-5 provided by OBS. On x86_64 instance it fails with
error: "prlimit64" syscall #300 is "fanotify_init" in syscallent.h
and on i586 it similarly fails with
error: "prlimit64" syscall #338 is "fanotify_init" in syscallent.h
So this is a real platform bug that is not likely to be worked around
on the strace side.
Dmitry V. Levin [Wed, 9 Dec 2015 02:07:44 +0000 (02:07 +0000)]
ia64: print all ia32 syscalls using printargs
Printing of ia32 syscalls on ia64 must have been broken for a long time.
Do not pretend that it works, print ia32 syscalls using printargs
instead.
* linux/ia64/syscallent.h: Remove all redefinitions of sys_* macros.
Stop including"../dummy.h". Include "../i386/syscallent.h" with
SYS_FUNC_NAME macro temporarily redirected to printargs.
Dmitry V. Levin [Wed, 9 Dec 2015 00:43:39 +0000 (00:43 +0000)]
aarch64: swap 64-bit and 32-bit personalities
Let native 64-bit personality be personality 0, and 32-bit personality
be personality 1, to follow the traditional layout used for other
architectures.
* defs.h [AARCH64]: Swap PERSONALITY0_WORDSIZE and
PERSONALITY1_WORDSIZE, remove DEFAULT_PERSONALITY.
[AARCH64 && HAVE_M32_MPERS]: Rename PERSONALITY1_* to PERSONALITY0_*.
* file.c [AARCH64 || defined X86_64 || defined X32]: Define
STAT32_PERSONALITY for AARCH64 as well.
* syscall.c (update_personality) [AARCH64]: Adjust PERSONALITY_NAMES.
* linux/aarch64/errnoent1.h: Adjust comment.
* linux/aarch64/get_error.c (get_error): Adjust tcp->currpers check.
* linux/aarch64/get_syscall_args.c (get_syscall_args): Likewise.
* linux/arm/arch_sigreturn.c (arch_sigreturn) [AARCH64]: Likewise.
* linux/aarch64/get_scno.c (arch_get_scno): Adjust update_personality
invocations.
* linux/aarch64/ioctls_arch0.h: Swap with ...
* linux/aarch64/ioctls_arch1.h: ... this file.
* linux/aarch64/ioctls_inc0.h: Swap with ...
* linux/aarch64/ioctls_inc1.h: ... this file.
* linux/aarch64/syscallent.h: Swap with ...
* linux/aarch64/syscallent1.h: ... this file.
Dmitry V. Levin [Tue, 8 Dec 2015 00:24:53 +0000 (00:24 +0000)]
build: add -D_FILE_OFFSET_BITS=64 to _CPPFLAGS instead of _CFLAGS
* tests/Makefile.am (fstat64_CFLAGS): Rename to fstat64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(fstatat64_CFLAGS): Rename to fstatat64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(ftruncate64_CFLAGS): Rename to ftruncate64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(lstat64_CFLAGS): Rename to lstat64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(mmap64_CFLAGS): Rename to mmap64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(newfstatat_CFLAGS): Rename to newfstatat_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(stat64_CFLAGS): Rename to stat64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(statfs_CFLAGS): Rename to statfs_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(truncate64_CFLAGS): Rename to truncate64_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
(uio_CFLAGS): Rename to uio_CPPFLAGS,
replace $(AM_CFLAGS) with $(AM_CPPFLAGS).
Dmitry V. Levin [Tue, 8 Dec 2015 00:14:26 +0000 (00:14 +0000)]
Move x32 <asm/stat.h> replacement to x32 specific directory
As tests-m*32/Makefile.am files now refer to proper arch specific
directories, it's possible to relocate x32 <asm/stat.h> replacement
to its arch specific directory.
Dmitry V. Levin [Tue, 8 Dec 2015 00:14:10 +0000 (00:14 +0000)]
build: set arch specific -m switches in tests-m*32/Makefile.am files properly
* tests/Makefile.am (ARCH_MFLAGS, AM_LDFLAGS): New variables.
(AM_CPPFLAGS): Use ARCH_MFLAGS.
* bootstrap: In tests-m32/Makefile.am and tests-mx32/Makefile.am,
add -m32 and -mx32, respectively, to ARCH_MFLAGS instead of AM_CFLAGS.
Dmitry V. Levin [Tue, 8 Dec 2015 00:13:38 +0000 (00:13 +0000)]
build: initialize ARCH variable in tests-m*32/Makefile.am files properly
* configure.ac (arch_m32): Set to sparc on sparc64, powerpc on
powerpc64, arm on aarch64, i386 on x86_64 and x32, $arch in other cases.
(arch_mx32): Set to x32 on x86_64, $arch in other cases.
(AC_SUBST): Add arch_m32 and arch_mx32.
* bootstrap: Substitute @arch@ with @arch_m32@ in tests-m32/Makefile.am.
Substitute @arch@ with @arch_mx32@ in tests-mx32/Makefile.am.
Dmitry V. Levin [Sun, 6 Dec 2015 05:28:11 +0000 (05:28 +0000)]
times.test: workaround buggy libc
* tests/times.c: Include <sys/syscall.h>.
(main): On systems where user's and kernel's long types are the same,
prefer direct times syscall over libc's times function because
the latter is more prone to return value truncation.
Dmitry V. Levin [Sun, 6 Dec 2015 04:51:57 +0000 (04:51 +0000)]
times.test: reduce cpu time consumption, increase struct tms diversity
* tests/times.c (main): Reduce cpu time consumption fourfold,
make the parent process consume less cpu time than the child process
so that members of the structure returned by times syscall would be
more likely to contain different values.
Dmitry V. Levin [Sat, 5 Dec 2015 00:03:49 +0000 (00:03 +0000)]
tests: replace old stat tests with stat.test and stat64.test
* tests/stat.c: Replace with a wrapper around lstatx.c
* tests/stat.test: Replace with a wrapper around statx.sh.
* tests/stat32-v.test: Remove.
* tests/stat32.c: Remove.
* tests/stat64-v.test: Remove.
* tests/stat64.c: New file.
* tests/stat64.test: New test.
* tests/Makefile.am (check_PROGRAMS): Replace stat32 with stat64.
(stat_CFLAGS): Rename to stat64_CFLAGS.
(TESTS): Replace stat32-v.test and stat64-v.test with stat64.test.
* tests/.gitignore: Replace stat32 with stat64.
Dmitry V. Levin [Sat, 5 Dec 2015 00:01:56 +0000 (00:01 +0000)]
tests: prepare for detailed testing of stat family syscalls
Parametrize code from fstatat.c to support <asm/stat.h>
as an alternative to <sys/stat.h> and move it to a separate file.
* tests/statx.sh: New file, based on fstatat64.test.
* tests/fstatat64.test: Use it.
* tests/newfstatat.test: Likewise.
* tests/xstatx.c: New file, based on fstatat.c.
* tests/fstatat.c: Use it.
* tests/Makefile.am (EXTRA_DIST): Add statx.sh and xstatx.c.
* tests/fstatat64.c (FSTATAT_NAME): Change to TEST_SYSCALL_NAME.
* tests/newfstatat.c: Likewise.
Gabriel Laskar [Fri, 4 Dec 2015 00:07:33 +0000 (01:07 +0100)]
ioctl: allow to stop decoding number
For some ioctls, like from drm, the identification of the correct ioctl
is done by custom code. Specifying IOCTL_NUMBER_STOP_LOOKUP on
return of ioctl_decode_command_number() disables further calls to
ioctl_lookup().
* defs.h (IOCTL_NUMBER_UNKNOWN, IOCTL_NUMBER_HANDLED,
IOCTL_NUMBER_STOP_LOOKUP): Add macros representing ioctl number state
decoding.
* ioctl.c (SYS_FUNC(ioctl)): Skip ioctl_lookup() when
ioctl_decode_command_number() returns a value with
IOCTL_NUMBER_STOP_LOOKUP flag is set.
Suggested-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com> Signed-off-by: Gabriel Laskar <gabriel@lse.epita.fr> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Dmitry V. Levin [Fri, 4 Dec 2015 16:51:11 +0000 (16:51 +0000)]
tests: skip restart_syscall.test on x32
The syscall number of restart_syscall returned by the kernel in case
of ERESTART_RESTARTBLOCK is broken on x32 from the beginning, see
https://lkml.org/lkml/2015/11/30/790