lkml.org 
[lkml]   [2022]   [Jul]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] nvme: Define compat_ioctl again to unbreak 32-bit userspace.
From
Hi Nick,

Should this in the brace of "#ifdef CONFIG_COMPAT" and "#endif"?

best regards,

Guixin Liu

在 2022/7/20 09:55, 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
>
> Direct .compat_ioctl to the main ioctl handlers in order to make things
> work again.
>
> Fixes: 89b3d6e60550 ("nvme: simplify the compat ioctl handling")
> Signed-off-by: Nick Bowler <nbowler@draconx.ca>
> ---
> 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 a2862a56fadc..30e105dbc178 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2093,6 +2093,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 = nvme_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 d464fdf978fb..0f38a5feec22 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 = nvme_ns_head_ioctl,
> .getgeo = nvme_getgeo,
> .report_zones = nvme_ns_head_report_zones,
> .pr_ops = &nvme_pr_ops,

\
 
 \ /
  Last update: 2022-07-20 05:51    [W:0.063 / U:0.160 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site