public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
From: Guixin Liu <kanie@linux.alibaba.com>
To: Nick Bowler <nbowler@draconx.ca>,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2] nvme: Define compat_ioctl again to unbreak 32-bit userspace.
Date: Thu, 21 Jul 2022 14:34:45 +0800	[thread overview]
Message-ID: <06b571a5-4d0f-2112-c73b-35618b652a3b@linux.alibaba.com> (raw)
In-Reply-To: <20220721035735.2720-1-nbowler@draconx.ca>

LGTM,

Reviewed-by: Guixin Liu <kanie@linux.alibaba.com>

在 2022/7/21 11:57, Nick Bowler 写道:
> Commit 89b3d6e60550 ("nvme: simplify the compat ioctl handling") removed
> the initialization of compat_ioctl from the nvme block_device_operations
> structures.
>
> Presumably the expectation was that 32-bit ioctls would be directed
> through the regular handler but this is not the case: failing to assign
> .compat_ioctl actually means that the compat case is disabled entirely,
> and any attempt to submit nvme ioctls from 32-bit userspace fails
> outright with -ENOTTY.
>
> For example:
>
>    % smartctl -x /dev/nvme0n1
>    [...]
>    Read NVMe Identify Controller failed: NVME_IOCTL_ADMIN_CMD: Inappropriate ioctl for device
>
> The blkdev_compat_ptr_ioctl helper can be used to direct compat calls
> through the main ioctl handler and makes things work again.
>
> Fixes: 89b3d6e60550 ("nvme: simplify the compat ioctl handling")
> Signed-off-by: Nick Bowler <nbowler@draconx.ca>
> ---
>
> v2: use blkdev_compat_ptr_ioctl as suggested by Christoph Hellwig
>
>   drivers/nvme/host/core.c      | 1 +
>   drivers/nvme/host/multipath.c | 1 +
>   2 files changed, 2 insertions(+)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 6a12a906a11e..9c75d7378d31 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2123,6 +2123,7 @@ static int nvme_report_zones(struct gendisk *disk, sector_t sector,
>   static const struct block_device_operations nvme_bdev_ops = {
>   	.owner		= THIS_MODULE,
>   	.ioctl		= nvme_ioctl,
> +	.compat_ioctl	= blkdev_compat_ptr_ioctl,
>   	.open		= nvme_open,
>   	.release	= nvme_release,
>   	.getgeo		= nvme_getgeo,
> diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
> index d3e2440d8abb..432ea9793a84 100644
> --- a/drivers/nvme/host/multipath.c
> +++ b/drivers/nvme/host/multipath.c
> @@ -408,6 +408,7 @@ const struct block_device_operations nvme_ns_head_ops = {
>   	.open		= nvme_ns_head_open,
>   	.release	= nvme_ns_head_release,
>   	.ioctl		= nvme_ns_head_ioctl,
> +	.compat_ioctl	= blkdev_compat_ptr_ioctl,
>   	.getgeo		= nvme_getgeo,
>   	.report_zones	= nvme_ns_head_report_zones,
>   	.pr_ops		= &nvme_pr_ops,


      parent reply	other threads:[~2022-07-21  6:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21  3:57 [PATCH v2] nvme: Define compat_ioctl again to unbreak 32-bit userspace Nick Bowler
2022-07-21  5:41 ` Christoph Hellwig
2022-07-21  6:34 ` Guixin Liu [this message]

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=06b571a5-4d0f-2112-c73b-35618b652a3b@linux.alibaba.com \
    --to=kanie@linux.alibaba.com \
    --cc=hch@lst.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=nbowler@draconx.ca \
    /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