From: Alexey Dobriyan <adobriyan@gmail.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH] x86_64: test that userspace stack is in fact NX
Date: Tue, 3 Oct 2023 16:00:10 +0300 [thread overview]
Message-ID: <d468d13c-6c4b-4d8d-8e2d-e4314b4bb1a7@p183> (raw)
In-Reply-To: <1d5223b8-0275-619d-db1c-e2aaaddb173e@intel.com>
On Mon, Oct 02, 2023 at 07:23:10AM -0700, Dave Hansen wrote:
> On 10/1/23 09:31, Alexey Dobriyan 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.
>
> I guess the subject implies it, but it's probably worth a sentence or
> two in the changelog about this being 64-bit only.
>
> IIRC, there _are_ x86_64 CPUs that don't support NX. It's also entirely
> possible for a hypervisor to disable NX enumeration for a guest. Those
> two are (probably) rare enough that they can be ignored for now. But it
> might mean adding a CPUID check at some point.
>
> Basically, could you spend a moment in the changelog to talk about:
>
> 1. 32-bit kernels on NX hardware
> and
> 2. 64-bit kernels on non-NX hardware
Sure. My logic whas that i386 is dead arch, but this test is easy to
port to i386, only 2 simple functions.
I don't want to parse /proc/cpuinfo. If someone knows they're shipping
NX-incapable hardware, just let them disable the test.
next prev parent reply other threads:[~2023-10-03 13:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-01 16:31 Alexey Dobriyan
2023-10-02 13:12 ` Ingo Molnar
2023-10-03 13:03 ` Alexey Dobriyan
2023-10-02 14:23 ` Dave Hansen
2023-10-03 13:00 ` Alexey Dobriyan [this message]
2023-10-03 14:23 ` Dave Hansen
2023-10-03 19:06 ` Ingo Molnar
2023-10-03 19:30 ` Ingo Molnar
2023-10-03 20:46 ` Dave Hansen
2023-10-03 21:53 ` H. Peter Anvin
2023-10-03 16:18 ` [PATCH v2] x86: " Alexey Dobriyan
2023-10-03 19:01 ` Ingo Molnar
2023-10-03 19:12 ` [tip: x86/mm] selftests/x86/mm: Add new " tip-bot2 for Alexey Dobriyan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d468d13c-6c4b-4d8d-8e2d-e4314b4bb1a7@p183 \
--to=adobriyan@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®