alistair23-linux/tools/testing/selftests/x86
Andy Lutomirski 6365b842aa x86/syscalls: Split the x32 syscalls into their own table
For unfortunate historical reasons, the x32 syscalls and the x86_64
syscalls are not all numbered the same.  As an example, ioctl() is nr 16 on
x86_64 but 514 on x32.

This has potentially nasty consequences, since it means that there are two
valid RAX values to do ioctl(2) and two invalid RAX values.  The valid
values are 16 (i.e. ioctl(2) using the x86_64 ABI) and (514 | 0x40000000)
(i.e. ioctl(2) using the x32 ABI).

The invalid values are 514 and (16 | 0x40000000).  514 will enter the
"COMPAT_SYSCALL_DEFINE3(ioctl, ...)" entry point with in_compat_syscall()
and in_x32_syscall() returning false, whereas (16 | 0x40000000) will enter
the native entry point with in_compat_syscall() and in_x32_syscall()
returning true.  Both are bogus, and both will exercise code paths in the
kernel and in any running seccomp filters that really ought to be
unreachable.

Splitting out the x32 syscalls into their own tables, allows both bogus
invocations to return -ENOSYS.  I've checked glibc, musl, and Bionic, and
all of them appear to call syscalls with their correct numbers, so this
change should have no effect on them.

There is an added benefit going forward: new syscalls that need special
handling on x32 can share the same number on x32 and x86_64.  This means
that the special syscall range 512-547 can be treated as a legacy wart
instead of something that may need to be extended in the future.

Also add a selftest to verify the new behavior.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/208024256b764312598f014ebfb0a42472c19354.1562185330.git.luto@kernel.org
2019-07-22 10:31:23 +02:00
..
.gitignore selftests: x86: add missing executables to .gitignore 2017-05-03 10:55:20 -06:00
check_cc.sh treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 257 2019-06-05 17:30:27 +02:00
check_initial_reg_state.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
entry_from_vm86.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 257 2019-06-05 17:30:27 +02:00
fsgsbase.c Revert "x86/ptrace: Prevent ptrace from clearing the FS/GS selector" and fix the test 2019-07-15 17:12:31 +02:00
ioperm.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
iopl.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ldt_gdt.c x86/ldt: Make the LDT mapping RO 2017-12-23 21:13:01 +01:00
Makefile x86/syscalls: Split the x32 syscalls into their own table 2019-07-22 10:31:23 +02:00
mov_ss_trap.c x86/selftests: Add mov_to_ss test 2018-05-14 11:14:45 +02:00
mpx-debug.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mpx-dig.c selftest/x86/mpx-dig.c: Remove duplicate header 2019-04-08 16:18:21 -06:00
mpx-hw.h x86/mpx/selftests: Fix up weird arrays 2017-11-21 09:34:52 +01:00
mpx-mini-test.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 444 2019-06-05 17:37:17 +02:00
mpx-mm.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pkey-helpers.h x86/pkeys/selftests: Avoid printf-in-signal deadlocks 2018-05-14 11:14:45 +02:00
protection_keys.c docs: move protection-keys.rst to the core-api book 2019-06-08 13:42:12 -06:00
ptrace_syscall.c selftests/x86/ptrace_syscall: Fix for yet more glibc interference 2018-03-19 09:06:15 +01:00
raw_syscall_helper_32.S License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sigreturn.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
single_step_syscall.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
syscall_arg_fault.c selftests/x86: Test SYSCALL and SYSENTER manually with TF set 2019-07-02 08:45:20 +02:00
syscall_nt.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
syscall_numbering.c x86/syscalls: Split the x32 syscalls into their own table 2019-07-22 10:31:23 +02:00
sysret_rip.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
sysret_ss_attrs.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
test_FCMOV.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_FCOMI.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_FISTTP.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
test_mremap_vdso.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
test_syscall_vdso.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
test_vdso.c x86/vdso: Fix vDSO syscall fallback asm constraint regression 2018-10-04 08:17:50 +02:00
test_vsyscall.c selftests/x86: Add a test for process_vm_readv() on the vsyscall page 2019-06-28 00:04:40 +02:00
thunks.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
thunks_32.S treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
trivial_32bit_program.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 257 2019-06-05 17:30:27 +02:00
trivial_64bit_program.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 257 2019-06-05 17:30:27 +02:00
trivial_program.c selftests/x86: Detect -no-pie availability 2018-05-30 15:21:51 -06:00
unwind_vdso.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00
vdso_restorer.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 288 2019-06-05 17:36:37 +02:00