public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors
@ 2025-10-23 16:44 Naresh Kamboju
  2025-10-23 19:20 ` Anders Roxell
  2025-10-23 20:02 ` [LTP] " Avinesh Kumar
  0 siblings, 2 replies; 4+ messages in thread
From: Naresh Kamboju @ 2025-10-23 16:44 UTC (permalink / raw)
  To: ltp
  Cc: lkft, arnd, dan.carpenter, pvorel, jack, brauner, chrubis,
	linux-kernel, linux-fsdevel, regressions, aalbersh, arnd, viro,
	anders.roxell, benjamin.copeland, andrea.cervesato, lkft-triage,
	Naresh Kamboju

Newer kernels (since ~v6.18-rc1) 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.

Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
---
 testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
index d20c6f074..744f7def4 100644
--- a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
+++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
@@ -4,8 +4,8 @@
  */
 
 /*\
- * Verify that ioctl() raises an EINVAL error when PIDFD_GET_INFO is used. This
- * happens when:
+ * Verify that ioctl() raises an EINVAL or ENOTTY (since ~v6.18-rc1) error when
+ * PIDFD_GET_INFO is used. This happens when:
  *
  * - info parameter is NULL
  * - info parameter is providing the wrong size
@@ -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,12 @@ 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 (~v6.18-rc1) */
+	int exp_errnos[] = {EINVAL, ENOTTY};
+
+	TST_EXP_FAIL_ARR(ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid),
+			exp_errnos, ARRAY_SIZE(exp_errnos));
 
 	SAFE_CLOSE(pidfd);
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors
  2025-10-23 16:44 [PATCH v2] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors Naresh Kamboju
@ 2025-10-23 19:20 ` Anders Roxell
  2025-10-24  8:15   ` Petr Vorel
  2025-10-23 20:02 ` [LTP] " Avinesh Kumar
  1 sibling, 1 reply; 4+ messages in thread
From: Anders Roxell @ 2025-10-23 19:20 UTC (permalink / raw)
  To: Naresh Kamboju
  Cc: ltp, lkft, arnd, dan.carpenter, pvorel, jack, brauner, chrubis,
	linux-kernel, linux-fsdevel, regressions, aalbersh, arnd, viro,
	benjamin.copeland, andrea.cervesato, lkft-triage

On Thu, 23 Oct 2025 at 18:44, Naresh Kamboju <naresh.kamboju@linaro.org> wrote:
>
> Newer kernels (since ~v6.18-rc1) 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.
>
> Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>

Verified this on arm64, and the test passed now.

Tested-by: Anders Roxell <anders.roxell@linaro.org>


Cheers,
Anders

> ---
>  testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
> index d20c6f074..744f7def4 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
> @@ -4,8 +4,8 @@
>   */
>
>  /*\
> - * Verify that ioctl() raises an EINVAL error when PIDFD_GET_INFO is used. This
> - * happens when:
> + * Verify that ioctl() raises an EINVAL or ENOTTY (since ~v6.18-rc1) error when
> + * PIDFD_GET_INFO is used. This happens when:
>   *
>   * - info parameter is NULL
>   * - info parameter is providing the wrong size
> @@ -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,12 @@ 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 (~v6.18-rc1) */
> +       int exp_errnos[] = {EINVAL, ENOTTY};
> +
> +       TST_EXP_FAIL_ARR(ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid),
> +                       exp_errnos, ARRAY_SIZE(exp_errnos));
>
>         SAFE_CLOSE(pidfd);
>  }
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [LTP] [PATCH v2] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors
  2025-10-23 16:44 [PATCH v2] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors Naresh Kamboju
  2025-10-23 19:20 ` Anders Roxell
@ 2025-10-23 20:02 ` Avinesh Kumar
  1 sibling, 0 replies; 4+ messages in thread
From: Avinesh Kumar @ 2025-10-23 20:02 UTC (permalink / raw)
  To: ltp, Naresh Kamboju
  Cc: arnd, brauner, jack, regressions, arnd, linux-kernel, lkft-triage,
	viro, benjamin.copeland, linux-fsdevel, aalbersh, lkft,
	dan.carpenter

Hi,


On Thursday, October 23, 2025 6:44:01 PM CEST Naresh Kamboju wrote:
> Newer kernels (since ~v6.18-rc1) 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.
> 
> Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>

Tested-by: Avinesh Kumar <akumar@suse.de>
Reviewed-by: Avinesh Kumar <akumar@suse.de>

Regards,
Avinesh

> ---
>  testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
> index d20c6f074..744f7def4 100644
> --- a/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
> +++ b/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c
> @@ -4,8 +4,8 @@
>   */
>  
>  /*\
> - * Verify that ioctl() raises an EINVAL error when PIDFD_GET_INFO is used. This
> - * happens when:
> + * Verify that ioctl() raises an EINVAL or ENOTTY (since ~v6.18-rc1) error when
> + * PIDFD_GET_INFO is used. This happens when:
>   *
>   * - info parameter is NULL
>   * - info parameter is providing the wrong size
> @@ -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,12 @@ 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 (~v6.18-rc1) */
> +	int exp_errnos[] = {EINVAL, ENOTTY};
> +
> +	TST_EXP_FAIL_ARR(ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid),
> +			exp_errnos, ARRAY_SIZE(exp_errnos));
>  
>  	SAFE_CLOSE(pidfd);
>  }
> 





^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors
  2025-10-23 19:20 ` Anders Roxell
@ 2025-10-24  8:15   ` Petr Vorel
  0 siblings, 0 replies; 4+ messages in thread
From: Petr Vorel @ 2025-10-24  8:15 UTC (permalink / raw)
  To: Anders Roxell
  Cc: Naresh Kamboju, ltp, lkft, arnd, dan.carpenter, jack, brauner,
	chrubis, linux-kernel, linux-fsdevel, regressions, aalbersh, arnd,
	viro, benjamin.copeland, andrea.cervesato, lkft-triage,
	Avinesh Kumar

Hi all,

> On Thu, 23 Oct 2025 at 18:44, Naresh Kamboju <naresh.kamboju@linaro.org> wrote:

> > Newer kernels (since ~v6.18-rc1) 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.

I dared to add a commit which caused the change (found by Cyril Hrubis):
3c17001b21b9f ("pidfs: validate extensible ioctls")

and merged!

Thanks for fix and review!

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-10-24  8:16 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-23 16:44 [PATCH v2] ioctl_pidfd05: accept both EINVAL and ENOTTY as valid errors Naresh Kamboju
2025-10-23 19:20 ` Anders Roxell
2025-10-24  8:15   ` Petr Vorel
2025-10-23 20:02 ` [LTP] " Avinesh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox