[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <u67ijiie6n2w3crfpuipprrmkocja7bxadlo3sbr47w7hysjgj@rjduhmczwwdz>
Date: Thu, 24 Jul 2025 12:16:40 +0200
From: Klara Modin <klarasmodin@...il.com>
To: Arnd Bergmann <arnd@...db.de>
Cc: Arnd Bergmann <arnd@...nel.org>, Anuj Gupta <anuj20.g@...sung.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>, Kanchan Joshi <joshi.k@...sung.com>,
Christian Brauner <brauner@...nel.org>, Christoph Hellwig <hch@...radead.org>,
Naresh Kamboju <naresh.kamboju@...aro.org>, Anders Roxell <anders.roxell@...aro.org>,
Jens Axboe <axboe@...nel.dk>, Keith Busch <kbusch@...nel.org>,
Caleb Sander Mateos <csander@...estorage.com>, Pavel Begunkov <asml.silence@...il.com>,
Alexey Dobriyan <adobriyan@...il.com>, "Darrick J. Wong" <djwong@...nel.org>,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] [v2] block: fix FS_IOC_GETLBMD_CAP parsing in
blkdev_common_ioctl()
On 2025-07-18 07:56:49 +0200, Arnd Bergmann wrote:
> On Fri, Jul 18, 2025, at 01:37, Klara Modin wrote:
>
> >> diff --git a/block/ioctl.c b/block/ioctl.c
> >> index 9ad403733e19..af2e22e5533c 100644
> >> --- a/block/ioctl.c
> >> +++ b/block/ioctl.c
> >> @@ -566,9 +566,11 @@ static int blkdev_common_ioctl(struct block_device *bdev, blk_mode_t mode,
> >> void __user *argp)
> >> {
> >> unsigned int max_sectors;
> >> + int ret;
> >>
> >> - if (_IOC_NR(cmd) == _IOC_NR(FS_IOC_GETLBMD_CAP))
> >> - return blk_get_meta_cap(bdev, cmd, argp);
> >
> >> + ret = blk_get_meta_cap(bdev, cmd, argp);
> >> + if (ret != -ENOIOCTLCMD)
> >> + return ret;
> >
> > This check seems to be incomplete. In the case when BLK_DEV_INTEGRITY is
> > disabled the ioctl can never complete as blk_get_meta_cap will then
> > always return -EOPNOTSUPP. Or should the !BLK_DEV_INTEGRITY stub be
> > changed to return -ENOIOCTLCMD instead?
>
> Ah, I did miss the stub.
>
> > It makes e.g. cryptsetup fail in my initramfs. Adding -EOPNOTSUPP to the
> > check fixes it for me:
> >
> > diff --git a/block/ioctl.c b/block/ioctl.c
> > index af2e22e5533c..7d5361fd1b7d 100644
> > --- a/block/ioctl.c
> > +++ b/block/ioctl.c
> > @@ -569,7 +569,7 @@ static int blkdev_common_ioctl(struct block_device
> > *bdev, blk_mode_t mode,
> > int ret;
> >
> > ret = blk_get_meta_cap(bdev, cmd, argp);
> > - if (ret != -ENOIOCTLCMD)
> > + if (ret != -EOPNOTSUPP && ret != -ENOIOCTLCMD)
> > return ret;
> >
> > switch (cmd) {
>
> I think returning -ENOIOCTLCMD from the stub makes more sense,
> but I don't know what the motivation for the -EOPNOTSUPP was.
>
> Arnd
Should I send a patch changing the stub? At least from reading
Documentation/driver-api/ioctl.rst it seems clear that only -ENOIOCTLCMD
or -ENOTTY is correct when the command number is unknown.
I didn't find any particular reason in 9eb22f7fedfc ("fs: add ioctl to
query metadata and protection info capabilities") for the -EOPNOTSUPP
return.
Regards,
Klara Modin
Powered by blists - more mailing lists