Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3635447pxb; Mon, 24 Jan 2022 14:04:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwXx5KhVkFuSmH6RSkFEHaDp7TPndSifFKljMyg06PZjKXg1tvIitTb4D/78WRHew9fiNof X-Received: by 2002:a17:902:7681:b0:14b:7484:9d72 with SMTP id m1-20020a170902768100b0014b74849d72mr406174pll.99.1643061859953; Mon, 24 Jan 2022 14:04:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061859; cv=none; d=google.com; s=arc-20160816; b=w7jAt0oM+s5NOlVSZSMurwv0S3NIsFU7wf0jhVCb7tPL3s2niH+/dw94arXWS3C7W3 z3YpasB9dLLeIP9ljhIQYpt11C1mjzZcryFTPDtGvFoWbzPU8jpmDFoJlkf2hb+Es0m/ 7YHIpFSxPWHFOmjOeyBplZSGS3a9PcZVonCtoHXpfzyWfmLuVgcnj/PZhOHWntoG6QFK cu1C9kGnZeXX3Qt+a/rw16T8bJeFxhH4GKtOkLSb2DkVlV2IGa+qazk4HELiQ1TdVpzf 9t95etSPuVyMQUGSITYa7UfpX/SOqWPaYl5OfY62SPqjTiWPEcWkUemcAyJ+qXf+s7Xn PxMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ciRhlQA9Vi75bF43Psa66ehRlqU5YCb7xIJ+5xoXatY=; b=oOWk54SrI0yd83fuxP4bJbVGpqBKEjAWypQWrLz/mHqkqISEP2/pPtrajZgp2v0/CE Yj9iju63uUHtwpEsnRYTaIBNdLNEsuwc2AD5CMBcDY/Q5w+CnZ8tEhGAFMXsdjGeVTis K2Y2xtJS7xxcmQ6Dx8z+4q3dNTjFHj9VO81DBbp6ghgkDsUyxZO46AV5MIXot1JcGWb1 Di+O8IXj5YUEOSMrYKtq71wo+GE3SeFwVHLyQYqNpmJaU2oRcQyK5bwi5UMQnn2Yw0Ji +t1hCgWyGV8vAJQupPDpnGO3wBNcG/Sle6ybeNMNPWzl5BueMoPyc0cgNzn0piUNBA/y 9kFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zi39S5m2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si16255539plg.444.2022.01.24.14.03.54; Mon, 24 Jan 2022 14:04:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Zi39S5m2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1575101AbiAXVvC (ORCPT + 99 others); Mon, 24 Jan 2022 16:51:02 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:38556 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1449430AbiAXVPe (ORCPT ); Mon, 24 Jan 2022 16:15:34 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9B57A61425; Mon, 24 Jan 2022 21:15:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 620D0C340E4; Mon, 24 Jan 2022 21:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058933; bh=LQqVUSu1kkMBojTaP0fomJ/poZ8XZ9pus7ucI9OB5X4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zi39S5m2cQmLfiRRHAxn3iAVwFaiJIXnRxHWwF3Lm9e/7qo+ukzNm1ExSGKt7DidL wqet9t1JQutt6osp3f9rw7biwthZa7MzlSUkxtKKPnGGhJwIhJR7I0K2roFjffIHzQ mr40cHgqg8UP7k6184Fu5CzywMGc3aRCz6Av0qCE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamal Heib , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.16 0450/1039] RDMA/hns: Validate the pkey index Date: Mon, 24 Jan 2022 19:37:19 +0100 Message-Id: <20220124184140.421187760@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kamal Heib [ Upstream commit 2a67fcfa0db6b4075515bd23497750849b88850f ] Before query pkey, make sure that the queried index is valid. Fixes: 9a4435375cd1 ("IB/hns: Add driver files for hns RoCE driver") Link: https://lore.kernel.org/r/20211117145954.123893-1-kamalheib1@gmail.com Signed-off-by: Kamal Heib Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/hns/hns_roce_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c index 4194b626f3c65..8233bec053ee3 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -270,6 +270,9 @@ static enum rdma_link_layer hns_roce_get_link_layer(struct ib_device *device, static int hns_roce_query_pkey(struct ib_device *ib_dev, u32 port, u16 index, u16 *pkey) { + if (index > 0) + return -EINVAL; + *pkey = PKEY_ID; return 0; -- 2.34.1