Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp275707lqh; Thu, 28 Mar 2024 01:20:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVm5g6Nz1MUOv+Zs/BswcNADfE+LBKk3V6vl9svqAT8A0xrRm+9U39H9eLmkZidrJy9exLt98JLMNbCylZl+nYCikauiRz8vv/AMfrhiA== X-Google-Smtp-Source: AGHT+IH4gSDaO9HglyOlxpjX/6pGP8peUt08oC8bAh/aRpBcppmZ0HiSXaLPrrnZxxq0c/TVuM0O X-Received: by 2002:a17:90b:3a81:b0:29b:46f0:6f8e with SMTP id om1-20020a17090b3a8100b0029b46f06f8emr2363924pjb.8.1711614001991; Thu, 28 Mar 2024 01:20:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711614001; cv=pass; d=google.com; s=arc-20160816; b=ybqvsayWs8QZJMBOuX2vKYHz0raLtlyBHMZSNi2x+KhZN+MNo1LYwOtXuWiQMWVhQM /LT53+R1idZPF16lHPzvns6R9JPDPmAaBd57qKVszgxwhSoUo4cDCn7E6aALhX7cBJkI sCxhuZU/UEe+7c9XGNUHZ7asoiKQPB8k1xOLBFtxW/6DF6jhprswg8dP6dgS0zsC/+SA NRhlabD0bavxYU8UN2DAEaBSck6SvEZhclFuSbB6ZlupMGdZmuBa8pFzjlNKUMtCR/BC UbnDHvTL+uMKh86QA2jPEfhYALiFKUMc/2E167rEBxoxA3YUQzpOyqUkfIFm2FHX5+fM UkaQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=PBDen4iYcixurelbSTnSYzaQdiGcKvKP3bLFXy2ahvQ=; fh=NJnIVovbAh5m3TeClcO1DUKFK7OG026BK9qxGCI8R8Q=; b=QOLIOqaHUcp/UiP5tIiiRsBhbIHFGdEpz7UPySxkmEK9xuEXdj0ITtFLGSDqDpGvaz CfG7I5P4syII+rDoBGwgAS1MDhKr7WgzkAobHFEPXbcZ3azD1Peq5kk0/PaXzSIaY7cU +Zi8OfoQ4KWkSzkmMf0yAXeWVeRg/oRNnO9Jymua1z8Y2Rw2+wUmHMozL48f7NnHpMkE oOs9zxNFY56L85ComcaB1HB9VHiyFZIdfVUgAOfUG/jxHotfpi+nQliTfsSm8A1C/EDP HHivi9vZl5iFOzEKMPNenmhJ/BOjbcd8qqK6Vzn+UolChIL0pQqPemf64JuX7RIsG0yU QlNA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=hfyUJ6qw; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-122577-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w17-20020a17090a8a1100b002a1fff0e937si1230670pjn.17.2024.03.28.01.20.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 01:20:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-122577-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@t-argos.ru header.s=mail header.b=hfyUJ6qw; arc=pass (i=1 spf=pass spfdomain=t-argos.ru dkim=pass dkdomain=t-argos.ru dmarc=pass fromdomain=t-argos.ru); spf=pass (google.com: domain of linux-kernel+bounces-122577-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-122577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=t-argos.ru Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1DCC62988CD for ; Thu, 28 Mar 2024 08:19:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AA6654907; Thu, 28 Mar 2024 08:19:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b="hfyUJ6qw" Received: from mx1.t-argos.ru (mx1.t-argos.ru [109.73.34.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B067847C; Thu, 28 Mar 2024 08:18:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=109.73.34.58 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711613944; cv=none; b=uhWidEGrxsRehFqM6W2MtxmEpyGKP9dz9/9GWnRCLzgjBozqv0DEnSQSkyXwlSprEEMM2imW3kLf367CAjeTKyQ1W3o24rP+tiG3HkVqiN/VN7U5h5TzwzFA3iQVutaBOcKCwyeYx6veFxyhmY91QRWY5iR4oSNgP3oDwc77WCQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711613944; c=relaxed/simple; bh=gGMVJNa69Leb+cEsuqMfbUA1imWzW7vL8sf2rg0Skpo=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=kQXMK/xhfMXhj4kWv2ZaS7O4xxvO4oqKs+HwvneXHk+nclMuXNANRahx8g7jc3s3TzFJ2CI/a51i2Oi09Og1CH1m+GlGANZSu53URqTkV2NCn4dzIbbYGd5bIVtALexFYH8h0GRu35kHESRpOQmqRjlrPwMOgBtXuEG2ijas+o0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru; spf=pass smtp.mailfrom=t-argos.ru; dkim=pass (2048-bit key) header.d=t-argos.ru header.i=@t-argos.ru header.b=hfyUJ6qw; arc=none smtp.client-ip=109.73.34.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=t-argos.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=t-argos.ru Received: from mx1.t-argos.ru (localhost [127.0.0.1]) by mx1.t-argos.ru (Postfix) with ESMTP id EA2F3100002; Thu, 28 Mar 2024 11:18:33 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=t-argos.ru; s=mail; t=1711613914; bh=PBDen4iYcixurelbSTnSYzaQdiGcKvKP3bLFXy2ahvQ=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=hfyUJ6qwa0EdurR0ieoZbSH+vxyi00Eh/N8Kgmj54z98a4F9waSSW4HyYyn8fv8es 92k5TDTzeqxzQjNvSMjj7SW2Ls0jouagLRfVxAJWekx5aATjE7yec8JxMbNlvHT3zO 2SGObajDAqBGWe9yXDpxCNtAYdfkP2qyPm9SqHP5HqZ2a9AnUxVrndy67G9ioxwflu F4QjLKtMDvKGEUr81VYLRI9kz7lwlYxQc8bUC+WQ1/53iybepcxys5zyQGo0B+Z9ry yTn+sUDN7GSFkTglQ0gyIMXoJMO9kvprZyLzYc0j9xr9t4EzaQXaRuBtBTXXI1ISnj KuwUkOt6ML4ig== Received: from mx1.t-argos.ru.ru (ta-mail-02.ta.t-argos.ru [172.17.13.212]) by mx1.t-argos.ru (Postfix) with ESMTP; Thu, 28 Mar 2024 11:17:18 +0300 (MSK) Received: from localhost.localdomain (172.17.215.6) by ta-mail-02 (172.17.13.212) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Thu, 28 Mar 2024 11:16:57 +0300 From: Aleksandr Mishin To: Sunil Goutham CC: Aleksandr Mishin , Linu Cherian , Geetha sowjanya , Jerin Jacob , hariprasad , Subbaraya Sundeep , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , , , Subject: [PATCH] octeontx2-af: Add array index check Date: Thu, 28 Mar 2024 11:16:48 +0300 Message-ID: <20240328081648.13193-1-amishin@t-argos.ru> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: ta-mail-02.ta.t-argos.ru (172.17.13.212) To ta-mail-02 (172.17.13.212) X-KSMG-Rule-ID: 1 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 184459 [Mar 28 2024] X-KSMG-AntiSpam-Version: 6.1.0.4 X-KSMG-AntiSpam-Envelope-From: amishin@t-argos.ru X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 13 0.3.13 9d58e50253d512f89cb08f71c87c671a2d0a1bca, {Tracking_from_domain_doesnt_match_to}, t-argos.ru:7.1.1;mx1.t-argos.ru.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;127.0.0.199:7.1.2, FromAlignment: s X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean, bases: 2024/03/28 07:24:00 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2024/03/28 06:03:00 #24486213 X-KSMG-AntiVirus-Status: Clean, skipped In rvu_map_cgx_lmac_pf() the 'iter', which is used as an array index, can reach value (up to 14) that exceed the size (MAX_LMAC_COUNT = 8) of the array. Fix this bug by adding 'iter' value check. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: 91c6945ea1f9 ("octeontx2-af: cn10k: Add RPM MAC support") Signed-off-by: Aleksandr Mishin --- drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c index 72e060cf6b61..e9bf9231b018 100644 --- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c +++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_cgx.c @@ -160,6 +160,8 @@ static int rvu_map_cgx_lmac_pf(struct rvu *rvu) continue; lmac_bmap = cgx_get_lmac_bmap(rvu_cgx_pdata(cgx, rvu)); for_each_set_bit(iter, &lmac_bmap, rvu->hw->lmac_per_cgx) { + if (iter >= MAX_LMAC_COUNT) + continue; lmac = cgx_get_lmacid(rvu_cgx_pdata(cgx, rvu), iter); rvu->pf2cgxlmac_map[pf] = cgxlmac_id_to_bmap(cgx, lmac); -- 2.30.2