proot-me / proot

chroot, mount --bind, and binfmt_misc without privilege/setup for Linux
https://proot-me.github.io
GNU General Public License v2.0
2.02k stars 378 forks source link

Remove special handling of syscall avoider number on ARM #304

Closed yuyichao closed 2 years ago

yuyichao commented 3 years ago

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 e675d09b2ce133110afe32ac379868d1691b1fdf. 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 63c7f7f66824660408abc06b2b0ea98a00ef8096 and we should be able to use the better supported -1 for this purpose.