On Thu 23-10-25 12:46:45, Jiri Slaby wrote:
> On 10. 09. 25, 16:36, Christian Brauner wrote:
> > Validate extensible ioctls stricter than we do now.
> >
> > Signed-off-by: Christian Brauner <[email protected]>
> > ---
> > fs/pidfs.c | 2 +-
> > include/linux/fs.h | 14 ++++++++++++++
> > 2 files changed, 15 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/pidfs.c b/fs/pidfs.c
> > index edc35522d75c..0a5083b9cce5 100644
> > --- a/fs/pidfs.c
> > +++ b/fs/pidfs.c
> > @@ -440,7 +440,7 @@ static bool pidfs_ioctl_valid(unsigned int cmd)
> > * erronously mistook the file descriptor for a pidfd.
> > * This is not perfect but will catch most cases.
> > */
> > - return (_IOC_TYPE(cmd) == _IOC_TYPE(PIDFD_GET_INFO));
> > + return extensible_ioctl_valid(cmd, PIDFD_GET_INFO,
> > PIDFD_INFO_SIZE_VER0);
>
> Hi,
>
> this turned EINVAL (from pidfd_info()) into ENOTTY (from pidfd_ioctl()) for
> at least LTP's:
> struct pidfd_info_invalid {
> uint32_t dummy;
> };
>
> #define PIDFD_GET_INFO_SHORT _IOWR(PIDFS_IOCTL_MAGIC, 11, struct
> pidfd_info_invalid)
>
> ioctl(pidfd, PIDFD_GET_INFO_SHORT, info_invalid) == EINVAL
>
> at:
> https://github.com/linux-test-project/ltp/blob/9bb94efa39bb1b08f37e56c7437db5fa13ddcae2/testcases/kernel/syscalls/ioctl/ioctl_pidfd05.c#L46
>
> Is this expected?
We already discussed this internally but for others the problem was
discussed here [1] and we decided the new errno value is OK and LTP test is
being fixed up.
Honza
[1] https://lore.kernel.org/all/[email protected]/
--
Jan Kara <[email protected]>
SUSE Labs, CR