[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <81d3af8f-bad8-4559-8a0f-3271dd7f0abc@intel.com>
Date: Tue, 7 Jan 2025 10:01:14 -0800
From: Dave Hansen <dave.hansen@...el.com>
To: Rick Edgecombe <rick.p.edgecombe@...el.com>, x86@...nel.org,
tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, hpa@...or.com, luto@...nel.org,
peterz@...radead.org, linux-kernel@...r.kernel.org
Cc: christina.schimpe@...el.com
Subject: Re: [PATCH] x86: Check if shadow stack is active for ssp_get()
Some missing background: The x86 shadow stack support has its own set of
registers. Those registers are XSAVE-managed, but they are "supervisor
state components" which means that userspace can't touch them with
XSAVE/XRSTOR. It also means that they are not accessible from the
existing ptrace ABI like the FPU register or GPRs. Thus, there is a new
ptrace get/set interface for it.
The ptrace code is also provided an ->active() handler in addition to
the get/set ones. But this ->active() handler is _not_ checked before
the get/set handlers are called. This was not understood when shadow
stack support was put in place.
I think I'd also phrase the problem like this:
As a result, both the set/get handlers can be called with
XFEATURE_CET_USER in its init state, which would cause get_xsave_addr()
to return NULL and trigger a WARN_ON(). The ssp_set() handler luckily
has an ssp_active() check to avoid surprising the kernel with shadow
stack behavior when the kernel is not read for it (ARCH_SHSTK_SHSTK==0).
That check just happened to avoid the warning.
But the ->get() side wasn't so lucky. It can be called with shadow
stacks disabled, triggering the warning in practice, as reported by
Christina Schimpe:
...
Ensure that shadow stacks are active in a thread before looking them up
in the XSAVE buffer. Since ARCH_SHSTK_SHSTK and user_ssp[SHSTK_EN] are
set at the same time, the active check ensures that there will be
something to find in the XSAVE buffer.
---------------
We also want this to cc:stable, right?
Powered by blists - more mailing lists