Received: by 10.213.65.68 with SMTP id h4csp2196174imn; Sun, 8 Apr 2018 22:14:05 -0700 (PDT) X-Google-Smtp-Source: AIpwx485HQ3XNu0Tby5tSm0xvtNvTcq9UDHisbfTMmVO3Om5f1oMn29A0QgGqboYo/LpcaqHMUuD X-Received: by 10.99.104.131 with SMTP id d125mr24738771pgc.9.1523250845322; Sun, 08 Apr 2018 22:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523250845; cv=none; d=google.com; s=arc-20160816; b=Mb4zhMGsTL47f8WRg+uEZ0Xb+5GXWPC5aOVoRGYM4XPRnWv602+zv7XRSHwkxKfcyl CZSR6iaRjo9RoT2WJJ3O6fFvhegnJgW+Wt1Q2xpiSI7ZHgCLhJWuV6SBnokZq3RrXrYv //kLYUAWIIZMMzfnfhFI3DPesb1RVZjndnB6D3LtqDqV/5Q9LNy4tqdBsfdwHyxkHNRp SeIBHmEhdjS1oE7k8KMNLZtb+qjaRLXSwHQ1es4ugIcTEz0c//AhhUMvJlXRtQkv92cQ qlPbXewOXfurghx1kVEoJuiMWbFs17b8FHPyOdQdHaEufe4r1TwaucMvZUpuuhBOxvAh gW4g== 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=xCGZ7hWhf9xgTHEFdUEOsOTLixWFnr5IFoZ6A0B7acg=; b=0pgkgaZXG8wsTlfCzXcm01JMo5VB901Ni0k1pVMxUPpP68RONpiYH0mnL2SrvNZgA6 23n1/0wUkyP9Rr6618Nsvk11TdehNZSjenMdYunEfjWi6OpL0Q4lfwNFYw/VnZBZp+Ck C53PhNdwTGQQFMZOYB8Bcvr0eoLyDZh6juLMDfAha3VlOFLYBuWFpFLcPXaRoRxHd1Xm e413jy9CLx0UyeI+t42w1GNEBWzwvbfBnS/aAmYCZPaxtj4Tn2BQjv/3fNAuG0XX8R5a 2sPk8nTiNajmp1F+RPtdW+2H3DbW9WBLVB0Hel59yvE/dD5SXFmdjQgXXkspjRMPWlwJ xJNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=b2hZhJof; 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 c184si11918103pfc.367.2018.04.08.22.13.28; Sun, 08 Apr 2018 22:14:05 -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=b2hZhJof; 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 S1754051AbeDIAT2 (ORCPT + 99 others); Sun, 8 Apr 2018 20:19:28 -0400 Received: from mail-bn3nam01on0100.outbound.protection.outlook.com ([104.47.33.100]:20288 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753783AbeDIATV (ORCPT ); Sun, 8 Apr 2018 20:19:21 -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=xCGZ7hWhf9xgTHEFdUEOsOTLixWFnr5IFoZ6A0B7acg=; b=b2hZhJofS4gkFEGVIiCOkc6AsC8JZX37SL4t5PvGDkXjkLtyMM51kz01NICdUjFvjhCmGQWhmob2Q5lrZTIIL5rnC6XrbgpW/QuM9dFojeXSkppZPZgC89N0OgWpJQlxwjI42WCoNNRWLLXs8PFGObrDr+nK1DBEChWyh7IrRSw= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1063.namprd21.prod.outlook.com (52.132.128.39) 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:19:17 +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:19:17 +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.15 095/189] RDMA/uverbs: Use an unambiguous errno for method not supported Thread-Topic: [PATCH AUTOSEL for 4.15 095/189] RDMA/uverbs: Use an unambiguous errno for method not supported Thread-Index: AQHTz5g4M5EosI0cfEGDN4dxz7zPLg== Date: Mon, 9 Apr 2018 00:18:00 +0000 Message-ID: <20180409001637.162453-95-alexander.levin@microsoft.com> References: <20180409001637.162453-1-alexander.levin@microsoft.com> In-Reply-To: <20180409001637.162453-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;DM5PR2101MB1063;7:ojMJr3iRTZ/PJU3jFMvka+sK59mswSI/851JTKDPoHQb/APc8Cyy5njC2M7jEp0jG4H3t4/T6yGiR46llHcxC7ZTPmI1oBWuBF8/yJ8pbkgAzuQpdNfB7io/mkI40uCxsiz8O5Bcs7JH7lxk5GHp8mlNvLmH78hdIftlaC3KweLfIpEXp1aLCU41O2bR18wvc+aBS4El+WDgrSRcZ8ce57FFscvZ4d8pdyvv5HMzAyLY85VaGm40XgH8M/PI0OPS;20:KxJs5jigyolleyf4pur/SfLK4ARlXI7yqDKzMivDvDstlKn9qdCkbscJP2E3NuIqWwuEwUqi6hgv03eRKfYuRI5kNlWdedLy7cNpcNigmeGbqG80yv6hePPrdKvRxkVOLDF3a2K7MK2v3PJnYqS1dgfUWlkNow4a3tMskAZ/FIE= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: 0ec7b493-af18-457b-1167-08d59daf8827 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1063; x-ms-traffictypediagnostic: DM5PR2101MB1063: 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)(5005006)(8121501046)(93006095)(93001095)(3231221)(944501327)(52105095)(3002001)(10201501046)(6055026)(61426038)(61427038)(6041310)(20161123558120)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(6072148)(201708071742011);SRVR:DM5PR2101MB1063;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1063; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(39380400002)(39860400002)(376002)(396003)(366004)(189003)(199004)(2900100001)(6436002)(7736002)(10090500001)(102836004)(3660700001)(6506007)(76176011)(305945005)(4326008)(5250100002)(97736004)(26005)(25786009)(6512007)(2906002)(81166006)(106356001)(107886003)(68736007)(14454004)(86612001)(66066001)(10290500003)(59450400001)(6666003)(5660300001)(81156014)(478600001)(476003)(486006)(6486002)(72206003)(3280700002)(99286004)(105586002)(36756003)(1076002)(2616005)(11346002)(53936002)(446003)(8676002)(186003)(3846002)(54906003)(6116002)(2501003)(8936002)(316002)(110136005)(86362001)(22452003)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1063;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: OvK5rzBwfTUbyoGQvHULqgPri54gu+bEpxltnU9bisS7M7TAxZYstH2DoVgv+G70/dYzA+A/9sTHmUvRjK2vVR+5cB4XwY8lNjxoM1BG7v8IEr8bvwuKngF/gj9wF0BjSPnYXH/L/5XPwEDbAp/oHLP3nUIzAxL1xm264QCBCs5Q00KMsAhxs6rDDZBkrqBB6gW2oMsI3WUyhySSQzUQJTVH5pxIyFmMdQHfFp8hpCcBwZQ6h0yQi3DPfo/akYMpeEsoRycSQjDAij2d4BjW7/FXFfzGdik01uY8ELfTlB6gCfwcgHOWnQBM/hJDxEt71VA/1HIdwJsRNr+4Ty791wR6xlsY1tzM2qPdidwzBZdeO4dZPxlmZqxLbWuL+M/szDFtZUKHdh0FJSY9wc8nhQeDgc8hLPmnJ92JaWa+sZg= 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: 0ec7b493-af18-457b-1167-08d59daf8827 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:18:00.8194 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1063 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 71ff2644e053..d96dc1d17be1 100644 --- a/drivers/infiniband/core/uverbs_ioctl.c +++ b/drivers/infiniband/core/uverbs_ioctl.c @@ -243,16 +243,13 @@ static long ib_uverbs_cmd_verbs(struct ib_device *ib_= dev, size_t ctx_size; uintptr_t data[UVERBS_OPTIMIZE_USING_STACK_SZ / sizeof(uintptr_t)]; =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; @@ -305,6 +302,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: if (ctx !=3D (void *)data) kfree(ctx); @@ -341,7 +348,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