Linux block layer
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Klara Modin" <klarasmodin@gmail.com>, "Arnd Bergmann" <arnd@kernel.org>
Cc: "Anuj Gupta" <anuj20.g@samsung.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	"Kanchan Joshi" <joshi.k@samsung.com>,
	"Christian Brauner" <brauner@kernel.org>,
	"Christoph Hellwig" <hch@infradead.org>,
	"Naresh Kamboju" <naresh.kamboju@linaro.org>,
	"Anders Roxell" <anders.roxell@linaro.org>,
	"Jens Axboe" <axboe@kernel.dk>, "Keith Busch" <kbusch@kernel.org>,
	"Caleb Sander Mateos" <csander@purestorage.com>,
	"Pavel Begunkov" <asml.silence@gmail.com>,
	"Alexey Dobriyan" <adobriyan@gmail.com>,
	"Darrick J. Wong" <djwong@kernel.org>,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [v2] block: fix FS_IOC_GETLBMD_CAP parsing in blkdev_common_ioctl()
Date: Fri, 18 Jul 2025 07:56:49 +0200	[thread overview]
Message-ID: <b6346235-cc66-4ce0-8768-52a1a89fd699@app.fastmail.com> (raw)
In-Reply-To: <szmagqqo6lx36ozaqd5qf72xnzoi4e23jbfehjli6rfbvhps6w@if2cvmlgvmxv>

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

  reply	other threads:[~2025-07-18  5:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20250728133941eucas1p1110f4ef3da6f291256bc704a1835c866@eucas1p1.samsung.com>
2025-07-11  8:46 ` [PATCH] [v2] block: fix FS_IOC_GETLBMD_CAP parsing in blkdev_common_ioctl() Arnd Bergmann
2025-07-11  9:40   ` Anders Roxell
2025-07-11 10:04   ` Christian Brauner
2025-07-11 14:47   ` Jens Axboe
2025-07-17 23:37   ` Klara Modin
2025-07-18  5:56     ` Arnd Bergmann [this message]
2025-07-24 10:16       ` Klara Modin
2025-07-25  4:36         ` Anuj gupta
2025-07-28 13:39   ` Marek Szyprowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6346235-cc66-4ce0-8768-52a1a89fd699@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=adobriyan@gmail.com \
    --cc=anders.roxell@linaro.org \
    --cc=anuj20.g@samsung.com \
    --cc=arnd@kernel.org \
    --cc=asml.silence@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=csander@purestorage.com \
    --cc=djwong@kernel.org \
    --cc=hch@infradead.org \
    --cc=joshi.k@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=klarasmodin@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=naresh.kamboju@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox