[LTP] [PATCH] Disable io_uring fd in ioctl_pidfd01 for selinux

Avinesh Kumar akumar@suse.de
Tue Jul 29 10:32:48 CEST 2025


On Tuesday, July 29, 2025 10:06:45 AM CEST Andrea Cervesato wrote:
> From: Andrea Cervesato <andrea.cervesato@suse.com>
> 
> Disable io_uring bad file descriptor in ioctl_pidfd01 when SELinux is
> enabled with enforcing mode. The reason is that SELinux inhibits usage
> of the io_uring file descriptor with EACCESS, causing test to fail
> without a real underlying bug.

We also have same failure for memfd_secret case in this test:

ioctl_pidfd01.c:37: TINFO: memfd secret -> ...
ioctl_pidfd01.c:28: TFAIL: ioctl(memfd secret, PIDFD_GET_INFO, info) expected EINVAL, EBADF, ENOTTY: EACCES (13)

If we are opting for skipping the tests when selinux is enforcing mode,
this also needs to be skipped.

> 
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> ioctl_pidfd01.c:37: TINFO: io uring -> ...
> ioctl_pidfd01.c:28: TFAIL: ioctl(io uring, PIDFD_GET_INFO, info) expected EINVAL, EBADF, ENOTTY: EACCES (13)
> ---
>  testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c
> index 92c51c6c0d0dcbb2308c1a8d82b2a92650f3a6b3..1ccb4bcd8a5d4283d29e0a005aef57fbb6753759 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd01.c
> @@ -17,6 +17,7 @@ static int exp_errnos[] = {
>  };
>  
>  static struct pidfd_info *info;
> +static int selinux_enforcing;
>  
>  static void test_bad_pidfd(struct tst_fd *fd_in)
>  {
> @@ -25,6 +26,11 @@ static void test_bad_pidfd(struct tst_fd *fd_in)
>  		return;
>  	}
>  
> +	if (fd_in->type == TST_FD_IO_URING && selinux_enforcing) {
> +		tst_res(TINFO, "Skipping io_uring: SELinux enforcing enabled");
> +		return;
> +	}
> +
>  	TST_EXP_FAIL_ARR(ioctl(fd_in->fd, PIDFD_GET_INFO, info),
>  		  exp_errnos, ARRAY_SIZE(exp_errnos),
>  		  "ioctl(%s, PIDFD_GET_INFO, info)",
> @@ -44,6 +50,8 @@ static void setup(void)
>  	if (!ioctl_pidfd_info_exit_supported())
>  		tst_brk(TCONF, "PIDFD_INFO_EXIT is not supported by ioctl()");
>  
> +	selinux_enforcing = tst_selinux_enforcing();
> +
>  	info->mask = PIDFD_INFO_EXIT;
>  }
>  
> 
> ---
> base-commit: 91e6272febf95e19a8300695dfc2089569adf9d8
> change-id: 20250729-ioctl_pidfd01_selinux-1479ea457850
> 
> Best regards,
> 

Thanks,
Avinesh




More information about the ltp mailing list