* [LTP] [PATCH] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors
@ 2025-10-22 11:57 Naresh Kamboju
2025-10-22 12:12 ` Petr Vorel
0 siblings, 1 reply; 2+ messages in thread
From: Naresh Kamboju @ 2025-10-22 11:57 UTC (permalink / raw)
To: ltp
Cc: arnd, brauner, jack, regressions, arnd, linux-kernel, lkft-triage,
lkft-triage, viro, benjamin.copeland, linux-fsdevel, aalbersh,
lkft, dan.carpenter
Latest kernels return ENOTTY instead of EINVAL when invoking
ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid). Update the test to
accept both EINVAL and ENOTTY as valid errors to ensure compatibility
across different kernel versions.
Link: https://lore.kernel.org/all/CA+G9fYtUp3Bk-5biynickO5U98CKKN1nkE7ooxJHp7dT1g3rxw@mail.gmail.com
Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
---
.../kernel/syscalls/ioctl/ioctl_pidfd05.c | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
index d20c6f074..ec92240a1 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
@@ -4,7 +4,7 @@
*/
/*\
- * Verify that ioctl() raises an EINVAL error when PIDFD_GET_INFO is used. This
+ * Verify that ioctl() raises an EINVAL or ENOTTY error when PIDFD_GET_INFO is used. This
* happens when:
*
* - info parameter is NULL
@@ -14,6 +14,7 @@
#include "tst_test.h"
#include "lapi/pidfd.h"
#include "lapi/sched.h"
+#include <errno.h>
#include "ioctl_pidfd.h"
struct pidfd_info_invalid {
@@ -43,7 +44,22 @@ static void run(void)
exit(0);
TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, NULL), EINVAL);
- TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid), EINVAL);
+ /* Expect ioctl to fail; accept either EINVAL or ENOTTY */
+ TEST(ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid));
+ if (TEST_RETURN == -1) {
+ if (TEST_ERRNO == EINVAL || TEST_ERRNO == ENOTTY) {
+ tst_res(TPASS,
+ "ioctl(PIDFD_GET_INFO_SHORT) failed as expected with %s",
+ tst_strerrno(TEST_ERRNO));
+ } else {
+ tst_res(TFAIL,
+ "Unexpected errno: %s (expected EINVAL or ENOTTY)",
+ tst_strerrno(TEST_ERRNO));
+ }
+ } else {
+ tst_res(TFAIL, "ioctl(PIDFD_GET_INFO_SHORT) unexpectedly succeeded");
+ }
+
SAFE_CLOSE(pidfd);
}
--
2.43.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors
2025-10-22 11:57 [LTP] [PATCH] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors Naresh Kamboju
@ 2025-10-22 12:12 ` Petr Vorel
0 siblings, 0 replies; 2+ messages in thread
From: Petr Vorel @ 2025-10-22 12:12 UTC (permalink / raw)
To: Naresh Kamboju
Cc: arnd, brauner, jack, regressions, arnd, linux-kernel, lkft-triage,
lkft-triage, ltp, benjamin.copeland, linux-fsdevel, aalbersh,
lkft, dan.carpenter, viro
Hi Naresh,
> Latest kernels return ENOTTY instead of EINVAL when invoking
> ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid). Update the test to
> accept both EINVAL and ENOTTY as valid errors to ensure compatibility
> across different kernel versions.
Thanks a lot for contributing to LTP, we really appreciate it.
> Link: https://lore.kernel.org/all/CA+G9fYtUp3Bk-5biynickO5U98CKKN1nkE7ooxJHp7dT1g3rxw@mail.gmail.com
very nit: +1 for this. I prefer to reference it differently (e.g. [1]) as I add
Link: for referencing your actual patch the same way how it's used in kernel.
(e.g. Link: https://lore.kernel.org/ltp/20251022115704.46936-1-naresh.kamboju@linaro.org/)
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
> @@ -4,7 +4,7 @@
> */
> /*\
> - * Verify that ioctl() raises an EINVAL error when PIDFD_GET_INFO is used. This
> + * Verify that ioctl() raises an EINVAL or ENOTTY error when PIDFD_GET_INFO is used. This
nit: maybe note for ENOTTY: (from v6.18)?
> * happens when:
> *
> * - info parameter is NULL
> @@ -14,6 +14,7 @@
> #include "tst_test.h"
> #include "lapi/pidfd.h"
> #include "lapi/sched.h"
> +#include <errno.h>
> #include "ioctl_pidfd.h"
> struct pidfd_info_invalid {
> @@ -43,7 +44,22 @@ static void run(void)
> exit(0);
> TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO, NULL), EINVAL);
> - TST_EXP_FAIL(ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid), EINVAL);
> + /* Expect ioctl to fail; accept either EINVAL or ENOTTY */
> + TEST(ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid));
I'm sorry, we prefer these macros in include/tst_test_macros.h which shorten the
code. Could you please use TST_EXP_FAIL_ARR() [1]?
Kind regards,
Petr
[1] https://linux-test-project.readthedocs.io/en/latest/developers/api_c_tests.html#macro-tst-exp-fail-arr
> + if (TEST_RETURN == -1) {
> + if (TEST_ERRNO == EINVAL || TEST_ERRNO == ENOTTY) {
> + tst_res(TPASS,
> + "ioctl(PIDFD_GET_INFO_SHORT) failed as expected with %s",
> + tst_strerrno(TEST_ERRNO));
> + } else {
> + tst_res(TFAIL,
> + "Unexpected errno: %s (expected EINVAL or ENOTTY)",
> + tst_strerrno(TEST_ERRNO));
> + }
> + } else {
> + tst_res(TFAIL, "ioctl(PIDFD_GET_INFO_SHORT) unexpectedly succeeded");
> + }
> +
> SAFE_CLOSE(pidfd);
> }
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-22 12:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 11:57 [LTP] [PATCH] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors Naresh Kamboju
2025-10-22 12:12 ` Petr Vorel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox