lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 21 Feb 2024 12:45:59 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: Aruna Ramakrishna <aruna.ramakrishna@...cle.com>,
 "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Cc: "x86@...nel.org" <x86@...nel.org>, "tglx@...utronix.de"
 <tglx@...utronix.de>,
 "dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
 Keith Lucas <keith.lucas@...cle.com>,
 Andrew Brownsword <andrew.brownsword@...cle.com>,
 Dave Kleikamp <dave.kleikamp@...cle.com>, Joe Jin <joe.jin@...cle.com>
Subject: Re: PKRU issue while using alternate signal stack

On 2/21/24 11:54, Aruna Ramakrishna wrote:
> If the pkru_write_default() call were to move up the flow here, before 
> copy_fpstate_to_sigframe(), then the signal handling would work as 
> expected. But this code/flow is quite complicated, and we’d appreciate 
> some expert opinion.

First, I think you're not the first ones to report this, or want the
behavior tweaked.  I can't seem to find the thread at the moment, but
you might want to search to see if you have some fellow travelers here.

This is a bit of a chicken-and-egg problem.  We used to have some
complicated code to munge the (compacted+supervisor) kernel fpstate into
the (uncompacted+user) userspace sigframe.  That sucked, so we
simplified it to always use XSAVE to write the uncompacted+user format.

But that implementation choice fundamentally means that the register
state *MUST* match sigframe contents, at least at the time of XSAVE.
That's in direct conflict to your requirement that the sigframe be
written with different PKRU contents than what was in place at the time
that the exception happened.

That means we either need to abandon the xsave_to_user_sigframe()
approach, or we need to do something like:

	tmp_pkru = rdpkru();
	wrpkru(0);
	xsave_to_user_sigframe();
	put_user(pkru_sigframe_addr, tmp_pkru);

Which is horrid.

There are other games you could play with get_user_pages(), vmap() and
XSAVE but those would be even more horrid.

The simplest option is to just leave the altstacks writeable by all.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ