Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3558853pxb; Mon, 24 Jan 2022 12:12:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQVM59fjcZ/Q69JadlqnOuXd1P7lo1BtplLglZbsUFplD3TW+vxsUqgTa1l8MeeQxbSaub X-Received: by 2002:a63:e008:: with SMTP id e8mr12668418pgh.477.1643055119918; Mon, 24 Jan 2022 12:11:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643055119; cv=none; d=google.com; s=arc-20160816; b=OLHw/qq9eXf6JeYJDkllWDg+lJ6RmuRyB70Lanmd3NtPorycMyJCGevboT+R/kByvl MUB5XchOGBeXTA17BbnjuVYmSt703O/XFLXt+ISn2HhUVmf4HNV84i9Y2u2fIQ3kFoGP w8N8qvrl2tO7cm9moFU3jYoMzkxFxV878+h0LoO21H66iNKoua2EY7FcQjUpub/rHcbs bOsR/vaaSA6z9ozoJsF/je/HYj3uxod3gzbTE+eRFIhDOlGqv/txoGV7E6A/yGUNO5JN ryQKjpU//zcIFRwMnMmFsh1a23dpvUrJczXGeZvXGWRRNUDhFKSSZQU3yrHjH4VaAhNH 0wvg== 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=31KGeQuDNvsI0wWuDKD/DpaawoXo77tyCp+nCv1qFTU=; b=PV4w+jzcV7A45+3i7+yX7943860U+sc00sNpcNC+dkOM2nhhFZ8s5dGAackvmiCuKT IisY9QEIC0ZRmQgTZO+HQx1HdqwqWheP2EAQiOIsRP8IS9/L/kxDrBPuq69wZ/XkkNxL Y/bSIAlhRFcB4PZPj53DufV5VOAToOe5eMOLsuFIZ9gMMhBmqugsawS/3wcC+1AZgq12 4hFiv7luSBydMFRrP0MSDNQrPAWHULtee7+OW+tQlxsQ2DDRxO+iG1D3zN9CFWXvV6nN CTpNEFqvAu+83/66SEehGRiJWVTkgfPAhV8nJg/9r5eJgPP6NhBmQIx2wpN665L99FhA cX4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DADAexnB; 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 x9si15281784pgu.748.2022.01.24.12.11.46; Mon, 24 Jan 2022 12:11:59 -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=DADAexnB; 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 S1348385AbiAXTPS (ORCPT + 99 others); Mon, 24 Jan 2022 14:15:18 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:35056 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345296AbiAXTG5 (ORCPT ); Mon, 24 Jan 2022 14:06:57 -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 C25AC612F1; Mon, 24 Jan 2022 19:06:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86381C340E5; Mon, 24 Jan 2022 19:06:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051210; bh=NA/mU0i1Vi+X8zp/d7ZDj3kHh2fK5QZ3ovBPxx+vMWs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DADAexnBAkyo1FwAdbGDi3BPNssuAt3vvzezydzDng8/CBMfnzjnkJmORgKQZtYpX TpkgqOntflQ7KAf2JvMRYpZTcTkXCsqL5zEVul6/gu5MNVZFUJIBCDAY7PpwNVXonM iLNsP4KHPFWZcQEScccq10fUxOyaikjvNuG7+lrs= 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 4.14 072/186] RDMA/hns: Validate the pkey index Date: Mon, 24 Jan 2022 19:42:27 +0100 Message-Id: <20220124183939.441587144@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183937.101330125@linuxfoundation.org> References: <20220124183937.101330125@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 d9777b662eba9..6f64dc5262c0d 100644 --- a/drivers/infiniband/hw/hns/hns_roce_main.c +++ b/drivers/infiniband/hw/hns/hns_roce_main.c @@ -294,6 +294,9 @@ static int hns_roce_query_gid(struct ib_device *ib_dev, u8 port_num, int index, static int hns_roce_query_pkey(struct ib_device *ib_dev, u8 port, u16 index, u16 *pkey) { + if (index > 0) + return -EINVAL; + *pkey = PKEY_ID; return 0; -- 2.34.1