The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: vikas.gupta@broadcom.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
	andrew+netdev@lunn.ch, horms@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, bhargava.marreddy@broadcom.com,
	rahul-rg.gupta@broadcom.com, vsrama-krishna.nemani@broadcom.com,
	rajashekar.hudumula@broadcom.com, dharmender.garg@broadcom.com,
	ajit.khaparde@broadcom.com
Subject: Re: [PATCH net-next 3/4] bnge: add ndo_set_rx_mode_async support
Date: Tue, 28 Jul 2026 19:09:12 -0700	[thread overview]
Message-ID: <20260729020912.3657198-1-kuba@kernel.org> (raw)
In-Reply-To: <20260724142954.3101980-4-vikas.gupta@broadcom.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
---
--- Patch [3]: [PATCH net-next 3/4] bnge: add ndo_set_rx_mode_async support ---
commit 1fc0ed8b56a0fd5a87f788e357261a7f2693625b
Author: Vikas Gupta <vikas.gupta@broadcom.com>

bnge: add ndo_set_rx_mode_async support

This commit registers bnge_set_rx_mode() as ndo_set_rx_mode_async to
handle filter updates asynchronously. It computes UC list updates directly
from the snapshot, allowing sleepable HWRM commands without holding the
address lock.

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> index 1e3cdaeaa03dc..e67536a8c4304 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_netdev.c

[ ... ]

> @@ -2272,6 +2269,48 @@ static int bnge_cfg_rx_mode(struct bnge_net *bn, struct netdev_hw_addr_list *uc,
>  	return rc;
>  }
>  
> +static int bnge_set_rx_mode(struct net_device *dev,
> +			    struct netdev_hw_addr_list *uc,
> +			    struct netdev_hw_addr_list *mc)
> +{
> +	struct bnge_net *bn = netdev_priv(dev);
> +	struct bnge_vnic_info *vnic;

[ ... ]

> +	if (dev->flags & IFF_ALLMULTI) {
> +		mask |= CFA_L2_SET_RX_MASK_REQ_MASK_ALL_MCAST;
> +		vnic->mc_list_count = 0;
> +	} else if (dev->flags & IFF_MULTICAST) {
> +		mc_update = bnge_mc_list_updated(bn, &mask, mc);
> +	}
> +
> +	if (mask != vnic->rx_mask || uc_update || mc_update) {
> +		vnic->rx_mask = mask;
> +		return bnge_cfg_rx_mode(bn, uc, uc_update, true);
> +	}

[Severity: High]
If bnge_cfg_rx_mode() returns -EAGAIN, the network core schedules a retry 
timer. However, because vnic->rx_mask is eagerly updated here (and 
vnic->mc_list is mutated in-place inside bnge_mc_list_updated()), won't the 
subsequent retry falsely detect no state changes and return 0 without 
programming the hardware?

Could this leave the hardware filter state permanently desynchronized from 
the network stack?

> +
> +	return 0;
> +}

[ ... ]

> @@ -2704,7 +2743,7 @@ static int bnge_init_chip(struct bnge_net *bn)
>  		vnic->rx_mask |= mask;
>  	}
>  
> -	rc = bnge_cfg_rx_mode(bn, &bn->netdev->uc, false);
> +	rc = bnge_cfg_rx_mode(bn, &bn->netdev->uc, true, false);
>  	if (rc == -EAGAIN) {
>  		netif_rx_mode_schedule_retry(bn->netdev);
>  		rc = 0;

[Severity: High]
This is a pre-existing issue, but does iterating the live netdev multicast
list earlier in bnge_init_chip() require holding netif_addr_lock_bh()?

Just above this call in bnge_init_chip(), the code evaluates:
bnge_mc_list_updated(bn, &mask, &bn->netdev->mc)

Since this happens without netif_addr_lock_bh() held, could it race with 
concurrent multicast updates (such as dev_mc_add() from IGMP/MLD timers), 
potentially leading to a use-after-free or infinite loop during list 
traversal?

  reply	other threads:[~2026-07-29  2:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-24 14:29 [PATCH net-next 0/4] bnge: add more functionality Vikas Gupta
2026-07-24 14:29 ` [PATCH net-next 1/4] bnge: add steps in bnge_shutdown() Vikas Gupta
2026-07-29  2:09   ` Jakub Kicinski
2026-07-24 14:29 ` [PATCH net-next 2/4] bnge: refactor rx mode helpers to accept explicit address lists Vikas Gupta
2026-07-29  2:08   ` Jakub Kicinski
2026-07-29  2:09   ` Jakub Kicinski
2026-07-24 14:29 ` [PATCH net-next 3/4] bnge: add ndo_set_rx_mode_async support Vikas Gupta
2026-07-29  2:09   ` Jakub Kicinski [this message]
2026-07-24 14:29 ` [PATCH net-next 4/4] bnge: send hwrm for interface down/up transitions Vikas Gupta
2026-07-29  2:08   ` Jakub Kicinski
2026-07-29  2:09   ` Jakub Kicinski

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=20260729020912.3657198-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=ajit.khaparde@broadcom.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bhargava.marreddy@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=dharmender.garg@broadcom.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rahul-rg.gupta@broadcom.com \
    --cc=rajashekar.hudumula@broadcom.com \
    --cc=vikas.gupta@broadcom.com \
    --cc=vsrama-krishna.nemani@broadcom.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