Remove special handling of syscall avoider number on ARM (#304)

The use of a real syscall number causes problem with seccomp enabled
since we might not get a second chance in sysexit to set the return value from the syscall.

This, along with the use of PROOT_SET_SYSCALL,
was introduced in e675d09b2c.
The comment and the commit message claims that the syscall number must be a valid one.
However, based on local testing (on both an aarch64 kernel and an arm kernel)
it seems that while the 32bit kernel is unhappy about a invalid syscall number
it treats a `-1` from the ptracer as ignoring the syscall just as what we need.
OTOH, the 64bit kernel doesn't seem to care at all and will happily treate the `-2`
as ignoring syscall as well. I have not found any document
about the special treatment of `syscall(-1)` but this is what strace uses.

The original choice of `-2` seems to be because `-1` is used to indicate uninitialized value.
It doesn't seem that this is needed anymore after 63c7f7f668
and we should be able to use the better supported `-1` for this purpose.
This commit is contained in:
Yichao Yu 2021-11-05 18:23:52 -04:00 committed by GitHub
parent dd57b59200
commit 53191c518e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 7 deletions

View File

@ -31,7 +31,7 @@
typedef unsigned long word_t; typedef unsigned long word_t;
typedef unsigned char byte_t; typedef unsigned char byte_t;
#define SYSCALL_AVOIDER ((word_t) -2) #define SYSCALL_AVOIDER ((word_t) -1)
#define SYSTRAP_NUM SYSARG_NUM #define SYSTRAP_NUM SYSARG_NUM
#define STACK_ALIGNMENT 16 #define STACK_ALIGNMENT 16
@ -110,11 +110,6 @@ typedef unsigned char byte_t;
#define EXEC_PIC_ADDRESS 0x0f000000 #define EXEC_PIC_ADDRESS 0x0f000000
#define INTERP_PIC_ADDRESS 0x1f000000 #define INTERP_PIC_ADDRESS 0x1f000000
/* The syscall number has to be valid on ARM, so use tuxcall(2) as
* the "void" syscall since it has no side effects. */
#undef SYSCALL_AVOIDER
#define SYSCALL_AVOIDER ((word_t) 222)
#elif defined(ARCH_ARM64) #elif defined(ARCH_ARM64)
#define SYSNUMS_HEADER1 "syscall/sysnums-arm64.h" #define SYSNUMS_HEADER1 "syscall/sysnums-arm64.h"

View File

@ -182,7 +182,6 @@ static const Sysnum sysnums_arm[] = {
[ 219 ] = PR_mincore, [ 219 ] = PR_mincore,
[ 220 ] = PR_madvise, [ 220 ] = PR_madvise,
[ 221 ] = PR_fcntl64, [ 221 ] = PR_fcntl64,
[ 222 ] = PR_void,
[ 224 ] = PR_gettid, [ 224 ] = PR_gettid,
[ 225 ] = PR_readahead, [ 225 ] = PR_readahead,
[ 226 ] = PR_setxattr, [ 226 ] = PR_setxattr,