[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <dbc11c79-44bd-48aa-8548-21d86ac8fc0f@app.fastmail.com>
Date: Tue, 04 Oct 2022 10:46:17 -0700
From: "Andy Lutomirski" <luto@...nel.org>
To: "Rick P Edgecombe" <rick.p.edgecombe@...el.com>,
"Balbir Singh" <bsingharora@...il.com>,
"H. Peter Anvin" <hpa@...or.com>,
"Eugene Syromiatnikov" <esyr@...hat.com>,
"Peter Zijlstra (Intel)" <peterz@...radead.org>,
"Randy Dunlap" <rdunlap@...radead.org>,
"Kees Cook" <keescook@...omium.org>,
"Dave Hansen" <dave.hansen@...ux.intel.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
"Eranian, Stephane" <eranian@...gle.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"Florian Weimer" <fweimer@...hat.com>,
"Nadav Amit" <nadav.amit@...il.com>,
"Jann Horn" <jannh@...gle.com>,
"dethoma@...rosoft.com" <dethoma@...rosoft.com>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
"kcc@...gle.com" <kcc@...gle.com>,
"Borislav Petkov" <bp@...en8.de>,
"Oleg Nesterov" <oleg@...hat.com>, "H.J. Lu" <hjl.tools@...il.com>,
"Weijiang Yang" <weijiang.yang@...el.com>,
"Pavel Machek" <pavel@....cz>, "Arnd Bergmann" <arnd@...db.de>,
"Moreira, Joao" <joao.moreira@...el.com>,
"Thomas Gleixner" <tglx@...utronix.de>,
"Mike Kravetz" <mike.kravetz@...cle.com>,
"the arch/x86 maintainers" <x86@...nel.org>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"jamorris@...ux.microsoft.com" <jamorris@...ux.microsoft.com>,
"john.allen@....com" <john.allen@....com>,
"Mike Rapoport" <rppt@...nel.org>,
"Ingo Molnar" <mingo@...hat.com>,
"Shankar, Ravi V" <ravi.v.shankar@...el.com>,
"Jonathan Corbet" <corbet@....net>,
"Linux Kernel Mailing List" <linux-kernel@...r.kernel.org>,
"Linux API" <linux-api@...r.kernel.org>,
"Cyrill Gorcunov" <gorcunov@...il.com>
Subject: Re: [OPTIONAL/RFC v2 39/39] x86: Add alt shadow stack support
On Tue, Oct 4, 2022, at 9:12 AM, Edgecombe, Rick P wrote:
> On Mon, 2022-10-03 at 16:21 -0700, Andy Lutomirski wrote:
>> On 9/29/22 15:29, Rick Edgecombe wrote:
>> > To handle stack overflows, applications can register a separate
>> > signal alt
>> > stack to use for the stack to handle signals. To handle shadow
>> > stack
>> > overflows the kernel can similarly provide the ability to have an
>> > alt
>> > shadow stack.
>>
>>
>> The overall SHSTK mechanism has a concept of a shadow stack that is
>> valid and not in use and a shadow stack that is in use. This is
>> used,
>> for example, by RSTORSSP. I would like to imagine that this serves
>> a
>> real purpose (presumably preventing two different threads from using
>> the
>> same shadow stack and thus corrupting each others' state).
>>
>> So maybe altshstk should use exactly the same mechanism. Either
>> signal
>> delivery should do the atomic very-and-mark-busy routine or
>> registering
>> the stack as an altstack should do it.
>>
>> I think your patch has this maybe 1/3 implemented
>
> I'm not following how it breaks down into 3 parts, so hopefully I'm not
> missing something. We could do a software busy bit for the token at the
> end of alt shstk though. It seems like a good idea.
I didn't mean there were three parts. I just wild @&! guessed the amount of code written versus needed :)
>
> The busy-like bit in the RSTORSSP-type token is not called out as a
> busy bit, but instead defined as reserved (must be 0) in some states.
> (Note, it is different than the supervisor shadow stack format). Yea,
> we could just probably use it like RSTORSSP does for this operation.
>
> Or just invent another new token format and stay away from bits marked
> reserved. Then it wouldn't have to be atomic either, since userspace
> couldn't use it.
But userspace *can* use it by delivering a signal. I consider the scenario where two user threads set up the same altshstk and take signals concurrently to be about as dangerous and about as likely (under accidental or malicious conditions) as two user threads doing RSTORSSP at the same time. Someone at Intel thought the latter was a big deal, so maybe we should match its behavior.
Powered by blists - more mailing lists