Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp208443imi; Wed, 20 Jul 2022 21:39:36 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sLjRSld7lGzi1nQFWXXl8aqWi3DHVsn/Mn0H3ag+eeVhd2vCREYH4F1FpnVTfk0DHMspS2 X-Received: by 2002:a05:6402:4255:b0:43a:c03f:1aa4 with SMTP id g21-20020a056402425500b0043ac03f1aa4mr56297188edb.146.1658378376252; Wed, 20 Jul 2022 21:39:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658378376; cv=none; d=google.com; s=arc-20160816; b=Td3KjoTz+w+K6YBTev7ERcHp3iRGVLt8WmOyjMAdZfMdySAx04GwvsGp1o/XaUTwXO 7APDVbGBaGjxk5tNjkxw9BlUs1LhZjH/oAhgriqauYfNb3n/A6bDAILBMuC39AZOT2QI QfQLrNTv8B33U39+GCJN+kEcLpc9QKKXadVXAZZVMAc6dI8/zwEjovRPUEZ3LZ6t6PgO eQCAt3EOGtbNwXSFmF0Zs9gay39U9EMH8f78uoe+WQpYc6NRZNorZTPCf/kRAD3Q5A3x 6YU9OAK5pmAWol+KcGrmsS9EqAKVNVbfpSeoyF8gr22xi/DCMG9ALRERVLe50WSHZXQt 6m0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=XD7V9B+TbiGwRl4+2JiG8hf2lwXurCsdXxEwkGLkJBc=; b=amRCQyzoZgtGs/TszMiPL+7ry/PVgUX7/KOjSCqgawJ5ACWSIxz+QV81AnJsLDRF7/ umcY92lBOcFl8M4RHKSaAAA3ZxpBZwJ2hp7bNggNUKyRLlVKAe3qbrQlDDIK9PP46ACv UJy0ZrMsr2EfUZrTlmQtRfUW4LWBucLiv1cQBPftcLaZqRuOfOFvMCteNKxZ8d7ZKEWR fhez7wzWZJjoIUq6Ss3kd+bX2VFZ0Jt2x1VO9BjvnV/ZBWHoRPh87CbXBR8YRzICAagU zUr2PEGk79+q9eD0LHycJLBZC+SAQpglHmJoGf6V2Jj1uek62q2EcimrGL9/TaJzcx0i gelA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bd23-20020a056402207700b00437dce124fesi1024205edb.519.2022.07.20.21.39.11; Wed, 20 Jul 2022 21:39:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230332AbiGUD57 (ORCPT + 99 others); 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: 8bit X-Virus-Scanned: ClamAV using ClamSMTP X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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, -- 2.35.1