@@ -4255,6 +4255,61 @@ TEST(user_notification_addfd_rlimit)
4255
4255
close (memfd );
4256
4256
}
4257
4257
4258
+ #ifndef SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP
4259
+ #define SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP (1UL << 0)
4260
+ #define SECCOMP_IOCTL_NOTIF_SET_FLAGS SECCOMP_IOW(4, __u64)
4261
+ #endif
4262
+
4263
+ TEST (user_notification_sync )
4264
+ {
4265
+ struct seccomp_notif req = {};
4266
+ struct seccomp_notif_resp resp = {};
4267
+ int status , listener ;
4268
+ pid_t pid ;
4269
+ long ret ;
4270
+
4271
+ ret = prctl (PR_SET_NO_NEW_PRIVS , 1 , 0 , 0 , 0 );
4272
+ ASSERT_EQ (0 , ret ) {
4273
+ TH_LOG ("Kernel does not support PR_SET_NO_NEW_PRIVS!" );
4274
+ }
4275
+
4276
+ listener = user_notif_syscall (__NR_getppid ,
4277
+ SECCOMP_FILTER_FLAG_NEW_LISTENER );
4278
+ ASSERT_GE (listener , 0 );
4279
+
4280
+ /* Try to set invalid flags. */
4281
+ EXPECT_SYSCALL_RETURN (- EINVAL ,
4282
+ ioctl (listener , SECCOMP_IOCTL_NOTIF_SET_FLAGS , 0xffffffff , 0 ));
4283
+
4284
+ ASSERT_EQ (ioctl (listener , SECCOMP_IOCTL_NOTIF_SET_FLAGS ,
4285
+ SECCOMP_USER_NOTIF_FD_SYNC_WAKE_UP , 0 ), 0 );
4286
+
4287
+ pid = fork ();
4288
+ ASSERT_GE (pid , 0 );
4289
+ if (pid == 0 ) {
4290
+ ret = syscall (__NR_getppid );
4291
+ ASSERT_EQ (ret , USER_NOTIF_MAGIC ) {
4292
+ _exit (1 );
4293
+ }
4294
+ _exit (0 );
4295
+ }
4296
+
4297
+ req .pid = 0 ;
4298
+ ASSERT_EQ (ioctl (listener , SECCOMP_IOCTL_NOTIF_RECV , & req ), 0 );
4299
+
4300
+ ASSERT_EQ (req .data .nr , __NR_getppid );
4301
+
4302
+ resp .id = req .id ;
4303
+ resp .error = 0 ;
4304
+ resp .val = USER_NOTIF_MAGIC ;
4305
+ resp .flags = 0 ;
4306
+ ASSERT_EQ (ioctl (listener , SECCOMP_IOCTL_NOTIF_SEND , & resp ), 0 );
4307
+
4308
+ ASSERT_EQ (waitpid (pid , & status , 0 ), pid );
4309
+ ASSERT_EQ (status , 0 );
4310
+ }
4311
+
4312
+
4258
4313
/* Make sure PTRACE_O_SUSPEND_SECCOMP requires CAP_SYS_ADMIN. */
4259
4314
FIXTURE (O_SUSPEND_SECCOMP ) {
4260
4315
pid_t pid ;
0 commit comments