Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp663643lqz; Sat, 30 Mar 2024 13:12:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXNSWHGvR2QoNdqlurEzuhLtR4v5cRZbtkqB4zeBMehf3iy8EDCQqo+A52zohrtiBXWQjUTq62ZRyzfwhHWeA4GECcbqQL8qY+Bet5ivQ== X-Google-Smtp-Source: AGHT+IFiz7C+aH88M20WoTjaM9SmYjQkBfu4FxuFcWFnffVADbHO1FCwDYasQ7OBY5OQyXMEzSK1 X-Received: by 2002:a05:6402:1ec9:b0:56d:c73f:98ab with SMTP id g9-20020a0564021ec900b0056dc73f98abmr946480edg.19.1711829542778; Sat, 30 Mar 2024 13:12:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711829542; cv=pass; d=google.com; s=arc-20160816; b=a2A+lOW3/ban+mYjyinm3fQF/ZcV3OYiNB8snJjqhPuppuFqMMaqNlGw9oVvXDtNty /xm7cTICj2x9dLemAb0LjbgurMARvXktZb6eA+m0J2dtEkF66mrA4fU6JTfhTsE+TKlT qQDWMhWqpXPLXz7L04S6brEk14uWcE2D+H4eiclZXNDix5CrHGC3rDT7VUdVf5LTkNBV qMGb6EoljvcgG2XD91SKNBRqtAWnSfqJvSlXM1WWhyntyb8X1K7a6vrGotbu6kEM88EY LMeWikSLR2JD/AKIuV8xeWbeHrrbxiyKVCVAWlD1GIgWPnvt25Z6KzUfz/6giYgp5lc/ jFnw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=y0QyWOg333fQjHdB1I0gCndvZGKpQ+GkBldAsR8kGV8=; fh=xOMEImMucJgiEMkVKhIE8tcPJys8mYX8derDcbk5kfw=; b=t7qevQ0ldQXMRPbT3cJSVVDEm5Z7GIa4HxpbaUMJOyQ4hzAKqJIBu/cGwFWQhusFQs Y8kAvgxtsgQuuzSyzNN3uYDQx7adGI4KyTiOKKeLAl9/Igqs0rK4Sox5rGSz1epslSBw bysBEjCKJA6NVt1QgOe4Tyth/FPDUEL13UF25ZsayMzToWB9yr9PRscxD8cWt+O3Itiq Y9ylQY61aWkHi5u5uziyaI4yjNg/OLBknaxtZjHjVy0gFO9r2M2I29KGBaUxCg6AJIGP qnxv2edKlVAXEf7vMsYjbYeo98Fa2L0U3dKCzGA1cPl3wC6o4cKpSnIYEoTaBD0hNcmI X1rg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lGKCKruL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-125834-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125834-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id fj19-20020a0564022b9300b0056dc938aad5si231352edb.117.2024.03.30.13.12.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 30 Mar 2024 13:12:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-125834-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lGKCKruL; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-125834-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-125834-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 5EF8A1F22F0C for ; Sat, 30 Mar 2024 20:12:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53F5C43AC8; Sat, 30 Mar 2024 20:12:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lGKCKruL" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 77C4017D2; Sat, 30 Mar 2024 20:12:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711829531; cv=none; b=cg4JXiu2TTqk7+AlLJADizVcLrT2r9jP/z4stGAlOmME3bMlCT8S1kgZIxdklNBSS32ydqTPOd5IibjSXVOS0bWOsJdN5DIV6OIZwz4ftvuyYuklWLrmOc27fhRMoDvEUWSP62jsrYZeCXf/bgi5CYZMsAjHFmdt7BOD6FZ15JI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711829531; c=relaxed/simple; bh=tqxZkRzpXowyo+2UpdDz8L54SoNcrugqP9rLeDhbqnk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Y2PiYm0ESA8MqbYP5MlAhcWknqJirz0oAalMaN5vEBZ3ritN1ptiqqUkF2RL4fClzc8L7ZD47eNKOuyzGj9pR1GKyY1Mou0LhmBmd466RAfPuyIaooPliGM6Qtirg9TcaJzw/hUMYp6YR/G51IHHIZ/e6/d4A8ZaFgFlfcLB1ug= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lGKCKruL; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90DE7C433F1; Sat, 30 Mar 2024 20:12:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711829531; bh=tqxZkRzpXowyo+2UpdDz8L54SoNcrugqP9rLeDhbqnk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lGKCKruLPtXkgaWsIz7Fw2HM45FO+vLF7wjrUH0QrMBHQn4GsnWBqbj4OD5nPnNyI UIe98IldUxH5mHiwyyFWSYnY1mWjejEcmtd0ZoHoOyTjGzrgHmg+riHD98cttFvzn2 2ZV7lneQLOct9DfDvBgXiPbYiZ5omBRLk2DfgQ18yM5FfqPP9G+d8RRAzSsGSfBJNF UfwV9isvp938aGXdv07PYCKodaoRrJ5dsvMrAqdIJp2FESpUdSFRLmdE2OFiOhIRv/ AbW3RII4d+P70G+p67rXZYDfr83Y/cWw6j5h4IdMLUTssrkW98s1LXt3IzV7Zmxt4A kjdru6SwIX7/w== Date: Sat, 30 Mar 2024 20:10:36 +0000 From: Simon Horman To: Jakub Kicinski Cc: Aleksandr Mishin , Sunil Goutham , Linu Cherian , Geetha sowjanya , Jerin Jacob , hariprasad , Subbaraya Sundeep , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: Re: [PATCH] octeontx2-af: Add array index check Message-ID: <20240330201036.GA22418@kernel.org> References: <20240328081648.13193-1-amishin@t-argos.ru> <20240328112818.49c0de17@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240328112818.49c0de17@kernel.org> On Thu, Mar 28, 2024 at 11:28:18AM -0700, Jakub Kicinski wrote: > On Thu, 28 Mar 2024 11:16:48 +0300 Aleksandr Mishin wrote: > > 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. > > I'm guessing you got the 14 from: > > hw->lmac_per_cgx = (nix_const >> 8) & 0xFULL; > > Seems more reasonable to cap the size at that point than every use > afterwards. FWIIW, I didn't find any other locations where this overflow might occur, but I do agree that this approach makes sense. I also notice that rvu_map_cgx_lmac_pf() has the following check near the top. I think the lmac_per_cgx portion can be dropped, though that could be a follow-up. if (cgx_cnt_max > 0xF || rvu->hw->lmac_per_cgx > 0xF) return -EINVAL;