[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <de05c6c8-1139-cc40-8908-86c0dd645417@linuxfoundation.org>
Date: Fri, 29 May 2020 08:42:16 -0600
From: Shuah Khan <skhan@...uxfoundation.org>
To: Sasha Levin <sashal@...nel.org>, tglx@...utronix.de,
luto@...nel.org, ak@...ux.intel.com
Cc: corbet@....net, mingo@...hat.com, bp@...en8.de, x86@...nel.org,
shuah@...nel.org, gregkh@...uxfoundation.org, tony.luck@...el.com,
chang.seok.bae@...el.com, dave.hansen@...ux.intel.com,
peterz@...radead.org, linux-doc@...r.kernel.org,
linux-kernel@...r.kernel.org, jarkko.sakkinen@...ux.intel.com,
"H . Peter Anvin" <hpa@...or.com>,
Dave Hansen <dave.hansen@...el.com>,
Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH v13 16/16] selftests/x86/fsgsbase: Test ptracer-induced GS
base write with FSGSBASE
On 5/28/20 2:14 PM, Sasha Levin wrote:
> From: "Chang S. Bae" <chang.seok.bae@...el.com>
>
> This validates that GS selector and base are independently preserved in
> ptrace commands.
>
> Suggested-by: Andy Lutomirski <luto@...nel.org>
> Signed-off-by: Chang S. Bae <chang.seok.bae@...el.com>
> Reviewed-by: Tony Luck <tony.luck@...el.com>
> Cc: Thomas Gleixner <tglx@...utronix.de>
> Cc: Borislav Petkov <bp@...en8.de>
> Cc: Andy Lutomirski <luto@...nel.org>
> Cc: H. Peter Anvin <hpa@...or.com>
> Cc: Dave Hansen <dave.hansen@...el.com>
> Cc: Tony Luck <tony.luck@...el.com>
> Cc: Andi Kleen <ak@...ux.intel.com>
> Signed-off-by: Sasha Levin <sashal@...nel.org>
> ---
> tools/testing/selftests/x86/fsgsbase.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/x86/fsgsbase.c b/tools/testing/selftests/x86/fsgsbase.c
> index 950a48b2e366..9a4349813a30 100644
> --- a/tools/testing/selftests/x86/fsgsbase.c
> +++ b/tools/testing/selftests/x86/fsgsbase.c
> @@ -465,7 +465,7 @@ static void test_ptrace_write_gsbase(void)
> wait(&status);
>
> if (WSTOPSIG(status) == SIGTRAP) {
> - unsigned long gs;
> + unsigned long gs, base;
> unsigned long gs_offset = USER_REGS_OFFSET(gs);
> unsigned long base_offset = USER_REGS_OFFSET(gs_base);
>
> @@ -481,6 +481,7 @@ static void test_ptrace_write_gsbase(void)
> err(1, "PTRACE_POKEUSER");
>
> gs = ptrace(PTRACE_PEEKUSER, child, gs_offset, NULL);
> + base = ptrace(PTRACE_PEEKUSER, child, base_offset, NULL);
>
> /*
> * In a non-FSGSBASE system, the nonzero selector will load
> @@ -501,8 +502,14 @@ static void test_ptrace_write_gsbase(void)
> */
> if (gs == 0)
> printf("\tNote: this is expected behavior on older kernels.\n");
I know this hasn't changed. Please clarify what is "this" in this
message.
> + } else if (have_fsgsbase && (base != 0xFF)) {
> + nerrs++;
> + printf("[FAIL]\tGSBASE changed to %lx\n", base);
> } else {
> - printf("[OK]\tGS remained 0x%hx\n", *shared_scratch);
> + printf("[OK]\tGS remained 0x%hx", *shared_scratch);
> + if (have_fsgsbase)
> + printf(" and GSBASE changed to 0xFF");
> + printf("\n");
> }
> }
>
>
thanks,
-- Shuah
Powered by blists - more mailing lists