linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Jann Horn <jannh@google.com>
Cc: Alejandro Colomar <alx@kernel.org>,
	linux-man@vger.kernel.org, Suren Baghdasaryan <surenb@google.com>,
	"Liam R . Howlett" <Liam.Howlett@oracle.com>,
	Matthew Wilcox <willy@infradead.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	linux-mm@kvack.org
Subject: Re: [PATCH man-pages v2] madvise.2: add MADV_GUARD_INSTALL, MADV_GUARD_REMOVE description
Date: Mon, 2 Dec 2024 14:05:54 +0000	[thread overview]
Message-ID: <7a4bf410-09b7-4d88-bd4e-aaae5282cb37@lucifer.local> (raw)
In-Reply-To: <CAG48ez308HQ1XOKtZM7pDVq8tG5LSnD-7jSx9NF79CpALwPD5g@mail.gmail.com>

On Fri, Nov 29, 2024 at 07:13:22PM +0100, Jann Horn wrote:
> On Fri, Nov 29, 2024 at 4:59 PM Lorenzo Stoakes
> <lorenzo.stoakes@oracle.com> wrote:
> > Lightweight guard region support has been added to Linux 6.13, which adds
> > MADV_GUARD_INSTALL and MADV_GUARD_REMOVE flags to the madvise() system
> > call. Therefore, update the manpage for madvise() and describe these
> > operations.
> [...]
> > +.TP
> > +.BR MADV_GUARD_INSTALL " (since Linux 6.13)"
> > +Install a lightweight guard region into the range specified by
> > +.I addr
> > +and
> > +.IR size ,
> > +causing any read or write in the range to result in a fatal
> > +.B SIGSEGV
> > +signal being raised.
>
> Single-word nitpick: Maybe remove the word "fatal"?
>
> I think the term "fatal signal" normally refers to a signal that is
> guaranteed to terminate the task (that's how the signal handling code
> uses the term, more or less); but a SIGSEGV caused by VM_FAULT_SIGSEGV
> can AFAIK be handled by a userspace signal handler.
>
> SIGKILL is the one signal that is always fatal; the kernel can also
> send other signals in an always-fatal way, like with force_fatal_sig()
> or force_exit_sig(), but those are not used for VM_FAULT_SIGSEGV.
> (Those functions are mostly for cases where we can't continue because
> something is in an unsafe state, like if a signal return failed and
> the register state might now be messed up.)

I think there's a bit of a disconnect between the meaning of a fatal signal
in userland and the kernel, from the kerne's perspective as per
fatal_signal_pending(), it is, as you say, SIGKILL.

From a user's persepctive, and as per sig_fatal(), it is one that is, by
default, fatal if not handled.

So I think here it's fine to say 'fatal' in the latter sense, and the fact
we immediately mention SIGSEGV clarifies in what sense we mean 'fatal'.

The intent here also is that a user would treat this as a fatal event, a
thread that accesses a guard area is accessing memory that it shouldn't.

However I also see it from your perspective, I mean we say what signal
we're sending so it's not hugely necessary and eliminates a possible
confusion.

Not sure if Alejandro has any objection to this turn of phrase?

From my perspective I don't think it's too problematic to leave it in, but
if it's easy for Alejandro to pull out I have no objection.

If people feel strongly + Alejandro would find it easier, I could just send
a v3 with it removed.

Thanks, Lorenzo


  reply	other threads:[~2024-12-02 14:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-29 15:59 Lorenzo Stoakes
2024-11-29 18:13 ` Jann Horn
2024-12-02 14:05   ` Lorenzo Stoakes [this message]
2024-12-02 14:21     ` Alejandro Colomar

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=7a4bf410-09b7-4d88-bd4e-aaae5282cb37@lucifer.local \
    --to=lorenzo.stoakes@oracle.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=alx@kernel.org \
    --cc=jannh@google.com \
    --cc=linux-man@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=surenb@google.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.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