From: Oleg Nesterov <oleg@redhat.com>
To: Bradley Morgan <include@grrlz.net>
Cc: brauner@kernel.org, akpm@linux-foundation.org, tglx@kernel.org,
peterz@infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] signal: add a helper for the si_code kernel impersonation check
Date: Wed, 5 Aug 2026 22:08:31 +0200 [thread overview]
Message-ID: <anOYP3sEwR4tsWeq@redhat.com> (raw)
In-Reply-To: <28A302F8-20DB-46D6-AEA5-5F46824E57D4@grrlz.net>
On 08/05, Bradley Morgan wrote:
>
> On 5 August 2026 20:26:47 BST, Oleg Nesterov <oleg@redhat.com> wrote:
> >On 07/06, Bradley Morgan wrote:
> >>
> >> +/*
> >> + * si_code values >= 0 and SI_TKILL are reserved to the kernel. Not
> >even
> >> + * root can use them to pretend a signal was sent by the kernel or by
> >> + * kill()/tgkill(), except when signaling itself.
> >> + */
> >> +static bool si_code_reserved_to_kernel(int si_code)
> >> +{
> >> + return si_code >= 0 || si_code == SI_TKILL;
> >> +}
> >
> >...
> >
> >> static int do_rt_sigqueueinfo(pid_t pid, int sig, kernel_siginfo_t
> >*info)
> >> {
> >> - /* Not even root can pretend to send signals from the kernel.
> >> - * Nor can they impersonate a kill()/tgkill(), which adds source info.
> >> - */
> >> - if ((info->si_code >= 0 || info->si_code == SI_TKILL) &&
> >> - (task_pid_vnr(current) != pid))
> >> + if (si_code_reserved_to_kernel(info->si_code) &&
> >> + task_pid_vnr(current) != pid)
> >
> >Well, technically this (cosmetic) change is obviouly correct. And I do
> >agree
> >it makes sense to factor out these checks and (more importantly) the
> >comments.
> >
> >But. IMO, the new comment looks a bit worse.
> >
> >The old comment has "impersonate a kill()/tgkill(), which adds source
> >info"
> >and this in fact explains that si_code == 0 or si_code == SI_TKILL come
> >with
> >the real/valid .si_pid and .si_uid and the reciever can trust them.
> >
>
> Hmm, what do you suggest?
Hmm. it seems I wasn't clear...
If nothing else you can keep the old comment:
* Not even root can pretend to send signals from the kernel.
* Nor can they impersonate a kill()/tgkill(), which adds source info.
IMO, no need to add "si_code values >= 0 and SI_TKILL ..." at the start, this
just mirrors what the new (and trivial!) helper does.
May be you can improve it a bit, something like
* Not even root can pretend to send SI_FROMKERNEL() signals.
* Nor can they impersonate kill()/tgkill(), which have si_pid/uid
but this is subjective and minor.
I am fine either way. Just IMO the old comment(s) was more useful.
Oleg.
prev parent reply other threads:[~2026-08-05 20:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 12:40 Bradley Morgan
2026-08-05 19:26 ` Oleg Nesterov
2026-08-05 19:46 ` Bradley Morgan
2026-08-05 20:08 ` Oleg Nesterov [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=anOYP3sEwR4tsWeq@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=include@grrlz.net \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@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
all inboxes | Powered by JetHome®