lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACzX3AsRd__fXb9=CJPTTJC494SDnYAtYrN2=+bZgMCvM6UQDg@mail.gmail.com>
Date: Fri, 25 Jul 2025 10:06:55 +0530
From: Anuj gupta <anuj1072538@...il.com>
To: Klara Modin <klarasmodin@...il.com>
Cc: Arnd Bergmann <arnd@...db.de>, 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 Thu, Jul 24, 2025 at 3:46 PM Klara Modin <klarasmodin@...il.com> wrote:
>
> 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.

Hi Klara,

Thanks for pointing this out — I had originally used -EOPNOTSUPP
because the ioctl command is recognized, but the operation isn’t
supported when CONFIG_BLK_DEV_INTEGRITY=n.
That said, I agree that returning -ENOIOCTLCMD from the stub might be
more appropriate in this context.

Thanks,
Anuj

>
> Regards,
> Klara Modin
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ