From: sashiko-bot@kernel.org
To: "Bill Roberts" <bill.roberts@arm.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v3 5/5] selftests/x86: add generic prctl shadow stack test
Date: Thu, 20 Aug 2026 15:44:43 +0000 [thread overview]
Message-ID: <20260820154443.A65CC1F01558@smtp.kernel.org> (raw)
In-Reply-To: <20260818225428.1983328-6-bill.roberts@arm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The global `_which_test` variable used by `segv_gp_handler` is only initialized inside `test_32bit()`, creating an implicit execution dependency.
--
--- Patch [5]: [PATCH v3 5/5] selftests/x86: add generic prctl shadow stack test ---
commit 4df1cdb98415fac5314af3be03f1bd5e57dfbd7c
Author: Bill Roberts <bill.roberts@arm.com>
selftests/x86: add generic prctl shadow stack test
This commit refactors the existing shadow stack selftests to allow running
the suite using both arch_prctl and the generic prctl interfaces. It moves
the core logic into a shared file and introduces a new test executable for
the generic prctl.
> diff --git a/tools/testing/selftests/x86/shadow_stack.c b/tools/testing/selftests/x86/shadow_stack.c
> new file mode 100644
> --- /dev/null
> +++ b/tools/testing/selftests/x86/shadow_stack.c
[ ... ]
> +sigjmp_buf jmp_buffer;
> +enum shadow_stack_test _which_test;
> +void segv_gp_handler(int signum, siginfo_t *si, void *uc)
> +{
> + segv_triggered = true;
> +
> + /*
> + * To work with old glibc, this can't rely on siglongjmp working with
> + * shadow stack enabled, so disable shadow stack before siglongjmp().
> + */
> + SHADOW_STACK_DISABLE(_which_test);
> + siglongjmp(jmp_buffer, -1);
> +}
[ ... ]
> +int test_32bit(enum shadow_stack_test which_test)
> +{
> + struct sigaction sa = {};
> + struct sigaction *sa32;
> +
> + _which_test = which_test;
[ ... ]
> +int shadow_stack_run_tests(enum shadow_stack_test which_test)
> +{
> + int ret = 0;
> +
[Severity: Medium]
Could this create a test execution order dependency?
The global variable _which_test is used by segv_gp_handler to multiplex
between the arch_prctl and prctl APIs before calling siglongjmp(). However,
_which_test is only explicitly initialized when test_32bit() executes.
Since segv_gp_handler is also used by test_uretprobe() and test_uprobe_call(),
if the test execution order changes or if test_32bit() gets skipped,
_which_test will remain uninitialized (defaulting to 0, which corresponds
to SHADOW_STACK_TEST_ARCH_PRCTL). This could cause the generic prctl test
binary to incorrectly use the arch_prctl APIs in its signal handler.
Should _which_test be initialized here at the entry of
shadow_stack_run_tests() instead of inside test_32bit() to ensure it is
always cleanly set for all tests that rely on this signal handler?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260818225428.1983328-1-bill.roberts@arm.com?part=5
next prev parent reply other threads:[~2026-08-20 15:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 22:54 [PATCH v3 0/5] x86: Support shstk via prctl Bill Roberts
2026-08-18 22:54 ` [PATCH v3 1/5] selftests/x86: fix Makefile dependencies Bill Roberts
2026-08-20 15:36 ` sashiko-bot
2026-08-18 22:54 ` [PATCH v3 2/5] selftests/x86: fix fork bug Bill Roberts
2026-08-18 22:54 ` [PATCH v3 3/5] selftests/x86: add shadow stack lock test Bill Roberts
2026-08-20 15:40 ` sashiko-bot
2026-08-18 22:54 ` [PATCH v3 4/5] x86/shstk: support via prctl Bill Roberts
2026-08-20 15:44 ` sashiko-bot
2026-08-18 22:54 ` [PATCH v3 5/5] selftests/x86: add generic prctl shadow stack test Bill Roberts
2026-08-20 15:44 ` sashiko-bot [this message]
2026-08-19 1:07 ` [PATCH v3 0/5] x86: Support shstk via prctl Bill Roberts
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=20260820154443.A65CC1F01558@smtp.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