Skip to contentSkip to conversation

ioctl_pidfd06: Select expected errno for PIDFD_GET_INFO across pidns

PATCH In review Jan Polensky 4 participants 6 messages Feb 20 – Mar 2

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ioctl_pidfd06: Select expected errno for PIDFD_GET_INFO across pidns

PIDFD_GET_INFO semantics changed for pidfds referring to tasks without a PID in the caller's current pid namespace (commit ab89060fbc92e ("pidfs: return -EREMOTE when PIDFD_GET_INFO is called on another ns")).

Select the expected errno based on the running kernel version to keep the test working on kernels before and after the change, while being strict on newer kernels to avoid accepting the legacy errno by accident.

---
 testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c +4 -1
index 751281bacb74..52da322db050 100644
@@ -14,6 +14,7 @@
 
 static struct tst_clone_args *args;
 static struct pidfd_info *info;
+static int err_nr = ESRCH;
 
 static void run(void)
 {
@@ -41,7 +42,7 @@ static void run(void)
 	args->exit_signal = SIGCHLD;
 
 	if (!SAFE_CLONE(args)) {
-		TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, info), ESRCH);
+		TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, info), err_nr);
 		exit(0);
 	}
 
@@ -52,6 +53,8 @@ static void setup(void)
 {
 	if (!ioctl_pidfd_info_exit_supported())
 		tst_brk(TCONF, "PIDFD_INFO_EXIT is not supported by ioctl()");
+	if (tst_kvercmp(7, 0, 0) >= 0)
+		err_nr = EREMOTE;
 }
 
 static struct tst_test test = {
Signature · 5 lines
2.53.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v3 1/1
#1 lore raw

Hi Jan,

Quoted 7 lines

PIDFD_GET_INFO semantics changed for pidfds referring to tasks without a PID in the caller's current pid namespace (commit ab89060fbc92e ("pidfs: return -EREMOTE when PIDFD_GET_INFO is called on another ns")).

Select the expected errno based on the running kernel version to keep the test working on kernels before and after the change, while being strict on newer kernels to avoid accepting the legacy errno by accident.

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Acked-by Jan Stancek on v3 1/1
#3 lore raw
In reply to Jan Polensky
Quoted 11 lines · Jan Polensky

PIDFD_GET_INFO semantics changed for pidfds referring to tasks without a PID in the caller's current pid namespace (commit ab89060fbc92e ("pidfs: return -EREMOTE when PIDFD_GET_INFO is called on another ns")).

Select the expected errno based on the running kernel version to keep the test working on kernels before and after the change, while being strict on newer kernels to avoid accepting the legacy errno by accident.

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Hi all,

thank you, merged!

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp