TencentOS-kernel/tools/testing/selftests/x86
Andy Lutomirski 3cbbfad519 selftests/x86: Add a syscall_arg_fault_64 test for negative GSBASE
commit a5d25e01c8146ad8846da4760422e12242fceafe upstream.
Backport summary: for 5.4 kernel fsgsbase support.

If the kernel erroneously allows WRGSBASE and user code writes a
negative value, paranoid_entry will get confused. Check for this by
writing a negative value to GSBASE and doing SYSENTER with TF set. A
successful run looks like:

    [RUN]	SYSENTER with TF, invalid state, and GSBASE < 0
    [SKIP]	Illegal instruction

A failed run causes a kernel hang, and I believe it's because we
double-fault and then get a never ending series of page faults and,
when we exhaust the double fault stack we double fault again,
starting the process over.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/f4f71efc91b9eae5e3dae21c9aee1c70cf5f370e.1590620529.git.luto@kernel.org
(cherry picked from commit a5d25e01c8146ad8846da4760422e12242fceafe)
Signed-off-by: Ethan Zhao <Haifeng.Zhao@intel.com>
2021-08-17 06:29:11 +00:00
..
.gitignore Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
Makefile x86/ptrace: Fix 32-bit PTRACE_SETREGS vs fsbase and gsbase 2021-08-17 06:29:11 +00:00
check_cc.sh Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
check_initial_reg_state.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
entry_from_vm86.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
fsgsbase.c selftests/x86/fsgsbase: Fix GS == 1, 2, and 3 tests 2021-08-17 06:29:11 +00:00
fsgsbase_restore.c x86/ptrace: Fix 32-bit PTRACE_SETREGS vs fsbase and gsbase 2021-08-17 06:29:11 +00:00
helpers.h selftests/x86: Use __builtin_ia32_read/writeeflags 2021-08-17 06:29:11 +00:00
ioperm.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
iopl.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
ldt_gdt.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
mov_ss_trap.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
pkey-helpers.h Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
protection_keys.c selftests/vm/pkeys: fix alloc_random_pkey() to make it really random 2021-03-16 16:30:30 +08:00
ptrace_syscall.c selftests/x86/ptrace_syscall_32: Fix no-vDSO segfault 2021-03-16 16:25:57 +08:00
raw_syscall_helper_32.S Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sigreturn.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
single_step_syscall.c selftests/x86: Consolidate and fix get/set_eflags() helpers 2021-08-17 06:29:11 +00:00
syscall_arg_fault.c selftests/x86: Add a syscall_arg_fault_64 test for negative GSBASE 2021-08-17 06:29:11 +00:00
syscall_nt.c selftests/x86: Consolidate and fix get/set_eflags() helpers 2021-08-17 06:29:11 +00:00
syscall_numbering.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sysret_rip.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
sysret_ss_attrs.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
test_FCMOV.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
test_FCOMI.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
test_FISTTP.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
test_mremap_vdso.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
test_syscall_vdso.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
test_vdso.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
test_vsyscall.c selftests/x86: Consolidate and fix get/set_eflags() helpers 2021-08-17 06:29:11 +00:00
thunks.S Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
thunks_32.S Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
trivial_32bit_program.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
trivial_64bit_program.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
trivial_program.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00
unwind_vdso.c selftests/x86: Consolidate and fix get/set_eflags() helpers 2021-08-17 06:29:11 +00:00
vdso_restorer.c Init Repo base on linux 5.4.32 long term, and add base tlinux kernel interfaces. 2021-03-16 11:01:34 +08:00