bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Bill Roberts" <bill.roberts@arm.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v5 2/6] selftests/x86: fix fork bug
Date: Mon, 09 Nov 2026 18:36:13 +0000	[thread overview]
Message-ID: <sashiko-outbox-205424@kernel.org> (raw)
In-Reply-To: <20261109182758.252223-3-bill.roberts@arm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] selftests/x86: missing Fixes trailer and redundant report text
  in changelog
--

commit 63564f14db64d744c41e3438f86b4c7188ec7e2a
Author: Bill Roberts <bill.roberts@arm.com>

> selftests/x86: fix fork bug
>
> The shadow stack ptrace test does not check whether fork() fails
> before proceeding with the parent-side ptrace operations.
>
> If fork() fails, it returns -1, which is subsequently passed to
> kill() on the test's error path. Calling kill(-1, SIGKILL) sends
> SIGKILL to every process the caller has permission to signal,
> potentially terminating unrelated processes.
>
> Check for fork() failure immediately and return an error before
> entering the ptrace test's parent-side logic.
>
> Shashiko pointed out this fork bug, and the relevant snippets from the
> report are below:
>
> [ ... ]
> > +int test_ptrace(void)
> > +{
> > +     unsigned long saved_ssp, ssp = 0;
> > +     struct sigaction sa = {};
> > +     struct iovec iov;
> > +     int status;
> > +     int pid;
> > +
> > +     iov.iov_base = &ssp;
> > +     iov.iov_len = sizeof(ssp);
> > +
> > +     pid = fork();
> > +     if (!pid) {
>
> [Severity: High]
> This is a pre-existing issue, but could this code broadcast SIGKILL to
> all user processes if fork() fails?
>
> If fork() returns -1 due to resource limits, execution will proceed with
> pid = -1. When ptrace() subsequently fails, the error path is triggered:
>
> out_kill:
>         kill(pid, SIGKILL);
>         return 1;
>
> Since pid is -1, POSIX specifies that this will kill all processes the
> current user has permission to terminate, potentially crashing the host
> environment.
>
> Signed-off-by: Bill Roberts <bill.roberts@arm.com>

[Severity: Low]
This fixes a bug in test_ptrace() introduced with the shadow stack test.
Should the commit message include:

  Fixes: 81f30337ef4f ("selftests/x86: Add shadow stack test")

Also, this isn't a bug, but the subject does not mention shadow_stack or
test_ptrace(), and the pasted review snippet in the second half of the
changelog repeats the explanation already given in the first three
paragraphs.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261109182758.252223-1-bill.roberts@arm.com?part=2

  reply	other threads:[~2026-11-09 18:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-09 18:27 [PATCH v5 0/6] x86: Support shstk via prctl Bill Roberts
2026-11-09 18:27 ` [PATCH v5 1/6] selftests/x86: fix Makefile dependencies Bill Roberts
2026-11-09 18:27 ` [PATCH v5 2/6] selftests/x86: fix fork bug Bill Roberts
2026-11-09 18:36   ` sashiko-bot [this message]
2026-11-09 18:27 ` [PATCH v5 3/6] selftests/x86: add shadow stack lock test Bill Roberts
2026-11-09 18:35   ` sashiko-bot
2026-11-09 18:27 ` [PATCH v5 4/6] x86/shstk: support via prctl Bill Roberts
2026-11-09 18:52   ` sashiko-bot
2026-11-09 18:27 ` [PATCH v5 5/6] selftests/x86: support header files in extra-files Bill Roberts
2026-11-09 18:27 ` [PATCH v5 6/6] selftests/x86: add generic prctl shadow stack test Bill Roberts
2026-11-09 18:46   ` sashiko-bot

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=sashiko-outbox-205424@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bill.roberts@arm.com \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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;
as well as URLs for NNTP newsgroup(s).