[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZK0N65CEAd8HMOjm@arm.com>
Date: Tue, 11 Jul 2023 09:08:11 +0100
From: "szabolcs.nagy@....com" <szabolcs.nagy@....com>
To: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>,
"Lutomirski, Andy" <luto@...nel.org>
Cc: "Xu, Pengfei" <pengfei.xu@...el.com>,
"tglx@...utronix.de" <tglx@...utronix.de>,
"linux-arch@...r.kernel.org" <linux-arch@...r.kernel.org>,
"kcc@...gle.com" <kcc@...gle.com>,
"nadav.amit@...il.com" <nadav.amit@...il.com>,
"kirill.shutemov@...ux.intel.com" <kirill.shutemov@...ux.intel.com>,
"david@...hat.com" <david@...hat.com>,
"Schimpe, Christina" <christina.schimpe@...el.com>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"peterz@...radead.org" <peterz@...radead.org>,
"corbet@....net" <corbet@....net>, "nd@....com" <nd@....com>,
"broonie@...nel.org" <broonie@...nel.org>,
"dethoma@...rosoft.com" <dethoma@...rosoft.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"x86@...nel.org" <x86@...nel.org>, "pavel@....cz" <pavel@....cz>,
"bp@...en8.de" <bp@...en8.de>,
"debug@...osinc.com" <debug@...osinc.com>,
"linux-api@...r.kernel.org" <linux-api@...r.kernel.org>,
"rppt@...nel.org" <rppt@...nel.org>,
"john.allen@....com" <john.allen@....com>,
"jamorris@...ux.microsoft.com" <jamorris@...ux.microsoft.com>,
"rdunlap@...radead.org" <rdunlap@...radead.org>,
"mike.kravetz@...cle.com" <mike.kravetz@...cle.com>,
"jannh@...gle.com" <jannh@...gle.com>,
"oleg@...hat.com" <oleg@...hat.com>,
"andrew.cooper3@...rix.com" <andrew.cooper3@...rix.com>,
"keescook@...omium.org" <keescook@...omium.org>,
"gorcunov@...il.com" <gorcunov@...il.com>,
"arnd@...db.de" <arnd@...db.de>,
"Yu, Yu-cheng" <yu-cheng.yu@...el.com>,
"fweimer@...hat.com" <fweimer@...hat.com>,
"hpa@...or.com" <hpa@...or.com>,
"mingo@...hat.com" <mingo@...hat.com>,
"hjl.tools@...il.com" <hjl.tools@...il.com>,
"bsingharora@...il.com" <bsingharora@...il.com>,
"linux-mm@...ck.org" <linux-mm@...ck.org>,
"Syromiatnikov, Eugene" <esyr@...hat.com>,
"Yang, Weijiang" <weijiang.yang@...el.com>,
"linux-doc@...r.kernel.org" <linux-doc@...r.kernel.org>,
"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>,
"Torvalds, Linus" <torvalds@...ux-foundation.org>,
"Eranian, Stephane" <eranian@...gle.com>,
libc-alpha@...rceware.org, dalias@...c.org,
branislav.rankov@....com
Subject: Re: [PATCH v9 23/42] Documentation/x86: Add CET shadow stack
description
The 07/10/2023 22:56, Edgecombe, Rick P wrote:
> On Mon, 2023-07-10 at 17:54 +0100, szabolcs.nagy@....com wrote:
> > in short the only important change for v1 is shstk sizing.
>
> I tried searching through this long thread and AFAICT this is a new
> idea. Sorry if I missed something, but your previous answer on this(3)
> seemed concerned with the opposite problem (oversized shadow stacks).
>
> Quoted from a past mail:
> On Mon, 2023-07-03 at 19:19 +0100, szabolcs.nagy@....com wrote:
...
> > - tiny thread stack but big sigaltstack (musl libc, go).
and 4 months earlier:
> Date: Fri, 3 Mar 2023 16:30:37 +0000
> Subject: Re: [PATCH v7 01/41] Documentation/x86: Add CET shadow stack description
> > Looking at this again, I'm not sure why a new rlimit is needed. It
> > seems many of those points were just formulations of that the clone3
> > stack size was not used, but it actually is and just not documented. If
> > you disagree perhaps you could elaborate on what the requirements are
> > and we can see if it seems tricky to do in a follow up.
>
> - tiny thread stack and deep signal stack.
> (note that this does not really work with glibc because it has
> implementation internal signals that don't run on alt stack,
> cannot be masked and don't fit on a tiny thread stack, but
> with other runtimes this can be a valid use-case, e.g. musl
> allows tiny thread stacks, < pagesize.)
...
that analysis was wrong: it considered handling any signals
at all, but if the stack overflows due to a recursive call
with empty stack frames then the stack gets used up at the
same rate as the shadow stack and since the signal handler
on the alt stack uses the same shadow stack that can easily
overflow too independently of the stack size.
this is a big deal as it affects what operations the libc
can support and handling stack overflow is a common
requirement.
i originally argued for a fix using separate alt shadow
stacks, but since it became clear that does not work for
the x86 v1 abi i am recommending the size increase.
with shadow stack size = stack size + 1 page, libc can
document a depth limit for the alt stack that works.
(longjumping back to the alt stack is still broken
though, but that's rarely a requirement)
> Also glibc would have to size ucontext shadow stacks with an additional
yes, assuming glibc wants to support sigaltstack.
> page as well. I think it would be good to get some other signs of
> interest on this tweak due to the requirements for glibc to participate
> on the scheme. Can you gather that quickly, so we can get this all
> prepped again?
i can cc libc-alpha.
the decision is for x86 shadow stack linux abi to use
shadow stack size = stack size
or
shadow stack size = stack size + 1 page
as default policy when alt stack signals use the same
shadow stack, not a separate one.
note: smallest stack frame size is 8bytes, same as the
shadow stack entry. on a target where smallest frame
size is 2x shadow stack entry size, the formula would
use (stack size / 2).
note: there is no api to change the policy from userspace
at this point.
Powered by blists - more mailing lists