Skip to contentSkip to conversation

ioctl_pidfd06: accept EREMOTE/ESRCH for PIDFD_GET_INFO across pidns

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

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ioctl_pidfd06: accept EREMOTE/ESRCH 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")).

Accept both errnos to keep the test working on kernels with and without the change (including backports).

---
 testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c +3 -1
index 751281bacb74..6b4bc3191e37 100644
@@ -14,6 +14,7 @@
 
 static struct tst_clone_args *args;
 static struct pidfd_info *info;
+static const int exp_errnos[] = {EREMOTE, ESRCH};
 
 static void run(void)
 {
@@ -41,7 +42,8 @@ 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_ARR(ioctl(pidfd, PIDFD_GET_INFO, info), exp_errnos,
+				ARRAY_SIZE(exp_errnos));
 		exit(0);
 	}
 
Signature · 5 lines
2.53.0


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

Hi Jan,

Quoted 6 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")).

Accept both errnos to keep the test working on kernels with and without the change (including backports).

LGTM, thanks!

Kind regards,
Petr

Quoted 26 lines
---
 testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c +3 -1
index 751281bacb74..6b4bc3191e37 100644
@@ -14,6 +14,7 @@
 
 static struct tst_clone_args *args;
 static struct pidfd_info *info;
+static const int exp_errnos[] = {EREMOTE, ESRCH};
 
 static void run(void)
 {
@@ -41,7 +42,8 @@ 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_ARR(ioctl(pidfd, PIDFD_GET_INFO, info), exp_errnos,
+				ARRAY_SIZE(exp_errnos));
 		exit(0);
 	}
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#3 lore raw
In reply to Jan Polensky

Hi!

Quoted 25 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")).

Accept both errnos to keep the test working on kernels with and without the change (including backports).

---
 testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c +1 -0
index 751281bacb74..6b4bc3191e37 100644
@@ -14,6 +14,7 @@
 
 static struct tst_clone_args *args;
 static struct pidfd_info *info;
+static const int exp_errnos[] = {EREMOTE, ESRCH};
 
 static void run(void)
 {

testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c static void run(void) · line 43

Quoted 2 lines
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c +0 -0
@@ -41,7 +42,8 @@ static void run(void)
 	args->exit_signal = SIGCHLD;
 

I would be stricter for new kernels, we do not want the new value reverted back by an accident. So what about:

static int err_nr = ARRAY_SIZE(exp_errnos);

static void setup(void)

{
	...
	if (tst_kvercmp(9, 19, 0) >= 0)
		err_nr = 1;
	...
}

testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c static void run(void) · line 46

Quoted 4 lines
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c +2 -1
 	if (!SAFE_CLONE(args)) {
-		TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, info), ESRCH);
+		TST_EXP_FAIL_ARR(ioctl(pidfd, PIDFD_GET_INFO, info), exp_errnos,
+				ARRAY_SIZE(exp_errnos));
				^
				err_nr
Quoted 6 lines
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c +0 -0
 		exit(0);
 	}
 
Signature · 1 line
2.53.0
Signature · 5 lines
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

...

Quoted 10 lines

testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c static void run(void) · line 42

Quoted 6 lines
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c +1 -0
+static const int exp_errnos[] = {EREMOTE, ESRCH};
 
 static void run(void)
 {
@@ -41,7 +42,8 @@ static void run(void)
 	args->exit_signal = SIGCHLD;

I would be stricter for new kernels, we do not want the new value reverted back by an accident. So what about:

So we might want to add this to ground rules.

Quoted 9 lines

static int err_nr = ARRAY_SIZE(exp_errnos);

static void setup(void)

{
	...
	if (tst_kvercmp(9, 19, 0) >= 0)
		err_nr = 1;
	...
}

+1

Quoted 6 lines

testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c static void run(void) · line 46

Quoted 4 lines
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c +2 -1
 	if (!SAFE_CLONE(args)) {
-		TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, info), ESRCH);
+		TST_EXP_FAIL_ARR(ioctl(pidfd, PIDFD_GET_INFO, info), exp_errnos,
+				ARRAY_SIZE(exp_errnos));
				^
				err_nr

+1

Kind regards,
Petr

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#5 lore raw
In reply to Cyril Hrubis
Quoted 2 lines · Cyril Hrubis

Hi!

Quoted 1 line

PIDFD_GET_INFO semantics changed for pidfds referring to tasks without a PID

[snip]

Quoted 15 lines
Quoted 1 line

I would be stricter for new kernels, we do not want the new value reverted back by an accident. So what about:

static int err_nr = ARRAY_SIZE(exp_errnos);

static void setup(void)

{
	...
	if (tst_kvercmp(9, 19, 0) >= 0)
		err_nr = 1;
	...
}
Quoted 6 lines

testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c static void run(void) · line 46

Quoted 4 lines
testcases/kernel/syscalls/ioctl/ioctl_pidfd06.c +2 -1
 	if (!SAFE_CLONE(args)) {
-		TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, info), ESRCH);
+		TST_EXP_FAIL_ARR(ioctl(pidfd, PIDFD_GET_INFO, info), exp_errnos,
+				ARRAY_SIZE(exp_errnos));
				^
				err_nr

Hi Cyril,

thanks for the suggestion. I agree with you.
I tested the change on v6.18.5 and v6.19.0.

I’ll send v3 with the err_nr update as proposed.

Thanks,
Jan

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