linux-api.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Soni \"They/Them\" L." <fakedme@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: linux-api@vger.kernel.org
Subject: Re: mprotect PROT_SIGNAL
Date: Tue, 16 Jul 2024 13:16:30 -0300	[thread overview]
Message-ID: <67d71aa6-8ad3-414f-a6da-736481758614@gmail.com> (raw)
In-Reply-To: <87ikx5z7xp.fsf@oldenburg.str.redhat.com>



On 2024-07-16 12:13, Florian Weimer wrote:
> * Soni L.:
>
> > we'd like an mprotect PROT_SIGNAL flag for a compiler we're making
> >
> > PROT_SIGNAL - marks the pages as unmapped while running signal handlers
> >
> > this would be very useful, do you think you could provide it?
> >
> > (not much more to say about it, it's supposed to do what it says on
> > the tin, we want to unmap pages in signal handlers so as to catch bugs
> > without causing memory corruption.)
>
> The challenge is going to be to detect abnormal exit from the signal
> handler.
>
> You can already get some of this behavior to today with memory
> protection keys, on x86-64 at least.  (I consider this a glitch in the
> implementation, it makes it less useful.)  Access is revoked
> automatically when the hander is invoked.  However, access is not
> restored if you jump out of the handler using longjmp or by throwing an
> exception.

As it should be - POSIX specifies that longjmping out of a handler 
remains in handler context, so you still can't call signal-unsafe functions.

Presumably, an API to manually map them back in would be necessary in 
the case of e.g. the JVM, which uses signal handlers for 
hardware-accelerated null checks.

> Thanks,
> Florian
>


      reply	other threads:[~2024-07-16 16:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 16:44 mprotect PROT_SIGNAL Soni "They/Them" L.
2024-07-16 15:13 ` Florian Weimer
2024-07-16 16:16   ` Soni "They/Them" L. [this message]

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=67d71aa6-8ad3-414f-a6da-736481758614@gmail.com \
    --to=fakedme@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=linux-api@vger.kernel.org \
    /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.
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).