mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ratheesh Kannoth <rkannoth@marvell.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: <edumazet@google.com>, <sumang@marvell.com>,
	<linux-kernel@vger.kernel.org>, <sbhatta@marvell.com>,
	<davem@davemloft.net>, <netdev@vger.kernel.org>,
	<pabeni@redhat.com>, <andrew+netdev@lunn.ch>,
	<sgoutham@marvell.com>
Subject: Re: [net-next,v6,01/13] octeontx2-af: npc: cn20k: Index management
Date: Thu, 29 Jan 2026 10:53:00 +0530	[thread overview]
Message-ID: <aXrutHgsKEuJUlGK@rkannoth-OptiPlex-7090> (raw)
In-Reply-To: <20260129051301.376533-1-kuba@kernel.org>

On 2026-01-29 at 10:43:01, Jakub Kicinski (kuba@kernel.org) wrote:
> This is an AI-generated review of your patch. The human sending this
> email has considered the AI review valid, or at least plausible.
>
> For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
> ---
> octeontx2-af: npc: cn20k: Index management
>
> This patch adds MCAM index management for CN20K silicon, implementing
> contiguous and non-contiguous allocation schemes across the new subbank
> architecture with 32 subbanks of 256 entries each.
>
> > diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
> > new file mode 100644
> > index 000000000000..30cc05c64487
> > --- /dev/null
> > +++ b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
>
> [ ... ]
>
> > +static int npc_create_srch_order(int cnt)
> > +{
> > +	int val = 0;
> > +
> > +	subbank_srch_order = kcalloc(cnt, sizeof(int),
> > +				     GFP_KERNEL);
> > +	if (!subbank_srch_order)
> > +		return -ENOMEM;
> > +
> > +	for (int i = 0; i < cnt; i += 2) {
> > +		subbank_srch_order[i] = cnt / 2 - val - 1;
> > +		subbank_srch_order[i + 1] = cnt / 2 + 1 + val;
>                                    ^^^^^
>
> When cnt is odd, the final loop iteration has i = cnt - 1, which means
> subbank_srch_order[i + 1] writes to index cnt, which is out of bounds.
>
> For example with cnt = 5, the loop iterates with i = 0, 2, 4. At i = 4,
> the array access subbank_srch_order[5] overflows the allocated array of
> 5 elements.
>
> While CN20K hardware typically has 32 subbanks (even), the value is read
> from a hardware register at npc_priv_init() without validation beyond
> checking for zero. Could this lead to memory corruption if the hardware
> reports an odd subbank count?
subbank count is 16 or 8, depending on SoC variant. i will add a WARN check on
odd ?

>
> > +		val++;
> > +	}
> > +
> > +	subbank_srch_order[cnt - 1] = cnt / 2;
> > +	return 0;
> > +}
>
> [ ... ]
> --
> pw-bot: cr

  reply	other threads:[~2026-01-29  5:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28  7:12 [PATCH net-next v6 00/13] NPC HW block support for cn20k Ratheesh Kannoth
2026-01-28  7:12 ` [PATCH net-next v6 01/13] octeontx2-af: npc: cn20k: Index management Ratheesh Kannoth
2026-01-28 11:27   ` ALOK TIWARI
2026-01-29  5:13   ` [net-next,v6,01/13] " Jakub Kicinski
2026-01-29  5:23     ` Ratheesh Kannoth [this message]
2026-01-29 23:50       ` Jakub Kicinski
2026-01-28  7:12 ` [PATCH net-next v6 02/13] octeontx2-af: npc: cn20k: KPM profile changes Ratheesh Kannoth
2026-01-29  5:13   ` [net-next,v6,02/13] " Jakub Kicinski
2026-01-28  7:12 ` [PATCH net-next v6 03/13] octeontx2-af: npc: cn20k: Add default profile Ratheesh Kannoth
2026-01-28  7:12 ` [PATCH net-next v6 04/13] octeontx2-af: npc: cn20k: MKEX profile support Ratheesh Kannoth
2026-01-28  7:12 ` [PATCH net-next v6 05/13] octeontx2-af: npc: cn20k: Allocate default MCAM indexes Ratheesh Kannoth
2026-01-28  7:12 ` [PATCH net-next v6 06/13] octeontx2-af: npc: cn20k: Use common APIs Ratheesh Kannoth
2026-01-28  7:12 ` [PATCH net-next v6 07/13] octeontx2-af: npc: cn20k: Prepare for new SoC Ratheesh Kannoth
2026-01-28  7:12 ` [PATCH net-next v6 08/13] octeontx2-af: npc: cn20k: Add new mailboxes for CN20K silicon Ratheesh Kannoth
2026-01-29  5:13   ` [net-next,v6,08/13] " Jakub Kicinski
2026-01-28  7:12 ` [PATCH net-next v6 09/13] octeontx2-af: npc: cn20k: virtual index support Ratheesh Kannoth
2026-01-29  5:13   ` [net-next,v6,09/13] " Jakub Kicinski
2026-01-28  7:12 ` [PATCH net-next v6 10/13] octeontx2-af: npc: cn20k: Allocate MCAM entry for flow installation Ratheesh Kannoth
2026-01-29  5:13   ` [net-next,v6,10/13] " Jakub Kicinski
2026-01-28  7:12 ` [PATCH net-next v6 11/13] octeontx2-pf: cn20k: Add TC rules support Ratheesh Kannoth
2026-01-29  5:13   ` [net-next,v6,11/13] " Jakub Kicinski
2026-01-28  7:12 ` [PATCH net-next v6 12/13] octeontx2-af: npc: cn20k: add debugfs support Ratheesh Kannoth
2026-01-28  7:12 ` [PATCH net-next v6 13/13] octeontx2-af: npc: Use common structures Ratheesh Kannoth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aXrutHgsKEuJUlGK@rkannoth-OptiPlex-7090 \
    --to=rkannoth@marvell.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sbhatta@marvell.com \
    --cc=sgoutham@marvell.com \
    --cc=sumang@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®