Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp279744imi; Wed, 20 Jul 2022 23:59:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sgGVC3f3ZZQkI/btpQn41K3I38uXA9U4hxv9/zWs0mwdfUxPjEoUaq4K9upGQFqOmNLSO/ X-Received: by 2002:a17:90a:e58a:b0:1e2:fe75:dd5f with SMTP id g10-20020a17090ae58a00b001e2fe75dd5fmr9978769pjz.138.1658386741344; Wed, 20 Jul 2022 23:59:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658386741; cv=none; d=google.com; s=arc-20160816; b=d2UFulqCQdNIaf3jkK5MEAL8SVr19dt+CufERoqkdXZ4VjUsn7/6TIsl7gLYhvhxgb PUpBT68F/3IDdHiuHJ9yBgkdq+pP8c+FRY3p86mXjnbtkU6Vib/CSvbVaORrTAB3xlQN Zx3uS+jPFmMhRHOdJuwRzEJzIRnUvr33dZDomPAWR/OzfmuHoBCTC311AhyiypckyqBG EyDnws4VqJEx84YNXqV24pDT3itpwV8PZppc76t7Z9N50bDHq2Y18W8pFOMFWSBShWzY +m3Ybt+uaUVPVtFQEzbR8ZQ0wUV0O+6I+15ckfei3maJmEUnvpg2YFq37PZQ+lNeBKLK Pbmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=KAO2VPWSy+kFCQCIJkRvwztHjMzhz7EfdSG4Fv/zirA=; b=BqsZHkkpi70taqnF73tOchWI44KILMxqzwf615RWJ/w34ztBj3AsiF6jj0ErviQL0B FGTzH8LCaOP9pX/IacAfAACN778fLKwv3cJnESsh7rkNCUSKwRL2/2mvvCPC6YRcAxUI TJhzTizXTS1AoeEsS6L9FN8BOIt+EdEsa9EPPr/kr7qR4sERhNOkUbWIKofm3YbZh7Hk iNm3j7q/6iBOmY6oCImsi5BpA8OcOns3hoP7ry9n75HEFHXkj7WuWJVMZQzyt0duH5be 2/nCnw94M8CzeFTl5vGc/te337c/O/xKn9IjbaFwuoRWA7qzg36xJ3XsyG9LrAOfQp3T QldQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z7-20020aa78887000000b00528a45a239fsi1927643pfe.273.2022.07.20.23.58.46; Wed, 20 Jul 2022 23:59:01 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230336AbiGUGey (ORCPT + 99 others); Thu, 21 Jul 2022 02:34:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229653AbiGUGew (ORCPT ); Thu, 21 Jul 2022 02:34:52 -0400 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CC485245F for ; Wed, 20 Jul 2022 23:34:50 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046049;MF=kanie@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0VK-QiEr_1658385285; Received: from 30.178.82.178(mailfrom:kanie@linux.alibaba.com fp:SMTPD_---0VK-QiEr_1658385285) by smtp.aliyun-inc.com; Thu, 21 Jul 2022 14:34:46 +0800 Message-ID: <06b571a5-4d0f-2112-c73b-35618b652a3b@linux.alibaba.com> Date: Thu, 21 Jul 2022 14:34:45 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [PATCH v2] nvme: Define compat_ioctl again to unbreak 32-bit userspace. To: Nick Bowler , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Christoph Hellwig References: <20220721035735.2720-1-nbowler@draconx.ca> From: Guixin Liu In-Reply-To: <20220721035735.2720-1-nbowler@draconx.ca> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 LGTM, Reviewed-by: Guixin Liu 在 2022/7/21 11:57, 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 > > 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,