Received: by 10.213.65.68 with SMTP id h4csp2112191imn; Sun, 8 Apr 2018 20:01:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+Q1/E6I0eAmGUcWfvTFW5Ewmk2NjhEqHF7Zrh+VOIajpWDOuV362h71P8k0uinsiRfRaXB X-Received: by 10.98.194.133 with SMTP id w5mr27866374pfk.6.1523242909131; Sun, 08 Apr 2018 20:01:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523242909; cv=none; d=google.com; s=arc-20160816; b=Rg2ei7/r6LhAd7zH5PS3O6/Tz8is6ouAaI6S06kN9Mhy7il27QsvTi+ajOQJV10zbQ SOwBGuSbpbW3FKe5qlSwzo61iz3zlp4RN1cjyI4rTRLogys/ZEWXxEIkCvcz00u+bI2t 4xy09NdVtWk0Bb3qcyhjm2GEuCOYWJqKV/K5FxfFVITh03dBRwnx/tkFz9LE67CQSx/+ Gf/NG2Z8u0fq7As+cx/rkdMiB3OoJEzWXpPYE2RmDjdtE/UVAYD/yMAZbg/XNGRt8/j/ xjeocc9rQTEhISbPv7T7xnPHa11aCvGc0g5lMGl4oXI58fUaBuzOl1tUV5uMkyZ4+LDi MTWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=wdi6JISMER2Rn9T8bFBnB22DCorCFODGSDbVO66t6No=; b=os9PxFMknGvKoqsv9zSJRHne67SHqp/4roArGCQaHlJE9WubAVOOVz/ZFmO6Dgacog J7M11pOPinr0S04yVQzkZ5jyJZnp2CEdUmE+EtGXch1hdp0fFCGNA5oM8PIqAmrBgS1F JT7mCDj+vL9oA4U/QWtA5FO50d43sskPJTnRXht62BqSLJPe4imNgKUiiixxGYp/ijNE oBH9gn7tc4zpXOyROfiownLlzq9zGerdKYOw0GmKz3yEvKSQS+Cg9x64lI7REt3PQZKV GGs7KgFdvdcI3w8/3nNOGQVXMMgMfFkBn2VEcsc89s7LqhDtidpCDYL52BjeJgblpCnD 7eUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=PAVjShD8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 142si10492478pgg.29.2018.04.08.20.01.12; Sun, 08 Apr 2018 20:01:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=PAVjShD8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754996AbeDIAYA (ORCPT + 99 others); Sun, 8 Apr 2018 20:24:00 -0400 Received: from mail-dm3nam03on0092.outbound.protection.outlook.com ([104.47.41.92]:13920 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754978AbeDIAX4 (ORCPT ); Sun, 8 Apr 2018 20:23:56 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=wdi6JISMER2Rn9T8bFBnB22DCorCFODGSDbVO66t6No=; b=PAVjShD8292P17R7TlbY5Ifw5vdY3NZ8Qi7StnPeZjdzPmFg2Hgw2jDSYPYwm3QW9b7vrwPNWqqYCdWu1hsGUIkBWq8IG4lYmt1xdmUc7JFg44rQeuWm5bTa8ez0lQd3LgrS6IgOlZeoM8133+zgrASHXzygGoUCunrReGQO+CI= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0984.namprd21.prod.outlook.com (52.132.133.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:23:54 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:23:54 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Jason Gunthorpe , Doug Ledford , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 079/161] RDMA/uverbs: Use an unambiguous errno for method not supported Thread-Topic: [PATCH AUTOSEL for 4.14 079/161] RDMA/uverbs: Use an unambiguous errno for method not supported Thread-Index: AQHTz5idUWZSG5sKN0C9+MWKE+c7dQ== Date: Mon, 9 Apr 2018 00:20:51 +0000 Message-ID: <20180409001936.162706-79-alexander.levin@microsoft.com> References: <20180409001936.162706-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001936.162706-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0984;7:qciBhHyhmkI5VqG7FXxkFV6mhzUAOP6YNtLAHYZptwxzPkZWQ3wRscBHxxmN4RnlobSgwEWWxJFjeoHTPIK/+d4R2Rh4gZHUhrUA+yjajp/yAKWdvrS+D0KbaJ4NmKxa2WMEA5LIeg3Fg9+dsz7oPS7cAkyJEVFGRbHr9XpxFp0b7RIWo+CEmYktGGgJtson1tXM7o3x9EPWm81HNY4OnEGgR0Uyg80rRmtAeT5AcaAHGskq3x8HFXkGLvc2WBew;20:ceuLXnrI6D0f86NlcSB3LOYuO2uiy50rMsMn1/HkUcI/WNYKzdpiH0UOgr7eu57XBly7le6OHR50wXQlTwX1OMeJ7WtzanCjCW9rixy6cRARJZ9e+t3WC51yA5wXgjVOKqtvWKRCulywgxfn+yipRvA8A0JdL1pEZr7N3ARBisk= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 7274ba0b-26d7-430d-e441-08d59db02d27 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB0984; x-ms-traffictypediagnostic: DM5PR2101MB0984: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011);SRVR:DM5PR2101MB0984;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0984; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(376002)(366004)(39860400002)(396003)(189003)(199004)(5250100002)(2501003)(110136005)(54906003)(6116002)(6436002)(11346002)(1076002)(486006)(25786009)(105586002)(2900100001)(102836004)(86612001)(3846002)(68736007)(107886003)(316002)(10290500003)(5660300001)(86362001)(2616005)(305945005)(4326008)(446003)(6486002)(22452003)(7736002)(476003)(8676002)(81156014)(81166006)(8936002)(6512007)(10090500001)(186003)(3280700002)(106356001)(76176011)(2906002)(99286004)(26005)(97736004)(59450400001)(14454004)(6666003)(478600001)(53936002)(6506007)(36756003)(72206003)(66066001)(3660700001)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0984;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: Gs9dQ5UvTIZsgqekDrJbZQU/wudH0f5IN0sdxv5PXSCd9uDcjAO68BEbsYxoSMNn2JcGDrOTWESAxjwBAECm37xo2HNEZXVMrUBdPfw5uF1WjQiDAavtiiUU1IEWL5yRkJ9rUYn41jy/snbc3/He8V1pX+PYJy6/+q5YTHGVTp2B9tJBjjCZb/ZdSCL1XdO/Pny5tbD8FOQ/MFZVNnzf1/ufMnToY5sWJxaKmO4FBtDIJE8gvVGWx9rOj/Ha76LWvNOBj6SgTbu3PLGoTJMmXyG03ijCua/ZHqGa4x90BVTIftrpLiEa9ZyoKllgmkqj1rOYNBXrVI7//52NOKqmGoevk8Vht9Yj7LeIlprzttOtPiFWfN+SMPXfUsTvczcA3ae6g0kUz2gch9W2SALXW1FRbkdo2KTgefUCLPhtZqM= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7274ba0b-26d7-430d-e441-08d59db02d27 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:20:51.0190 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0984 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jason Gunthorpe [ Upstream commit 3624a8f02568f08aef299d3b117f2226f621177d ] Returning EOPNOTSUPP is problematic because it can also be returned by the method function, and we use it in quite a few places in drivers these days. Instead, dedicate EPROTONOSUPPORT to indicate that the ioctl framework is enabled but the requested object and method are not supported by the kernel. No other case will return this code, and it lets userspace know to fall back to write(). grep says we do not use it today in drivers/infiniband subsystem. Signed-off-by: Jason Gunthorpe Reviewed-by: Matan Barak Signed-off-by: Doug Ledford Signed-off-by: Sasha Levin --- drivers/infiniband/core/uverbs_ioctl.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/infiniband/core/uverbs_ioctl.c b/drivers/infiniband/co= re/uverbs_ioctl.c index 5286ad57d903..8f2dc79ad4ec 100644 --- a/drivers/infiniband/core/uverbs_ioctl.c +++ b/drivers/infiniband/core/uverbs_ioctl.c @@ -245,16 +245,13 @@ static long ib_uverbs_cmd_verbs(struct ib_device *ib_= dev, uintptr_t data[UVERBS_OPTIMIZE_USING_STACK_SZ / sizeof(uintptr_t)]; #endif =20 - if (hdr->reserved) - return -EINVAL; - object_spec =3D uverbs_get_object(ib_dev, hdr->object_id); if (!object_spec) - return -EOPNOTSUPP; + return -EPROTONOSUPPORT; =20 method_spec =3D uverbs_get_method(object_spec, hdr->method_id); if (!method_spec) - return -EOPNOTSUPP; + return -EPROTONOSUPPORT; =20 if ((method_spec->flags & UVERBS_ACTION_FLAG_CREATE_ROOT) ^ !file->uconte= xt) return -EINVAL; @@ -310,6 +307,16 @@ static long ib_uverbs_cmd_verbs(struct ib_device *ib_d= ev, =20 err =3D uverbs_handle_method(buf, ctx->uattrs, hdr->num_attrs, ib_dev, file, method_spec, ctx->uverbs_attr_bundle); + + /* + * EPROTONOSUPPORT is ONLY to be returned if the ioctl framework can + * not invoke the method because the request is not supported. No + * other cases should return this code. + */ + if (unlikely(err =3D=3D -EPROTONOSUPPORT)) { + WARN_ON_ONCE(err =3D=3D -EPROTONOSUPPORT); + err =3D -EINVAL; + } out: #ifdef UVERBS_OPTIMIZE_USING_STACK_SZ if (ctx_size > UVERBS_OPTIMIZE_USING_STACK_SZ) @@ -348,7 +355,7 @@ long ib_uverbs_ioctl(struct file *filp, unsigned int cm= d, unsigned long arg) } =20 if (hdr.reserved) { - err =3D -EOPNOTSUPP; + err =3D -EPROTONOSUPPORT; goto out; } =20 --=20 2.15.1