From: Oleg Nesterov <oleg@redhat.com>
To: Avi Weiss <thnkslprpt@gmail.com>, Christian Brauner <brauner@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Eric W . Biederman" <ebiederm@xmission.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] signal: cleanup the .si_signo checks in dequeue_synchronous_signal()
Date: Fri, 23 Oct 2026 12:50:38 +0200 [thread overview]
Message-ID: <ats7_mSMrLBAq0Np@redhat.com> (raw)
In-Reply-To: <ats7j0mb3VF6lIg4@redhat.com>
Christian,
This is on top of Avi's
[PATCH v2] signal: respect the blocked mask in dequeue_synchronous_signal()
If you are going to update your tree and take V2 + my cleanup, I will not
mind if you fold my patch into the fix from Avi.
And! I just noticed the sashiko's review of Avi's patch:
https://sashiko.dev/#/patchset/20261022061015.3737924-1-thnkslprpt%40gmail.com
It noticed the problem with UB too. But, unlike me, it noticed another problem
with the "still_pending" logic. The described scenario is not possible after my
change, but we have the same problem with posix timers.
This needs another change. I'll try to think a bit to avoid a "brute force" fix.
Oleg.
On 10/23, Oleg Nesterov wrote:
>
> - Use SI_FROMKERNEL() instead of open-coded check
>
> - Use rt_sigmask() instead of sigmask() to avoid UB on 32-bit if
> .si_signo > 32
>
> - Pre-calculate the unblocked synchronous signal "mask" to not check
> .si_signo twice.
>
> Signed-off-by: Oleg Nesterov <oleg@redhat.com>
> ---
> kernel/signal.c | 18 +++++++-----------
> 1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/kernel/signal.c b/kernel/signal.c
> index 7386b9552dc3..64259219bbdc 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -676,21 +676,17 @@ static int dequeue_synchronous_signal(kernel_siginfo_t *info)
> struct task_struct *tsk = current;
> struct sigpending *pending = &tsk->pending;
> struct sigqueue *q, *sync = NULL;
> + unsigned long mask;
>
> - /*
> - * Might a synchronous signal be in the queue?
> - */
> - if (!((pending->signal.sig[0] & ~tsk->blocked.sig[0]) & SYNCHRONOUS_MASK))
> + /* Might a synchronous signal be in the queue? */
> + mask = (pending->signal.sig[0] & ~tsk->blocked.sig[0]) & SYNCHRONOUS_MASK;
> + if (!mask)
> return 0;
>
> - /*
> - * Return the first synchronous signal in the queue.
> - */
> + /* Return the first synchronous signal in the queue. */
> list_for_each_entry(q, &pending->list, list) {
> - /* Synchronous signals have a positive si_code */
> - if ((q->info.si_code > SI_USER) &&
> - (sigmask(q->info.si_signo) & SYNCHRONOUS_MASK) &&
> - !sigismember(&tsk->blocked, q->info.si_signo)) {
> + if (SI_FROMKERNEL(&q->info) &&
> + (rt_sigmask(q->info.si_signo) & mask)) {
> sync = q;
> goto next;
> }
> --
> 2.55.0
>
prev parent reply other threads:[~2026-10-23 10:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-22 6:10 [PATCH v2] signal: respect the blocked mask " Avi Weiss
2026-10-22 11:58 ` Oleg Nesterov
2026-10-22 20:21 ` Eric W. Biederman
2026-10-23 10:02 ` Oleg Nesterov
2026-10-22 20:15 ` Eric W. Biederman
2026-10-23 10:48 ` [PATCH] signal: cleanup the .si_signo checks " Oleg Nesterov
2026-10-23 10:50 ` 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=ats7_mSMrLBAq0Np@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=thnkslprpt@gmail.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.
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®