From: sashiko-bot@kernel.org
To: "David Windsor" <dwindsor@gmail.com>
Cc: selinux@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v5 bpf-next 3/3] selftests/bpf: add tests for bpf_init_inode_xattr kfunc
Date: Wed, 08 Jul 2026 00:17:30 +0000 [thread overview]
Message-ID: <20260708001731.1EA051F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708000956.46138-4-dwindsor@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Missing file cleanup before file creation causes flaky tests. If the test files already exist, `open(O_CREAT)` will not trigger the LSM hook, leading to test failure.
--
--- Patch [3]: [PATCH v5 bpf-next 3/3] selftests/bpf: add tests for bpf_init_inode_xattr kfunc ---
commit fb13c41f9d223f18ed7c34e0e581869c6933b5e5
Author: David Windsor <dwindsor@gmail.com>
selftests/bpf: add tests for bpf_init_inode_xattr kfunc
This commit adds BPF selftests to verify atomic inode xattr labeling in the
inode_init_security hook. It introduces tests that attach to the hook and
validate that bpf_init_inode_xattr properly sets xattrs and respects the
per-inode slot limit.
> diff --git a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
> --- a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
> +++ b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
[ ... ]
> @@ -268,6 +269,123 @@ static void test_fsverity(void)
> +static void test_init_inode_xattr(void)
> +{
> + struct test_init_inode_xattr *skel = NULL;
> + int fd = -1, err;
> + char value_out[64];
> + const char *testfile_new = "/tmp/test_progs_fs_kfuncs_new";
> +
> + skel = test_init_inode_xattr__open_and_load();
> + if (!ASSERT_OK_PTR(skel, "test_init_inode_xattr__open_and_load"))
> + return;
> +
> + skel->bss->monitored_pid = getpid();
> + err = test_init_inode_xattr__attach(skel);
> + if (!ASSERT_OK(err, "test_init_inode_xattr__attach"))
> + goto out;
> +
> + /* Trigger inode_init_security */
> + fd = open(testfile_new, O_CREAT | O_RDWR, 0644);
[Severity: Medium]
Will this test become flaky if the file already exists from a previously
aborted test run?
If the testfile remains on disk from an earlier crash or failure,
open() with O_CREAT will simply open the existing file rather than create a
new inode. This would bypass the inode_init_security LSM hook entirely,
meaning the BPF program won't execute and init_result will remain at its
default value, causing the test to fail.
Would it be safer to call remove(testfile_new) before this open(), or use a
unique temporary filename to ensure the hook is always triggered?
> + if (!ASSERT_GE(fd, 0, "create_file"))
> + goto out;
> +
> + ASSERT_EQ(skel->data->init_result, 0, "init_result");
[ ... ]
> +static void test_init_inode_xattr_slot_limit(void)
> +{
[ ... ]
> + /* Trigger inode_init_security once with all programs attached. */
> + fd = open(testfile_slot, O_CREAT | O_RDWR, 0644);
[Severity: Medium]
Does this face the same issue where a pre-existing testfile_slot will
prevent the LSM hook from firing?
If remove(testfile_slot) is called prior to open(), it would guarantee a
new inode is created each time.
> + if (!ASSERT_GE(fd, 0, "create_file"))
> + goto out;
> +
> + /*
> + * Exactly INIT_INODE_XATTR_MAX programs claim a slot; the program past
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260708000956.46138-1-dwindsor@gmail.com?part=3
next prev parent reply other threads:[~2026-07-08 0:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-08 0:09 [PATCH v5 bpf-next 0/3] bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling David Windsor
2026-07-08 0:09 ` [PATCH v5 bpf-next 1/3] security: rework inode_init_security xattr handling David Windsor
2026-07-08 0:20 ` sashiko-bot
2026-07-08 0:31 ` David Windsor
2026-07-08 0:09 ` [PATCH v5 bpf-next 2/3] bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling David Windsor
2026-07-08 0:20 ` sashiko-bot
2026-07-08 0:09 ` [PATCH v5 bpf-next 3/3] selftests/bpf: add tests for bpf_init_inode_xattr kfunc David Windsor
2026-07-08 0:17 ` sashiko-bot [this message]
2026-07-08 3:12 ` [PATCH v5 bpf-next 0/3] bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling Kumar Kartikeya Dwivedi
2026-07-08 12:51 ` David Windsor
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=20260708001731.1EA051F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dwindsor@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=selinux@vger.kernel.org \
/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