Re: [PATCH v4 bpf-next 6/7] selftests/bpf: Test BTF sysfs inline representations
flat view
From: sashiko-bot@kernel.org
Date: 2026-10-09 12:25:10
Also in:
bpf
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] selftests: flaky test in test_btf_inline_sysfs_all() due to missing -ENOENT check -- commit df90a8288d824aad2169294b18c9baff7baa8c42 Author: Alan Maguire [off-list ref] selftests/bpf: Test BTF sysfs inline representations This commit adds tests to load vmlinux, vmlinux.inline, and module entries from /sys/fs/btf to sanity-check inline representations and kernel relocations. It also tests mmap functionality for vmlinux.inline.
quoted hunk ↗ jump to hunk
diff --git a/tools/testing/selftests/bpf/prog_tests/btf_sysfs.c b/tools/testing/selftests/bpf/prog_tests/btf_sysfs.c --- a/tools/testing/selftests/bpf/prog_tests/btf_sysfs.c +++ b/tools/testing/selftests/bpf/prog_tests/btf_sysfs.c
[ ... ]
+static void test_btf_inline_sysfs_all(void)
+{[ ... ]
+ while ((dentry = readdir(dir)) != NULL) {[ ... ]
quoted hunk ↗ jump to hunk
+ if (!base_btf) { + module_btf = btf__parse_split(btf_path, vmlinux_btf); + err = libbpf_get_error(module_btf); + if (err) { + /* A module can be unloaded while its sysfs entry is iterated. */ + if (err == -ENOENT) + continue; + ASSERT_OK(err, "parse_module_btf"); + continue; + } + base_btf = module_btf; + } + if (stat(inline_path, &st)) { + err = errno; + if (err != ENOENT) + ASSERT_OK(err, "stat_inline_btf"); + btf__free(module_btf); + continue; + } + if (base_btf == vmlinux_btf) + test_btf_mmap_sysfs(inline_path, base_btf); + inline_btf = btf__parse_split(inline_path, base_btf); + err = libbpf_get_error(inline_btf); + if (!err) + btf__free(inline_btf); + ASSERT_OK(err, "parse_inline_btf");
[Severity: Medium] Is this ASSERT_OK() missing a check for -ENOENT? When parsing the module BTF earlier in the loop, the code correctly handles the case where a module is unloaded during sysfs iteration by checking for -ENOENT. However, a time-of-check to time-of-use race can occur here. If the module is unloaded in the small window between stat() and btf__parse_split(), the parse function will return -ENOENT. This causes ASSERT_OK() to fail and could lead to flaky tests in parallel testing environments.
quoted hunk ↗ jump to hunk
+ btf__free(module_btf); + } + closedir(dir); + + btf__free(vmlinux_btf); +}
-- Sashiko AI review · https://sashiko.dev/#/patchset/20261009112324.1442319-1-alan.maguire@oracle.com?part=6