selftests/x86: Add a syscall_arg_fault_64 test for negative GSBASE
authorAndy Lutomirski <luto@kernel.org>
Wed, 27 May 2020 23:02:36 +0000 (16:02 -0700)
committerBorislav Petkov <bp@suse.de>
Mon, 22 Jun 2020 16:56:36 +0000 (18:56 +0200)
commita5d25e01c8146ad8846da4760422e12242fceafe
treec49aa6d29b239fcea083dd0c9ee760dbb6e8d215
parent5e7ec8578fa3dada50c50f5b234fa8d154b76349
selftests/x86: Add a syscall_arg_fault_64 test for negative GSBASE

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
tools/testing/selftests/x86/syscall_arg_fault.c