From: bot+bpf-ci@kernel.org
To: dwindsor@gmail.com,andrii@kernel.org,eddyz87@gmail.com,ast@kernel.org,daniel@iogearbox.net,memxor@gmail.com,shuah@kernel.org
Cc: martin.lau@linux.dev,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org,linux-kernel@vger.kernel.org,bpf@vger.kernel.org,linux-kselftest@vger.kernel.org,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH v2 2/2] selftests/bpf: add tests for bpf_init_inode_xattr kfunc
Date: Sun, 10 May 2026 21:10:32 +0000 (UTC) [thread overview]
Message-ID: <c4d24cb0de0cf600ddaba4fa89cf7cb6031f73df60141915ad3753f03c96e3a2@mail.kernel.org> (raw)
In-Reply-To: <20260503211835.16103-3-dwindsor@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3750 bytes --]
> diff --git a/tools/testing/selftests/bpf/bpf_kfuncs.h b/tools/testing/selftests/bpf/bpf_kfuncs.h
> index 7dad01439391..fd2da5487506 100644
> --- a/tools/testing/selftests/bpf/bpf_kfuncs.h
> +++ b/tools/testing/selftests/bpf/bpf_kfuncs.h
[ ... ]
> diff --git a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
> index 43a26ec69a8e..26daef116ee2 100644
> --- a/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
> +++ b/tools/testing/selftests/bpf/prog_tests/fs_kfuncs.c
[ ... ]
> +static void test_init_inode_xattr(void)
> +{
> + struct test_init_inode_xattr *skel = NULL;
> + int fd = -1, err;
> + char value_out[32];
> + const char *testfile_new = "/tmp/test_progs_fs_kfuncs_new";
Could value_out be read while uninitialized? If getxattr() succeeds but
returns fewer bytes than expected, the size ASSERT_EQ check will fail but
execution will continue. The subsequent strncmp() might then read
uninitialized stack memory.
Referenced in v1/v2 review comments at
https://lore.kernel.org/bpf/20260427011024.7A5D9C2BCAF@smtp.kernel.org/
> +
> + 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;
> +
> + /* Create a new file — this triggers inode_init_security */
> + fd = open(testfile_new, O_CREAT | O_RDWR, 0644);
If the test file already exists from a previous failed run, will open()
just open the existing file without triggering the inode_init_security
hook? Since the hook only fires when a new inode is instantiated, this
would cause the test to persistently fail.
Also, since this runs as root in the world-writable /tmp directory, could
this predictable path be vulnerable to a symlink attack?
Referenced in v1/v2 review comments at
https://lore.kernel.org/bpf/20260427011024.7A5D9C2BCAF@smtp.kernel.org/
> + if (!ASSERT_GE(fd, 0, "create_file"))
> + goto out;
> +
> + ASSERT_EQ(skel->data->init_result, 0, "init_result");
> +
> + /* The initxattrs callback prepends "security." to the name */
> + err = getxattr(testfile_new, "security.bpf.test_label", value_out,
> + sizeof(value_out));
> + if (err < 0 && errno == ENODATA) {
If the underlying /tmp filesystem does not support extended attributes at
all, getxattr() returns -1 with errno set to EOPNOTSUPP (or ENOTSUP).
Should this condition also be handled to correctly skip the test instead of
failing on the next ASSERT_GE check?
Referenced in v1/v2 review comments at
https://lore.kernel.org/bpf/20260427011024.7A5D9C2BCAF@smtp.kernel.org/
> + printf("%s:SKIP:filesystem did not apply LSM xattrs\n",
> + __func__);
> + test__skip();
> + goto out;
> + }
> + if (!ASSERT_GE(err, 0, "getxattr"))
> + goto out;
> +
> + ASSERT_EQ(err, (int)sizeof(skel->data->xattr_value), "xattr_size");
> + ASSERT_EQ(strncmp(value_out, "test_value",
> + sizeof("test_value")), 0, "xattr_value");
> +
> +out:
> + close(fd);
If an error occurs before the file is opened (e.g. during skeleton load or
attach), fd will be -1. Does this result in an unnecessary close(-1) which
returns -EBADF? Should this be guarded with if (fd >= 0)?
Referenced in v1 review comments at
https://lore.kernel.org/bpf/20260427011024.7A5D9C2BCAF@smtp.kernel.org/
> + test_init_inode_xattr__destroy(skel);
> + remove(testfile_new);
> +}
[ ... ]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/25639388555
prev parent reply other threads:[~2026-05-10 21:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260503211835.16103-1-dwindsor@gmail.com>
2026-05-03 21:18 ` [PATCH v2 1/2] bpf: add bpf_init_inode_xattr kfunc for atomic inode labeling David Windsor
2026-05-04 20:14 ` Paul Moore
2026-05-04 21:40 ` Song Liu
2026-05-04 22:42 ` Paul Moore
2026-05-04 23:09 ` Song Liu
2026-05-05 1:07 ` David Windsor
2026-05-05 2:02 ` Paul Moore
2026-05-05 2:05 ` Paul Moore
2026-05-05 9:00 ` Song Liu
2026-05-05 13:49 ` Paul Moore
2026-05-10 21:22 ` bot+bpf-ci
2026-05-03 21:18 ` [PATCH v2 2/2] selftests/bpf: add tests for bpf_init_inode_xattr kfunc David Windsor
2026-05-03 21:52 ` bot+bpf-ci
2026-05-10 21:10 ` bot+bpf-ci [this message]
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=c4d24cb0de0cf600ddaba4fa89cf7cb6031f73df60141915ad3753f03c96e3a2@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=dwindsor@gmail.com \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@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
all inboxes | Powered by JetHome®