From patchwork Thu Dec 6 12:48:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 10715959 X-Patchwork-Delegate: jgg@ziepe.ca Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BAA5D1731 for ; Thu, 6 Dec 2018 12:48:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A36362DD39 for ; Thu, 6 Dec 2018 12:48:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9337E2DD68; Thu, 6 Dec 2018 12:48:47 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY 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 39BB92DD39 for ; Thu, 6 Dec 2018 12:48:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729518AbeLFMsq (ORCPT ); Thu, 6 Dec 2018 07:48:46 -0500 Received: from aserp2130.oracle.com ([141.146.126.79]:58494 "EHLO aserp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728482AbeLFMsq (ORCPT ); Thu, 6 Dec 2018 07:48:46 -0500 Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB6Cd2xo106199; Thu, 6 Dec 2018 12:48:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=XoVpGhj1gh6heAAeGnqXSNM0mVr0YSQQ017fx2nc3FE=; b=3pUfPodtV5YXD3MsmLJ1yOiAhnV5+wFvOt0lNvwczEhOvfQZeTo9oL8YqdmrzuNp/KU+ PucFdmAblBjjp+a4unW8Henb4IlP+tBwBPzsizkDzHrx0/IcqxvKjQ61uTCNvboR7pR+ UP3AK0y0l0cInwfurkM71PXzDqVgjtX/AzvBtEZHuyt+xOk19aFz/YHs16aZQWFsvBCG CbNZz5uDdQFGfBxUZJVXqCBmbJtdsF6qyuB/OHlaNvwywZnDc2E86LSLOPFBssb2uMGa dw06IvhNILeAP1RpjKxsUB5ffo/XQs28SnVwW1eKDFiGFnPg9nfY0FnbrGa+ozpqHvXs 6Q== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2p3ftfby9x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 06 Dec 2018 12:48:39 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wB6CmchK026095 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 6 Dec 2018 12:48:38 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wB6CmbMm020180; Thu, 6 Dec 2018 12:48:37 GMT Received: from localhost.localdomain (/77.138.186.148) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 06 Dec 2018 04:48:37 -0800 From: Yuval Shaia To: dledford@redhat.com, jgg@ziepe.ca, leon@kernel.org, parav@mellanox.com, danielj@mellanox.com, markb@mellanox.com, linux-rdma@vger.kernel.org Cc: Yuval Shaia Subject: [PATCH] RDMA/core: Validate port number in query_pkey verb Date: Thu, 6 Dec 2018 14:48:18 +0200 Message-Id: <20181206124818.4298-1-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9098 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=975 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812060113 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 Before calling the driver's function let's make sure port is valid. Signed-off-by: Yuval Shaia --- drivers/infiniband/core/device.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 0027b0d79b09..348a7fb1f945 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c @@ -1042,6 +1042,9 @@ int ib_enum_all_devs(nldev_callback nldev_cb, struct sk_buff *skb, int ib_query_pkey(struct ib_device *device, u8 port_num, u16 index, u16 *pkey) { + if (!rdma_is_port_valid(device, port_num)) + return -EINVAL; + return device->query_pkey(device, port_num, index, pkey); } EXPORT_SYMBOL(ib_query_pkey);