From patchwork Thu Jan 25 02:58:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10183517 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74CB760383 for ; Thu, 25 Jan 2018 02:58:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 637FE289CA for ; Thu, 25 Jan 2018 02:58:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5744E28A18; Thu, 25 Jan 2018 02:58:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 709C8289CA for ; Thu, 25 Jan 2018 02:58:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752746AbeAYC64 (ORCPT ); Wed, 24 Jan 2018 21:58:56 -0500 Received: from mail-he1eur01on0046.outbound.protection.outlook.com ([104.47.0.46]:25641 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751762AbeAYC6z (ORCPT ); Wed, 24 Jan 2018 21:58:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=FkM612IzlqX8Z6hZDlQuNritMxh39R63Yy61WpWbOeM=; b=bZ3CPbSBZ70SUGKYdBCzJ+tsRXwDQGMcfII/IwegFO7Wn9hQiV3p195z/FZ9PilPl+siTl8PtYAFkUQ6Uwvo5NKYhBu7x0SkKNQgiASVewvkrz5OhzIz8pJT82VcO0wa7ImRkBRm4oRmiTZ1o2RDfU/cCeScOfBKi2eSw+SOtFE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=jgg@mellanox.com; Received: from mlx.ziepe.ca (70.74.179.152) by VI1PR0501MB2862.eurprd05.prod.outlook.com (2603:10a6:800:9b::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.428.17; Thu, 25 Jan 2018 02:58:51 +0000 Received: from jgg by mlx.ziepe.ca with local (Exim 4.86_2) (envelope-from ) id 1eeXkI-0006jS-Pn; Wed, 24 Jan 2018 19:58:34 -0700 Date: Wed, 24 Jan 2018 19:58:34 -0700 From: Jason Gunthorpe To: linux-rdma@vger.kernel.org Cc: Matan Barak Subject: [PATCH] RDMA/uverbs: Use an unambiguous errno for method not supported Message-ID: <20180125025834.GA25674@ziepe.ca> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-Originating-IP: [70.74.179.152] X-ClientProxiedBy: MWHPR06CA0014.namprd06.prod.outlook.com (2603:10b6:301:39::27) To VI1PR0501MB2862.eurprd05.prod.outlook.com (2603:10a6:800:9b::7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: bf202b0c-64dc-4426-8e99-08d5639f9066 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(2017052603307)(7153060)(7193020); SRVR:VI1PR0501MB2862; X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2862; 3:ekfuDgdx2Cd1lOLJdmbgOJH17iUl8Yj4rhl8Bwq4hA8H7WCMJg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FF1Z3OAjzomr8rVCk2Z2c9OezSz5Wz57IoxMNePK90uwOuQAXigJwnUQxjp4xfVvAnoTjzdW5smr+nG1cgIibstzW3NLZRHHTiuFFD0GHaoG6f0copU/qqiV+BuH2Gy0ubX93D9/NY5xTzew7sW54XGIyN0tuIqI7GxJZomzGWaulFxxk9xiJSxWfe5g4tjv50dqHmR86YGoPsFrlEZ3fuQdk4IQYeTe/PTPr0Y2Qv/bRW47E1TbfPPTwXj02UKc92QWy45wCPih6PdMHd1QzZ9vUTPIi0DeNe8y4Otr6g4ti63BxlEuyR; 4:jIwpi7riE0QWN0gCapk9yfUA6y3/gxUFHp33BsrM06MgCLj1nE1VYiqroY7YFQMWOoM/tWMdqnQI4Dgnu9i3rAsh3X5f0bGZn40X3hu32AQ9+2b3gNcM/L9GtUj8CqZ2Zyq5Uj2A0zYJANiYgitxsFgnrug6Oo1uxf1rUWa4Uh6moLplInJwG9o/Cxruf4L2H5oeQYc6xmoNrtnRJaSNVyaUSyv8AQQQPriZ5qHeQgh39BEBeDF8elV+3iB0BRQsH+OUS8O2xWFftGKgmMSXdAW/LlMaXeKaqWcDckqsYev4lW4mUBzQsTpMX/EdZMcG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(166708455590820); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040501)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(3231023)(2400081)(944501161)(10201501046)(6055026)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(6072148)(201708071742011); SRVR:VI1PR0501MB2862; BCL:0; PCL:0; RULEID:; SRVR:VI1PR0501MB2862; X-Forefront-PRVS: 0563F2E8B7 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(39380400002)(39860400002)(366004)(396003)(199004)(189003)(69596002)(6916009)(50466002)(107886003)(4326008)(66066001)(46656002)(2906002)(5660300001)(36756003)(9686003)(478600001)(966005)(1076002)(6306002)(6116002)(3846002)(23726003)(83506002)(47776003)(97736004)(316002)(33656002)(16586007)(53936002)(58126008)(33896004)(186003)(9746002)(9786002)(8936002)(105586002)(106356001)(83796002)(57986006)(52116002)(386003)(122856001)(8676002)(2351001)(7736002)(305945005)(81166006)(81156014)(68736007)(59450400001)(26005)(86362001)(2361001)(18370500001)(24400500001)(42262002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR0501MB2862; H:mlx.ziepe.ca; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR0501MB2862; 23:5LeN0EkAI/31SLaygR5Gojo4mhkkJqgLGAip/Rv?= =?us-ascii?Q?wiWqyuWYV/C99SP3ZtcBIOyAt87mMdmiaGFtoYY3RctaW+VIN8fbmnoLpHRo?= =?us-ascii?Q?LM4bw5dkUD9uYTUQ8lL2lpcyCzoiFj5efR6YFCs4rT+fKXBcd0z22QyxNKjO?= =?us-ascii?Q?qcEbk3mcKIXVeS31kBTh5bW/v4l5CsE+uV8aG4H2x+sl90RpyTHREI3bf4Ss?= =?us-ascii?Q?GYpqXkDN56N7UmHOml1mwHkg2OAi9KnT4KyWk5C37rHZJ2leQ/1ZOEB+KPI1?= =?us-ascii?Q?YibTCljl6TGadS6duRVRHPu08ET2X6Vi0wCPLUjxDad3t9zbNTnxjgbEccs8?= =?us-ascii?Q?Iz3sJcLaAsk12sVE/pdbiEsB8ofiRcYlJSFoiJm7JGZhykGnp9u3rSu912kl?= =?us-ascii?Q?8v9ezdbEjF8dOdTYA+VhSdfLb99q+YW5TEOgPSNLbwQwLp6cse6pVisBzN4P?= =?us-ascii?Q?v4R/9y92BW0Y4xWjwy3WWQKSqXkcszmcvWk82Lz38tl4rqybrgw3lKhkHMwj?= =?us-ascii?Q?kJQALFokVKtI5jkFB8gJW1fcyY3tF80CQTG9rDbIeiKRvMXOCl8d4jlguJdG?= =?us-ascii?Q?88bmJi2QnIXep8wKMO3Xi9INbcnpQD75KzdDU3HQjilxLrbbdJkoG75PoJVU?= =?us-ascii?Q?7Yi7f/9gq7ErLNyh7ycEREUlVi+VAKZzZT50187ZobVj1+9Epph2HLIH+pxY?= =?us-ascii?Q?VYlwFbYGuvZdV87nMx7TydQk9zPYuE91OLMtkYAN1cI4iyeHgb+IpjVgUN6g?= =?us-ascii?Q?N4BxlWidigIyLr7aILpKfrWSR2Bzmblj9S1/bdkPBGHDcrC2c01KJxiSFlxq?= =?us-ascii?Q?XxVEwvdsHVuHfoQwYShnhoMAXAI+jJdKaeShYOMHSvYtQTA0bcFb58ejOAXz?= =?us-ascii?Q?y+qp+HKnwmDXKaRVepZqDDHHIOAnCt/xVp1fuigyXBAbvNaILiotHF66Gjnw?= =?us-ascii?Q?wXxeUrR8llUPg37gWkB0nHJGTpt+DGh1Ikg4U3Ho80iHw5VSAT34Bfsy3F3g?= =?us-ascii?Q?hRU+DbWmk3zLl0WfSL5yaTvW5SgFldkhBkzhhm7kClq23oqz0VXprBe1MJt+?= =?us-ascii?Q?7L7H0jMYhaExN/Xx3hRDS/bPJNpAB7MGU0ox7+R8fwLJ9r3JfJyORKgMpUM5?= =?us-ascii?Q?uPKqF3hwxrjoJoMKLp49MZcqufSS77vblOultyHzGsUgmREeYiqTcwteLbb3?= =?us-ascii?Q?IuAN+RYLUcEvWAE0S+ONnVvWNvBUz4aE1olOutmFw/8J03xDjyp0PrmYqDFZ?= =?us-ascii?Q?r4I539nZymXAuBuHe0Je0/4zUy7jUxtLchMqdpGRGrHCyIBKNUoHHV/upTxQ?= =?us-ascii?Q?ChrJX1NQiIDtbyf4Ru1WbhKz/oih/6FxDG6Uo46/hmmk9vonQ2XcVEjzOMj5?= =?us-ascii?Q?ytGwHTA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; VI1PR0501MB2862; 6:QEYf9jjFOfZSQBGegyg36SJRL0LomPfeZUuRkGW5H5RS2eV24HQ7JGasRVfs0kg7zIxJUSX040xl3n9JfDb+8s/R7xkzXpVVqy3AnQjAkIluwZdBVHlNaC4GBrIrmpoy02QOS6UtVmzPEKJthaAIoqPeobIBO2u9ZTplTsI3rz2Ij3Cc4p0HDRyvy3klUQmpm4jnv4mrmgDqhKGadtiAwc23m09XRHikiyxWKpBRGuU8lNTreHcBSRQ14lCJgvRx+68KmyIvjWksIqpLB+pOwdsaPi3tX2PCbw3VifHnXc+AjFLsSWWMuQJjsPkQciC8sTUOfssmgUR1TckC2lZGaPS98sQmucXigN9esfu/f0Q=; 5:19fEImWH+DcCQqEkyOkoI36rqN/C5cqDLEN/1rJlgWdyMXPzqD2adFF/RRthZdxm8twmfsnnJIeSVT5kvaw1er9cd4bUUv0Ks9JbQua6D9Xl828+8nNEedNXr8w3imkdJkRzBI3HZJJxfIdKm2IatKSy4M5qIUVBBzd3cpWLaR8=; 24:u9MHiGmCEXI+6hWJVTQdd9RZeyqATV629Obrq770opxvo/lFvbBnOrCDZ0SfmoRfznsOB9rVx8IsCOWzSGEQkQUQ4t4db3ITHEP5nbbpwgI=; 7:HYwKsGII22Gi6F4V3WqgxiGWoyIsrcYkVkLgu0xR1a3V/ENktzwb/9EqPMGxLeRIaLVmRJQiiH8aDDaxupDHDxiePO07yaa/7xWxFGgq4ySgAhg7ZmdgTkFGPKi7G3X+ll8O2P6rh1q/FLfjW9PrywCqZmdJioWZxBVJVEa5mnuSoZFg0RXi6UTZhBsL723VzSmIKpZ2fUPSGih6Cx6l8sJFUEsJ+mTYf0GBLM7Fx/tqMAbHpAFJ0MK80ZJzjc4M SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jan 2018 02:58:51.4352 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf202b0c-64dc-4426-8e99-08d5639f9066 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0501MB2862 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/infiniband/core/uverbs_ioctl.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) This goes along with the series I am cooking to enable the new ioctl interface in rdma-core: https://github.com/jgunthorpe/rdma-plumbing/tree/ioctl diff --git a/drivers/infiniband/core/uverbs_ioctl.c b/drivers/infiniband/core/uverbs_ioctl.c index 71ff2644e053b8..d96dc1d17be189 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)]; - if (hdr->reserved) - return -EINVAL; - object_spec = uverbs_get_object(ib_dev, hdr->object_id); if (!object_spec) - return -EOPNOTSUPP; + return -EPROTONOSUPPORT; method_spec = uverbs_get_method(object_spec, hdr->method_id); if (!method_spec) - return -EOPNOTSUPP; + return -EPROTONOSUPPORT; if ((method_spec->flags & UVERBS_ACTION_FLAG_CREATE_ROOT) ^ !file->ucontext) return -EINVAL; @@ -305,6 +302,16 @@ static long ib_uverbs_cmd_verbs(struct ib_device *ib_dev, err = 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 == -EPROTONOSUPPORT)) { + WARN_ON_ONCE(err == -EPROTONOSUPPORT); + err = -EINVAL; + } out: if (ctx != (void *)data) kfree(ctx); @@ -341,7 +348,7 @@ long ib_uverbs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) } if (hdr.reserved) { - err = -EOPNOTSUPP; + err = -EPROTONOSUPPORT; goto out; }