diff options
author | Jiri Olsa <jolsa@kernel.org> | 2020-09-18 14:23:38 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-09-22 02:18:00 +0300 |
commit | a8a717963fe5ecfd274eb93dd1285ee9428ffca7 (patch) | |
tree | 62c0f3340551492668d4416a74cd26ba07242258 /tools/testing/selftests/bpf/prog_tests/d_path.c | |
parent | c69d2ddb2072eb7ffca1a31ee5ddc16dcd414ed9 (diff) | |
download | linux-a8a717963fe5ecfd274eb93dd1285ee9428ffca7.tar.xz |
selftests/bpf: Fix stat probe in d_path test
Some kernels builds might inline vfs_getattr call within fstat
syscall code path, so fentry/vfs_getattr trampoline is not called.
Add security_inode_getattr to allowlist and switch the d_path test stat
trampoline to security_inode_getattr.
Keeping dentry_open and filp_close, because they are in their own
files, so unlikely to be inlined, but in case they are, adding
security_file_open.
Adding flags that indicate trampolines were called and failing
the test if any of them got missed, so it's easier to identify
the issue next time.
Fixes: e4d1af4b16f8 ("selftests/bpf: Add test for d_path helper")
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200918112338.2618444-1-jolsa@kernel.org
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/d_path.c')
-rw-r--r-- | tools/testing/selftests/bpf/prog_tests/d_path.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/d_path.c b/tools/testing/selftests/bpf/prog_tests/d_path.c index fc12e0d445ff..0a577a248d34 100644 --- a/tools/testing/selftests/bpf/prog_tests/d_path.c +++ b/tools/testing/selftests/bpf/prog_tests/d_path.c @@ -120,6 +120,16 @@ void test_d_path(void) if (err < 0) goto cleanup; + if (CHECK(!bss->called_stat, + "stat", + "trampoline for security_inode_getattr was not called\n")) + goto cleanup; + + if (CHECK(!bss->called_close, + "close", + "trampoline for filp_close was not called\n")) + goto cleanup; + for (int i = 0; i < MAX_FILES; i++) { CHECK(strncmp(src.paths[i], bss->paths_stat[i], MAX_PATH_LEN), "check", |