Skip to content

Commit d11ae1b

Browse files
olsajiriborkmann
authored andcommitted
selftests/bpf: Fix d_path test
Recent commit [1] broke d_path test, because now filp_close is not called directly from sys_close, but eventually later when the file is finally released. As suggested by Hou Tao we don't need to re-hook the bpf program, but just instead we can use sys_close_range to trigger filp_close synchronously. [1] 021a160 ("fs: use __fput_sync in close(2)") Suggested-by: Hou Tao <[email protected]> Signed-off-by: Jiri Olsa <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 121fd33 commit d11ae1b

File tree

1 file changed

+18
-1
lines changed
  • tools/testing/selftests/bpf/prog_tests

1 file changed

+18
-1
lines changed

tools/testing/selftests/bpf/prog_tests/d_path.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
#include "test_d_path_check_rdonly_mem.skel.h"
1313
#include "test_d_path_check_types.skel.h"
1414

15+
/* sys_close_range is not around for long time, so let's
16+
* make sure we can call it on systems with older glibc
17+
*/
18+
#ifndef __NR_close_range
19+
#ifdef __alpha__
20+
#define __NR_close_range 546
21+
#else
22+
#define __NR_close_range 436
23+
#endif
24+
#endif
25+
1526
static int duration;
1627

1728
static struct {
@@ -90,14 +101,20 @@ static int trigger_fstat_events(pid_t pid)
90101
fstat(indicatorfd, &fileStat);
91102

92103
out_close:
93-
/* triggers filp_close */
104+
/* sys_close no longer triggers filp_close, but we can
105+
* call sys_close_range instead which still does
106+
*/
107+
#define close(fd) syscall(__NR_close_range, fd, fd, 0)
108+
94109
close(pipefd[0]);
95110
close(pipefd[1]);
96111
close(sockfd);
97112
close(procfd);
98113
close(devfd);
99114
close(localfd);
100115
close(indicatorfd);
116+
117+
#undef close
101118
return ret;
102119
}
103120

0 commit comments

Comments
 (0)