All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Justin Suess" <utilityemal77@gmail.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v2 14/15] selftests/bpf: Test the LSM policy object kfuncs with Landlock
Date: Mon, 31 Aug 2026 19:53:26 +0000	[thread overview]
Message-ID: <20260831195327.1282C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831145858.3869191-15-utilityemal77@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] File descriptors leak on the error path in test_restrict_binprm_discard().
--

commit 7fa3010dd885254cc82b6aa2f6f254ee83a13717
Author: Justin Suess <utilityemal77@gmail.com>

selftests/bpf: Test the LSM policy object kfuncs with Landlock

This commit adds tests for LSM policy object kfuncs interacting with Landlock.
It tests execution confinement, audit log flags, and concurrent application
using a syscall program and BPF RCU lock management.

> diff --git a/tools/testing/selftests/bpf/prog_tests/lsm_policy_landlock.c b/tools/testing/selftests/bpf/prog_tests/lsm_policy_landlock.c
> new file mode 100644
> index 0000000000000..9270b39f5e3a7
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/lsm_policy_landlock.c
[ ... ]
> +static void test_restrict_binprm_discard(void)
> +{
> +	struct policy_test_env env;
> +	char garbage_path[] = "/tmp/lsm_policy_garbage_XXXXXX";
> +	int garbage_fd, pipe_fds[2];
> +	char buf = 0;
> +	pid_t pid;
> +
> +	if (setup_env(&env))
> +		goto out;
[ ... ]
> +	if (!ASSERT_OK(pipe(pipe_fds), "pipe"))
> +		goto out_unlink;
> +
> +	/*
> +	 * Cannot use spawn_exec_child(): the same process must test its
> +	 * write access after the failed exec.
> +	 */
> +	pid = fork();
> +	if (!ASSERT_GE(pid, 0, "fork"))
> +		goto out_unlink;

[Severity: Low]
Does this code leak the file descriptors created by pipe() if fork() fails? 

If fork() fails here, the code jumps directly to the out_unlink label, and it 
appears neither pipe_fds[0] nor pipe_fds[1] are closed before exiting the
function. 

The spawn_exec_child() helper function introduced in this same commit properly 
closes both descriptors on fork failure. Should similar cleanup be added here?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260831145858.3869191-1-utilityemal77@gmail.com?part=14

  reply	other threads:[~2026-08-31 19:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 14:58 [PATCH v2 00/15] BPF interface for applying Landlock rulesets Justin Suess
2026-08-31 14:58 ` [PATCH v2 01/15] lsm: Add the LSM policy object lifetime hooks Justin Suess
2026-08-31 17:17   ` Casey Schaufler
2026-08-31 17:41     ` Justin Suess
2026-09-02 13:05   ` Justin Suess
2026-09-02 17:51     ` Casey Schaufler
2026-09-02 18:28       ` Justin Suess
2026-08-31 14:58 ` [PATCH v2 02/15] lsm: Add the bprm_apply_policy_object LSM hook Justin Suess
2026-08-31 14:58 ` [PATCH v2 03/15] lsm: Move the lsm_for_each_hook() macro to security/lsm.h Justin Suess
2026-08-31 14:58 ` [PATCH v2 04/15] lsm: Add the bpf_lsm_policy_release kfunc and policy object destructor Justin Suess
2026-08-31 14:58 ` [PATCH v2 05/15] lsm: Add the bpf_lsm_policy_from_fd kfunc Justin Suess
2026-08-31 14:58 ` [PATCH v2 06/15] lsm: Add the bpf_lsm_policy_acquire kfunc Justin Suess
2026-08-31 14:58 ` [PATCH v2 07/15] lsm: Add the bpf_lsm_policy_apply_bprm kfunc Justin Suess
2026-08-31 14:58 ` [PATCH v2 08/15] lsm: Document the LSM policy object interface Justin Suess
2026-08-31 14:58 ` [PATCH v2 09/15] selftests/bpf: Add tests for the LSM policy object kfuncs Justin Suess
2026-08-31 14:58 ` [PATCH v2 10/15] landlock: Expose the ruleset fd lookup to the rest of Landlock Justin Suess
2026-08-31 14:58 ` [PATCH v2 11/15] landlock: Factor the credential restriction out of landlock_restrict_self() Justin Suess
2026-08-31 14:58 ` [PATCH v2 12/15] landlock: Free rulesets after an RCU grace period Justin Suess
2026-08-31 14:58 ` [PATCH v2 13/15] landlock: Implement the LSM policy object hooks Justin Suess
2026-08-31 14:58 ` [PATCH v2 14/15] selftests/bpf: Test the LSM policy object kfuncs with Landlock Justin Suess
2026-08-31 19:53   ` sashiko-bot [this message]
2026-09-02 12:24     ` Justin Suess
2026-08-31 14:58 ` [PATCH v2 15/15] landlock: Document the BPF policy interface Justin Suess

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=20260831195327.1282C1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=utilityemal77@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 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.