File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
tools/testing/selftests/x86 Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 14
14
#include <errno.h>
15
15
#include <unistd.h>
16
16
#include <string.h>
17
+ #include <stdbool.h>
17
18
18
19
#include <sys/mman.h>
19
20
#include <sys/auxv.h>
@@ -55,13 +56,55 @@ static int try_to_remap(void *vdso_addr, unsigned long size)
55
56
56
57
}
57
58
59
+ #define VDSO_NAME "[vdso]"
60
+ #define VMFLAGS "VmFlags:"
61
+ #define MSEAL_FLAGS "sl"
62
+ #define MAX_LINE_LEN 512
63
+
64
+ bool vdso_sealed (FILE * maps )
65
+ {
66
+ char line [MAX_LINE_LEN ];
67
+ bool has_vdso = false;
68
+
69
+ while (fgets (line , sizeof (line ), maps )) {
70
+ if (strstr (line , VDSO_NAME ))
71
+ has_vdso = true;
72
+
73
+ if (has_vdso && !strncmp (line , VMFLAGS , strlen (VMFLAGS ))) {
74
+ if (strstr (line , MSEAL_FLAGS ))
75
+ return true;
76
+
77
+ return false;
78
+ }
79
+ }
80
+
81
+ return false;
82
+ }
83
+
58
84
int main (int argc , char * * argv , char * * envp )
59
85
{
60
86
pid_t child ;
87
+ FILE * maps ;
61
88
62
89
ksft_print_header ();
63
90
ksft_set_plan (1 );
64
91
92
+ maps = fopen ("/proc/self/smaps" , "r" );
93
+ if (!maps ) {
94
+ ksft_test_result_skip (
95
+ "Could not open /proc/self/smaps, errno=%d\n" ,
96
+ errno );
97
+
98
+ return 0 ;
99
+ }
100
+
101
+ if (vdso_sealed (maps )) {
102
+ ksft_test_result_skip ("vdso is sealed\n" );
103
+ return 0 ;
104
+ }
105
+
106
+ fclose (maps );
107
+
65
108
child = fork ();
66
109
if (child == -1 )
67
110
ksft_exit_fail_msg ("failed to fork (%d): %m\n" , errno );
You can’t perform that action at this time.
0 commit comments