All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
Cc: linux-security-module@vger.kernel.org
Subject: Re: [PATCH v2 26/27] selftests/landlock: Use EXPECT for closing FDs and stopping threads
Date: Wed, 04 Nov 2026 21:19:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-198097@kernel.org> (raw)
In-Reply-To: <20261104-selftests-refactor-v2-26-c52f23f7ce33@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] selftests/landlock: EXPECT_EQ before reading thread output in restrict()
--

commit 85f196c7c04b9c3b9c11f5b1ad1ee130ba7d4079
Author: Günther Noack <gnoack3000@gmail.com>

selftests/landlock: Use EXPECT for closing FDs and stopping threads

This commit changes ASSERT_EQ to EXPECT_EQ across Landlock selftests when
closing file descriptors, cancelling or joining threads whose results are
unused, and cleaning up at the end of named_pipe_ioctl.

> diff --git a/tools/testing/selftests/landlock/tsync_test.c b/tools/testing/selftests/landlock/tsync_test.c
> index 2b53596c986e0..aff973ba4735b 100644
> --- a/tools/testing/selftests/landlock/tsync_test.c
> +++ b/tools/testing/selftests/landlock/tsync_test.c
> @@ -152,10 +152,10 @@ TEST_F(multi_threaded, restrict)
>  	EXPECT_EQ(variant->expected_no_new_privs,
>  		  prctl(PR_GET_NO_NEW_PRIVS, 0, 0, 0, 0));
>  
> -	ASSERT_EQ(0, pthread_cancel(t1));
> -	ASSERT_EQ(0, pthread_cancel(t2));
> -	ASSERT_EQ(0, pthread_join(t1, NULL));
> -	ASSERT_EQ(0, pthread_join(t2, NULL));
> +	EXPECT_EQ(0, pthread_cancel(t1));
> +	EXPECT_EQ(0, pthread_cancel(t2));
> +	EXPECT_EQ(0, pthread_join(t1, NULL));
> +	EXPECT_EQ(0, pthread_join(t2, NULL));
>  
>  	/* Checks the no_new_privs state of the sibling threads. */
>  	EXPECT_EQ(variant->expected_no_new_privs, no_new_privs1);

[Severity: Medium]
In TEST_F(multi_threaded, restrict), no_new_privs1 and no_new_privs2 are
declared uninitialized on the stack and passed to the idle() threads:

tools/testing/selftests/landlock/tsync_test.c:restrict() {
	...
	bool no_new_privs1, no_new_privs2;

	ASSERT_EQ(0, pthread_create(&t1, NULL, idle, &no_new_privs1));
	ASSERT_EQ(0, pthread_create(&t2, NULL, idle, &no_new_privs2));
	...
}

In idle(), those variables are only populated when the cancellation cleanup
handler store_no_new_privs() runs upon cancellation:

tools/testing/selftests/landlock/tsync_test.c:idle() {
	pthread_cleanup_push(store_no_new_privs, data);

	while (true)
		sleep(1);

	pthread_cleanup_pop(1);
}

Since the subsequent checks on no_new_privs1 and no_new_privs2 depend on
pthread_cancel() and pthread_join() succeeding to populate and synchronize
those values, should pthread_cancel() and pthread_join() remain ASSERT_EQ
here so that a failure does not fall through into reading uninitialized
stack variables?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261104-selftests-refactor-v2-0-c52f23f7ce33@gmail.com?part=26

  reply	other threads:[~2026-11-04 21:19 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-04 21:08 [PATCH v2 00/27] landlock: Selftest fixes and cleanups Günther Noack
2026-11-04 21:08 ` [PATCH v2 01/27] selftests/landlock: Propagate grandchild failures in unix_scoping Günther Noack
2026-11-04 21:13   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 02/27] selftests/landlock: Propagate EXPECT failures from forked children Günther Noack
2026-11-04 21:14   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 03/27] selftests/landlock: Check the thread result in audit.thread Günther Noack
2026-11-04 21:12   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 04/27] selftests/landlock: Zero-initialize the buffer in inconsistent_attr Günther Noack
2026-11-04 21:12   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 05/27] selftests/landlock: Fix the openat() success check in fs_bench Günther Noack
2026-11-04 21:14   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 06/27] selftests/landlock: Fix the reported clock tick rate " Günther Noack
2026-11-04 21:14   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 07/27] selftests/landlock: Fix the ruleset_fd check in empty_or_same_ruleset Günther Noack
2026-11-04 21:12   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 08/27] selftests/landlock: Handle a missing control message in recv_fd() Günther Noack
2026-11-04 21:12   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 09/27] selftests/landlock: Assert tracefs_extract_field() results that are used Günther Noack
2026-11-04 21:12   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 10/27] selftests/landlock: Assert audit initialization in fixture setups Günther Noack
2026-11-04 21:20   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 11/27] selftests/landlock: Assert helper results that are used afterwards Günther Noack
2026-11-04 21:14   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 12/27] selftests/landlock: Assert audit_count_records() before using its result Günther Noack
2026-11-04 21:14   ` sashiko-bot
2026-11-04 21:08 ` [PATCH v2 13/27] selftests/landlock: Fix memory leak in audit_init_filter_exe() Günther Noack
2026-11-04 21:13   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 14/27] selftests/landlock: Make audit_message large enough for any exe filter Günther Noack
2026-11-04 21:15   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 15/27] selftests/landlock: Close leaked file descriptors Günther Noack
2026-11-04 21:14   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 16/27] selftests/landlock: Check errno for combined VERSION and ERRATA flags Günther Noack
2026-11-04 21:14   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 17/27] selftests/landlock: Fix SIGURG handler setup in scoped_signal_test Günther Noack
2026-11-04 21:15   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 18/27] selftests/landlock: Fix regex_escape() error handling in matches_log_fs_extra() Günther Noack
2026-11-04 21:19   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 19/27] selftests/landlock: Fix off-by-one in regex_escape() Günther Noack
2026-11-04 21:15   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 20/27] selftests/landlock: Fix the snprintf() error check in matches_log_fs_extra() Günther Noack
2026-11-04 21:16   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 21/27] selftests/landlock: Use _exit() in the named_pipe_ioctl child Günther Noack
2026-11-04 21:15   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 22/27] selftests/landlock: Fix messages and comments in helper programs Günther Noack
2026-11-04 21:15   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 23/27] selftests/landlock: Fix stale comments in common.h and audit.h Günther Noack
2026-11-04 21:15   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 24/27] selftests/landlock: Use ASSERT for syscall failures before errno checks Günther Noack
2026-11-04 21:21   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 25/27] selftests/landlock: Assert WIFEXITED() before checking the exit status Günther Noack
2026-11-04 21:25   ` sashiko-bot
2026-11-04 21:09 ` [PATCH v2 26/27] selftests/landlock: Use EXPECT for closing FDs and stopping threads Günther Noack
2026-11-04 21:19   ` sashiko-bot [this message]
2026-11-04 21:09 ` [PATCH v2 27/27] selftests/landlock: Use EXPECT for checks that later steps do not need Günther Noack
2026-11-04 21:19   ` 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-198097@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-security-module@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 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.