]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
nvme: define compat_ioctl again to unbreak 32-bit userspace.
authorNick Bowler <nbowler@draconx.ca>
Thu, 21 Jul 2022 03:57:35 +0000 (23:57 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 17 Oct 2022 09:56:46 +0000 (11:56 +0200)
BugLink: https://bugs.launchpad.net/bugs/1990162
[ Upstream commit a25d4261582cf00dad884c194d21084836663d3d ]

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>
Reviewed-by: Guixin Liu <kanie@linux.alibaba.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/nvme/host/core.c
drivers/nvme/host/multipath.c

index f7765fe631f37264afacf959f677bd5d76d509a8..b9183f67d5a7d89d0a89e4fe8bcfaf3f92b803fc 100644 (file)
@@ -2102,6 +2102,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,
index 064acad505d38c87ee8253785d694efb7261af87..04fa276701d1027c0e27b3d4ffd6356c63513ec6 100644 (file)
@@ -388,6 +388,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,