From nobody Mon Sep 29 20:14:10 2025 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 F1A49C25B0F for ; Tue, 16 Aug 2022 04:46:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232544AbiHPEpi (ORCPT ); Tue, 16 Aug 2022 00:45:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231236AbiHPEmA (ORCPT ); Tue, 16 Aug 2022 00:42:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E546C4E616; Mon, 15 Aug 2022 13:36:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7B3E1611E2; Mon, 15 Aug 2022 20:36:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FE5BC433C1; Mon, 15 Aug 2022 20:36:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595804; bh=gMMp2Qx9M5AdLKB1yiTry430Xu/koJbBtsrhkCFPWoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yJ/wmyKJgFfsfdYSSh5AU9dHR4ex78esPYaRS4vBoFqd/r1RbEIR5TJLrXyu/XM1h RIjsR6EcD8hWVkHhkRmThNxH834Ub3rxFCUipbIT5GdrhstTuJUJbGlHs2Qy/Jp/6v DbSD+iB3VHy6SaIfK8zXqyl2KW1gAp1VIYOHyMwg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nick Bowler , Guixin Liu , Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 5.19 0881/1157] nvme: define compat_ioctl again to unbreak 32-bit userspace. Date: Mon, 15 Aug 2022 20:03:57 +0200 Message-Id: <20220815180514.671731161@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Nick Bowler [ 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 Reviewed-by: Guixin Liu Signed-off-by: Christoph Hellwig Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- 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