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 <[email protected]> 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. > 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) { [ ... ] > + 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. > + btf__free(module_btf); > + } > + closedir(dir); > + > + btf__free(vmlinux_btf); > +} -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=6
