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 21:26:47 +0200 [thread overview]
Message-ID: <anOOd-zNR5IMYSAG@redhat.com> (raw)
In-Reply-To: <20260706124003.8000-1-include@grrlz.net>
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.
As for the naming... I would like to suggest a better name for the new helper
but I can't ;)
Oleg.
next prev parent reply other threads:[~2026-08-05 19:27 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 [this message]
2026-08-05 19:46 ` Bradley Morgan
2026-08-05 20:08 ` Oleg Nesterov
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=anOOd-zNR5IMYSAG@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®