[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8b1297a4-00f0-431a-8fff-4ce2745adfab@p183>
Date: Tue, 3 Oct 2023 16:03:55 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: Ingo Molnar <mingo@...nel.org>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
linux-kernel@...r.kernel.org, "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH] x86_64: test that userspace stack is in fact NX
On Mon, Oct 02, 2023 at 03:12:35PM +0200, Ingo Molnar wrote:
>
> * Alexey Dobriyan <adobriyan@...il.com> wrote:
>
> > Here is how it works:
> >
> > * fault and fill the stack from rsp with int3 down until rlimit allows,
> > * fill upwards with int3 too, overwrite libc stuff, argv, envp,
> > * try to exec int3 on each page and catch it with either SIGSEGV or
> > SIGTRAP handler.
> >
> > Note: trying to execute _every_ int3 takes 30-40 seconds even on fast
> > machine, so only 1 int3 per page is tried.
> >
> > Tested on F37 kernel and on custom kernel which did
> >
> > vm_flags |= VM_EXEC;
> >
> > to stack VMA.
> >
> > Signed-off-by: Alexey Dobriyan <adobriyan@...il.com>
> > ---
> >
> > tools/testing/selftests/x86/Makefile | 3
> > tools/testing/selftests/x86/nx_stack.c | 167 +++++++++++++++++++++++++++++++++
> > 2 files changed, 170 insertions(+)
>
> Ok, that's a good idea, but could the test case please output something
> human-readable that indicates whether the test was a success or not?
>
> A typical testcase output is like:
>
> kepler:~/tip/tools/testing/selftests/x86> ./sigaltstack_32
> [RUN] Test an alternate signal stack of sufficient size.
> Raise SIGALRM. It is expected to be delivered.
> [OK] SIGALRM signal delivered.
>
> Or:
>
> kepler:~/tip/tools/testing/selftests/x86> ./test_vsyscall_64
> ...
> [OK] vsyscalls are emulated (1 instructions in vsyscall page)
> ...
>
> ... where the 'OK' denotes success of a test.
>
> The nx_stack testcase only outputs:
>
> stack min 00007fffd75b5000
> stack max 00007fffd7db5000
>
> ... with only the exit code denoting success/failure.
The way Unix Founding Fathers intented! :-)
OK, I'll add something.
Powered by blists - more mailing lists