@@ -145,7 +145,7 @@ bool check_syscall_operations(int map_fd, int obj_fd)
145
145
void test_test_local_storage (void )
146
146
{
147
147
char tmp_exec_path [PATH_MAX ] = "/tmp/copy_of_rmXXXXXX" ;
148
- int err , serv_sk = -1 , task_fd = -1 ;
148
+ int err , serv_sk = -1 , task_fd = -1 , rm_fd = -1 ;
149
149
struct local_storage * skel = NULL ;
150
150
151
151
skel = local_storage__open_and_load ();
@@ -169,6 +169,15 @@ void test_test_local_storage(void)
169
169
if (CHECK (err < 0 , "copy_rm" , "err %d errno %d\n" , err , errno ))
170
170
goto close_prog ;
171
171
172
+ rm_fd = open (tmp_exec_path , O_RDONLY );
173
+ if (CHECK (rm_fd < 0 , "open" , "failed to open %s err:%d, errno:%d" ,
174
+ tmp_exec_path , rm_fd , errno ))
175
+ goto close_prog ;
176
+
177
+ if (!check_syscall_operations (bpf_map__fd (skel -> maps .inode_storage_map ),
178
+ rm_fd ))
179
+ goto close_prog ;
180
+
172
181
/* Sets skel->bss->monitored_pid to the pid of the forked child
173
182
* forks a child process that executes tmp_exec_path and tries to
174
183
* unlink its executable. This operation should be denied by the loaded
@@ -197,9 +206,14 @@ void test_test_local_storage(void)
197
206
CHECK (skel -> data -> sk_storage_result != 0 , "sk_storage_result" ,
198
207
"sk_local_storage not set\n" );
199
208
209
+ if (!check_syscall_operations (bpf_map__fd (skel -> maps .sk_storage_map ),
210
+ serv_sk ))
211
+ goto close_prog ;
212
+
200
213
close (serv_sk );
201
214
202
215
close_prog :
216
+ close (rm_fd );
203
217
close (task_fd );
204
218
local_storage__destroy (skel );
205
219
}
0 commit comments