mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Stefan O'Rear <sorear@fastmail.com>,
	musl@lists.openwall.com, Markus Wichmann <nullplan@gmx.net>,
	enh <enh@google.com>
Subject: Re: [musl] PAC/BTI Support on aarch64
Date: Sat, 2 Mar 2024 09:45:56 -0500	[thread overview]
Message-ID: <20240302144556.GC4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <20240302143345.GC1884416@port70.net>

On Sat, Mar 02, 2024 at 03:33:45PM +0100, Szabolcs Nagy wrote:
> * Rich Felker <dalias@libc.org> [2024-02-15 09:06:40 -0500]:
> 
> > On Thu, Feb 15, 2024 at 08:29:15AM -0500, Stefan O'Rear wrote:
> > > On Tue, Feb 13, 2024, at 9:19 PM, Rich Felker wrote:
> > > > What is the situation on x86? Does it use the same kind of per-page
> > > > enforcement mode, or is it only global, requiring disabling it if any
> > > > DSO lacks support? Is the endbr64 opcode a guaranteed-safe nop on
> > > > older ISA levels, or does it need to be conditional?
> > > 
> > > The situation for hardware control flow hardening on risc-v is two
> > > in-development extensions:
> > > 
> > > Zicfilp (landing pads) provides a 4-byte instruction which marks valid
> > > targets for indirect jumps and calls, written `lpad LABEL`.  This is
> > > an *architectural NOP at all ISA levels*.  Enforcement is
> > > process-global, not per-page.
> > > 
> > > Indirect jumps can be exempted from landing pad depending on which
> > > register is used for the address; this is expected to be used if the
> > > address is obtained from read-only memory or an auipc instruction, so
> > > jump tables do not use landing pads, nor are landing pads needed after
> > > direct calls regardless of length.  A function which is not a visible
> > > symbol and does not have its address taken does not need a landing pad.
> > > 
> > > The ABI function return is a member of the set of indirect jumps
> > > which bypass landing pad checks, so no landing pads are needed at the
> > > return sites of ABI function calls.  Zicfilp intentionally does not
> > > provide any protection against ROP, a different extension must be used
> > > to protect return addresses.
> > 
> > This all sounds very good and reasonable to support.
> 
> process global setting is not practical
> because legacy code maybe dlopened so libc
> cannot decide when to enable the feature.

That's exactly what you need process-global: so as soon as you dlopen
an incompatible library, all enforcement gets turned off and
everything turns into nops.

> linux in general only provides per thread disable
> for such features which does not help with dlopen.

Indeed this is a problem. The kernel needs to provide a way to make
sure none of the special instructions, which may still be pending (and
blocked by arbitrarily many interrupting stack frames) fault if
executed after disabling. In theory there are horrible ways userspace
could do this if we wrapped signal handlers and patched things up at
every signal return (to restart any interrupted critical section), but
that kind of invasiveness is not worth it to support shadow stacks.

Rich

  reply	other threads:[~2024-03-02 14:45 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-12 16:38 William Roberts
2024-02-12 18:42 ` Rich Felker
2024-02-12 21:25   ` William Roberts
2024-02-12 21:34     ` enh
2024-02-12 22:46     ` Rich Felker
2024-02-12 23:05       ` enh
2024-02-12 23:18         ` William Roberts
2024-02-13  2:08           ` Rich Felker
2024-02-13 14:47             ` William Roberts
2024-02-13 17:51               ` Markus Wichmann
2024-02-14  2:19                 ` Rich Felker
2024-02-14  3:19                   ` William Roberts
2024-02-14  4:44                   ` Markus Wichmann
2024-02-14 13:32                     ` Thorsten Glaser
2024-02-14 14:03                       ` Rich Felker
2024-02-14 14:12                         ` Thorsten Glaser
2024-02-15 13:29                   ` Stefan O'Rear
2024-02-15 14:06                     ` Rich Felker
2024-03-02 14:33                       ` Szabolcs Nagy
2024-03-02 14:45                         ` Rich Felker [this message]
2024-02-15  0:03             ` Szabolcs Nagy
2024-02-15  0:22               ` enh
2024-02-15  9:18                 ` Szabolcs Nagy
2024-02-19 23:54   ` Fangrui Song
     [not found]   ` <DS7PR12MB57659BC5D5536574D1B91D26CB502@DS7PR12MB5765.namprd12.prod.outlook.com>
2024-02-20  6:21     ` Anton Korobeynikov

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=20240302144556.GC4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=enh@google.com \
    --cc=musl@lists.openwall.com \
    --cc=nullplan@gmx.net \
    --cc=sorear@fastmail.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).