@@ -145,7 +145,7 @@ bool check_syscall_operations(int map_fd, int obj_fd)
145145void test_test_local_storage (void )
146146{
147147 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 ;
149149 struct local_storage * skel = NULL ;
150150
151151 skel = local_storage__open_and_load ();
@@ -169,6 +169,15 @@ void test_test_local_storage(void)
169169 if (CHECK (err < 0 , "copy_rm" , "err %d errno %d\n" , err , errno ))
170170 goto close_prog ;
171171
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+
172181 /* Sets skel->bss->monitored_pid to the pid of the forked child
173182 * forks a child process that executes tmp_exec_path and tries to
174183 * unlink its executable. This operation should be denied by the loaded
@@ -197,9 +206,14 @@ void test_test_local_storage(void)
197206 CHECK (skel -> data -> sk_storage_result != 0 , "sk_storage_result" ,
198207 "sk_local_storage not set\n" );
199208
209+ if (!check_syscall_operations (bpf_map__fd (skel -> maps .sk_storage_map ),
210+ serv_sk ))
211+ goto close_prog ;
212+
200213 close (serv_sk );
201214
202215close_prog :
216+ close (rm_fd );
203217 close (task_fd );
204218 local_storage__destroy (skel );
205219}
0 commit comments