]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
selftest/pidfd: add test for thread-group leader pidfd open for thread
authorChristian Brauner <brauner@kernel.org>
Thu, 3 Apr 2025 14:09:04 +0000 (16:09 +0200)
committerChristian Brauner <brauner@kernel.org>
Mon, 7 Apr 2025 07:38:24 +0000 (09:38 +0200)
Verify that we report ENOENT when userspace tries to create a
thread-group leader pidfd for a thread pidfd that isn't a thread-group
leader.

Link: https://lore.kernel.org/r/20250403-work-pidfd-fixes-v1-4-a123b6ed6716@kernel.org
Reviewed-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
tools/testing/selftests/pidfd/pidfd_info_test.c

index accfd6bdc539e57173bf8fbb763eff687321168e..a0eb6e81eaa26d1d44b94546397b1dd6dead4b29 100644 (file)
@@ -299,6 +299,7 @@ TEST_F(pidfd_info, thread_group)
        /* Opening a thread as a thread-group leader must fail. */
        pidfd_thread = sys_pidfd_open(pid_thread, 0);
        ASSERT_LT(pidfd_thread, 0);
+       ASSERT_EQ(errno, ENOENT);
 
        /* Opening a thread as a PIDFD_THREAD must succeed. */
        pidfd_thread = sys_pidfd_open(pid_thread, PIDFD_THREAD);