Received: by 10.192.165.148 with SMTP id m20csp527065imm; Wed, 25 Apr 2018 03:42:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/SYfHe3E8ApPThy1mmr8yHzuUZ4YIyLf6SW4P7osBzPcjhEflO/TzxraXQ/TW2tkhzvaeJ X-Received: by 2002:a17:902:5ac1:: with SMTP id g1-v6mr16294450plm.43.1524652930559; Wed, 25 Apr 2018 03:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524652930; cv=none; d=google.com; s=arc-20160816; b=SRcKuhO66w8ZqBp4HbGVvm+h5VlDME67B011qVOfjJvj6PyhAPBsjr+60CR4DtfVM2 zghYVtdsewOUt/f/Zqfzyw9Va9SN/itC5bfFye32V55AR1RrZ5AqkGKp4BT7I+iYNGyc 3l/1doDhGr4qP5HEEYy+2Omsi7DZj52XVVXQKWOFRAMSn2vWHO9D+avUaTZOnwtQ/mMw Dk+K9xa64c9+ToIWdIhNMAx9sbmBN4b4ycSpxPn3qTkjbsf05UfKzzQQXD7haSiWQZNv d0gFnjGBeGlxR+X2ls4Ku7mRxJIOptiMlcyZafkycIiZfynHPstyVjubDsHaEPS/Hv6r gpig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=GZK4zOQXWfwz9r7Frug/gLzwuan+63+jW6tfTEjMmPI=; b=LpsVy9yetUOh7SSX6dkXksD/6eNU3utRHK9Z1Ja9Jq2bVCv3/cK61xjZTBg2DX3PfW 7zL+ZlMyRnU4zSevdUB43qSPENctisir2GA8ubMlpBd4VSphM9rFYJ2kIHxlt2EvH5xR lrJWpvvYILXHS5VdTfTvu6HiBea1wUZ6jFPVQMnAxZYg633mmdtI2gzt4bCk/3l5nUNX rcERb+y5RXp0FeX362rQ8tmaFnidM+RMH/BzugWZQFGXoVR67kdJHO6ZHckis0qbmPkM WIZ1IXj2qwmGMSflZ8mUR77eG/xBzgqnGTr5E0ui0zaYo6v0nWevzpV+tmnMwRq1ik1K /lOw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q3si13370125pgs.516.2018.04.25.03.41.56; Wed, 25 Apr 2018 03:42:10 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753371AbeDYKk5 (ORCPT + 99 others); Wed, 25 Apr 2018 06:40:57 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52218 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753630AbeDYKks (ORCPT ); Wed, 25 Apr 2018 06:40:48 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C3D6D480; Wed, 25 Apr 2018 10:40:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jason Gunthorpe , Matan Barak , Doug Ledford , Sasha Levin Subject: [PATCH 4.14 091/183] RDMA/uverbs: Use an unambiguous errno for method not supported Date: Wed, 25 Apr 2018 12:35:11 +0200 Message-Id: <20180425103246.143393149@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/core/uverbs_ioctl.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) --- 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 i uintptr_t data[UVERBS_OPTIMIZE_USING_STACK_SZ / sizeof(uintptr_t)]; #endif - 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; @@ -310,6 +307,16 @@ static long ib_uverbs_cmd_verbs(struct i 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: #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, } if (hdr.reserved) { - err = -EOPNOTSUPP; + err = -EPROTONOSUPPORT; goto out; }