From: Oleg Nesterov <oleg@redhat.com>
To: Zhu Jun <zhujun2@cmss.chinamobile.com>
Cc: brauner@kernel.org, linux-kernel@vger.kernel.org,
syzbot+0f4d5234b6cb5e479e5d@syzkaller.appspotmail.com
Subject: Re: [PATCH] signal: Preserve the ptrace stop code for SIGCHLD notification
Date: Wed, 11 Nov 2026 17:22:26 +0100 [thread overview]
Message-ID: <avSWQsTI1KZaHFIr@redhat.com> (raw)
In-Reply-To: <20261111084310.81013-1-zhujun2@cmss.chinamobile.com>
On 11/11, Zhu Jun wrote:
>
> After ptrace_stop() drops siglock, the tracer can consume the stop with
> waitpid() and clear the tracee's exit_code. do_notify_parent_cldstop()
> then rereads that field without siglock and can report CLD_TRAPPED with
> a zero si_status instead of the stop signal.
>
> Pass the stop code saved in ptrace_stop() to the notification helper.
> The other notification reasons continue to obtain their status from
> the existing group-stop and continuation state.
But how the "correct" .si_status can actually help debugger if it has
already consumed tsk->exit_code? Why do we want this change?
> Fixes: 1da177e4c3f41 ("Linux-2.6.12-rc2")
Yes, this logic is very old. And unlikely useful.
I don't think userspace actually uses the siginfo which comes with SIGCHLD.
If nothing else, SIGCHLD doesn't queue, so si_code/si_status is not necessary
uptodate even if parent/debugger has a single child/tracee.
> static void do_notify_parent_cldstop(struct task_struct *tsk,
> - bool for_ptracer, int why)
> + bool for_ptracer, int why, int exit_code)
> {
> struct kernel_siginfo info;
> unsigned long flags;
> @@ -2394,7 +2395,7 @@ static void do_notify_parent_cldstop(struct task_struct *tsk,
> info.si_status = tsk->signal->group_exit_code & 0x7f;
> break;
> case CLD_TRAPPED:
> - info.si_status = tsk->exit_code & 0x7f;
> + info.si_status = exit_code & 0x7f;
Note that tsk->signal->group_exit_code can be cleared by waitpid() the same way,
even if tsk is not traced, so this change is incomplete.
Again, I personally think we don't care.. Perhaps something like this patch makes
sense just to make this code look more correct, but then please consider the
CLD_STOPPED case as well.
Oleg.
prev parent reply other threads:[~2026-11-11 16:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-11 8:43 [PATCH] signal: Preserve the ptrace stop code for SIGCHLD notification Zhu Jun
2026-11-11 16:22 ` 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=avSWQsTI1KZaHFIr@redhat.com \
--to=oleg@redhat.com \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+0f4d5234b6cb5e479e5d@syzkaller.appspotmail.com \
--cc=zhujun2@cmss.chinamobile.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.