From: Robert Kueffner <r.m.kueffner@gmail.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: Kyle Huey <me@kylehuey.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Robert Kueffner <r.m.kueffner@gmail.com>
Subject: Re: Memory protection keys: Signal handlers crash if pkey0 is write-disabled
Date: Thu, 7 Sep 2023 19:07:52 -0400 [thread overview]
Message-ID: <E821837A-22AD-420C-A290-8511344E7EAF@gmail.com> (raw)
In-Reply-To: <c0159d08-e69d-0329-5ca9-68fd26cab0c8@intel.com>
> I assume that *something* is trying to access pkey-0-protected memory.
> Any idea what that is? Which entity is doing that access and what are
> they accessing? The page fault tracepoints might come in handy.
If I understand correctly, the kernel (a) pushes the processor state onto the stack and (b) resets PKRU=0x55555554 some time before switching to the signal handler. And may try between (a) and (b) to write pkey-0-protected memory.
This would be compatible with what I see when my user code causes a FPE, upon which there is a SEGV before the kernel switches to my signal handler.
If the user code causes SEGV my signal handler actually executes and only fails later when returning from syscall 14 in sigprocmask(), i.e. sigprocmask() => __GI___sigprocmask => __GI___pthread_sigmask => syscall 14
I will look into tracepoints - but that would be diagnostic rather
As a farfetched solution, would there be a way, perhaps via a kernel hook, to reset PKRU before the kernel actually starts processing the signal?
next prev parent reply other threads:[~2023-09-07 23:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-07 21:22 Robert Kueffner
2023-09-07 21:31 ` Dave Hansen
2023-09-07 23:07 ` Robert Kueffner [this message]
2023-09-08 15:14 ` Dave Hansen
2023-09-08 15:43 ` Robert Kueffner
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=E821837A-22AD-420C-A290-8511344E7EAF@gmail.com \
--to=r.m.kueffner@gmail.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=me@kylehuey.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