Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3603334pxb; Mon, 24 Jan 2022 13:17:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJzFSL041Rsb2C7pptjSHL6ChDb6pN76anPE7hu5dyuhd/8gP1hmk1MZRPaez1hMKCMIB250 X-Received: by 2002:a17:902:a404:b0:148:b897:c658 with SMTP id p4-20020a170902a40400b00148b897c658mr16108427plq.71.1643059049305; Mon, 24 Jan 2022 13:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643059049; cv=none; d=google.com; s=arc-20160816; b=Gmwhfru0BW9bALYE+deBryBzmEg187fzXQ2KC64BgciyYRrhv7TT0iCIrPHhqdTIpx hXXaie7hjvxfQN51VQ/NURvpmX7EvIsUgFQ8vF/sdJcDO0X7RzPWM6ATs1HCefutEFc2 v06imUil05umN/UXPdIAPKRpB4RVSO7JmEbcBUDUJkBeg2Z1CB0ITskQfPqVTlytLihr FIHHMosHqTcjpq4u45ZUExLt1jSHgKwoFwOOx4nuPWGXfS2RqiT8Zz55hTODX1zHK+hy nBoElsK99OEpXSe/YjWPnIBgZMlpZyjDFrK/+hZKIhG3mE7MRSdRXy+2QuO9a9kLFZCj I18g== 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=f1VHWGcv2p2FljxVbp0WXihbJSta0OiHL2gAfa+JKyc=; b=J0WYMhAwcZslhILsUCex8Ah8xRyF9NZJA80DoMJ1qn9rtLbvSOGCHvn+UTdph7cwP5 dIYaYwDrKm+F+D+J8S3AC/coZ8kjV7+kusyRf6CvZvDEJbwBXEzC9Quu/j7z6UOxcGCI yE/x1FD5LompdhpdFzEhOvrA+oZxIyYz/lFj+92EX3GjCUYKlBxUfZYoiR5ab3PL65dn DHtoK2L6KIUn44V/2wtSOM4Nhfu7k8vX1Vc7erjKvsXbnTlCWkkxYqoRzi2bPx6bUABc mwU+FKc+zp2bn3AW5h3BoEcD6Z5WCYNLllA1e2XIdaVbxcIG18HHdZFbYUR2OBsyqGXZ CDFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tSTZL8Ws; 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 w23si14528692pll.352.2022.01.24.13.17.17; Mon, 24 Jan 2022 13:17:29 -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=tSTZL8Ws; 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 S1441852AbiAXUvp (ORCPT + 99 others); Mon, 24 Jan 2022 15:51:45 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:35288 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1384029AbiAXU2p (ORCPT ); Mon, 24 Jan 2022 15:28:45 -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 ams.source.kernel.org (Postfix) with ESMTPS id 50CE4B8123F; Mon, 24 Jan 2022 20:28:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D612C340E5; Mon, 24 Jan 2022 20:28:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643056123; bh=gCqnxCSztncfwgpQ6vakkyq1OCHii8Ag/97TwT4IkCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tSTZL8WsTEQZnVcLqGktUo1FZAuEe6TA00I5TmBXjSWiyG67Oi5aW//hTHEXP2RzT 1Futgj15Y+OOsAKMtzqZyzH74X4/mG7XW3saFLvM9rgrJxqgBUt/qg5473QYuZ9KPe ULnvxAwlG905J4KPRfCc81SY3WFc2DPQ7Xz5lNjE= 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.15 379/846] RDMA/hns: Validate the pkey index Date: Mon, 24 Jan 2022 19:38:16 +0100 Message-Id: <20220124184114.008408143@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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 5d39bd08582af..6012340e6d69e 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -269,6 +269,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