From nobody Fri Apr 17 22:31:14 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19F03C43334 for ; Thu, 21 Jul 2022 03:58:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231435AbiGUD57 (ORCPT ); Wed, 20 Jul 2022 23:57:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbiGUD55 (ORCPT ); Wed, 20 Jul 2022 23:57:57 -0400 Received: from mta02.start.ca (mta02.start.ca [162.250.196.96]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33733785AB for ; Wed, 20 Jul 2022 20:57:56 -0700 (PDT) Received: from mta02.start.ca (localhost [127.0.0.1]) by mta02.start.ca (Postfix) with ESMTP id 51210414D0; Wed, 20 Jul 2022 23:57:55 -0400 (EDT) Received: from localhost (dhcp-24-53-241-20.cable.user.start.ca [24.53.241.20]) by mta02.start.ca (Postfix) with ESMTPS id DD33C412D6; Wed, 20 Jul 2022 23:57:54 -0400 (EDT) From: Nick Bowler To: linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig , Guixin Liu Subject: [PATCH v2] nvme: Define compat_ioctl again to unbreak 32-bit userspace. Date: Wed, 20 Jul 2022 23:57:35 -0400 Message-Id: <20220721035735.2720-1-nbowler@draconx.ca> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: ClamAV using ClamSMTP Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Guixin Liu --- 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, se= ctor_t sector, static const struct block_device_operations nvme_bdev_ops =3D { .owner =3D THIS_MODULE, .ioctl =3D nvme_ioctl, + .compat_ioctl =3D blkdev_compat_ptr_ioctl, .open =3D nvme_open, .release =3D nvme_release, .getgeo =3D 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 = =3D { .open =3D nvme_ns_head_open, .release =3D nvme_ns_head_release, .ioctl =3D nvme_ns_head_ioctl, + .compat_ioctl =3D blkdev_compat_ptr_ioctl, .getgeo =3D nvme_getgeo, .report_zones =3D nvme_ns_head_report_zones, .pr_ops =3D &nvme_pr_ops, --=20 2.35.1