From: netdev-bot+sashiko@kernel.org
To: michael.chan@broadcom.com
Cc: davem@davemloft.net, netdev@vger.kernel.org, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, andrew+netdev@lunn.ch,
pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com
Subject: Re: [PATCH net-next v5 5/9] bnxt_en: Reinit IRQ when configuring LRO/GRO/HDS
Date: Tue, 24 Nov 2026 02:10:50 +0000 [thread overview]
Message-ID: <179548625022.3135.12630325753455613911@kernel.org> (raw)
In-Reply-To: <20261120012921.2537903-6-michael.chan@broadcom.com>
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message understates the bug being fixed.
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but this patch
sends more paths into it.
--
bnxt_en: Reinit IRQ when configuring LRO/GRO/HDS
When LRO/GRO/HDS is enabled, new RX aggregation rings may be needed. The
FW may grant fewer rings than requested, and then the number of channels
shrinks. The patch sets irq_re_init in bnxt_set_features() and
bnxt_set_ringparam() so that the IRQs and NAPIs are rebuilt when agg rings
are newly needed.
> Without
> this patch, when the driver is eventually shutdown, some memory for the
> unused NAPIs may never be freed properly if the rings have shrunk.
[Severity: Low]
Does this describe the pre-patch behavior accurately? It reads more like
a use-after-free than a leak.
Before this patch, the sequence looks like this:
bnxt_set_features() / bnxt_set_ringparam()
close/open with irq_re_init == false
bp->bnapi is kept, NAPIs for the old cp_nr_rings stay registered
__bnxt_reserve_rings()
BNXT_FLAG_AGG_RINGS is set, FW grants fewer rings
bp->rx_nr_rings and bp->cp_nr_rings shrink
Then the next close with irq_re_init == true (ndo_stop, remove, ...) runs:
__bnxt_close_nic()
bnxt_free_irq() <- loops only to the reduced bp->cp_nr_rings
bnxt_del_napi() <- same bound
bnxt_free_mem()
kfree(bp->bnapi); <- single block holding every bnxt_napi
The napi_structs above the reduced count would stay linked on
dev->napi_list after their memory is freed. Their IRQs would also stay
requested, with dev_id pointing into the freed block.
Later walks of dev->napi_list would then read freed memory. Examples are
netif_napi_dev_list_add() from the next bnxt_init_napi(), and
netif_napi_del() from free_netdev().
Could the commit message call this a use-after-free, so stable and
distro reviewers can see it is a memory safety fix?
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index f4eff048eea5a..887a67d42bb37 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
[ ... ]
> @@ -14184,8 +14185,12 @@ static int bnxt_set_features(struct net_device *dev, netdev_features_t features)
> update_tpa = true;
> if ((bp->flags & BNXT_FLAG_TPA) == 0 ||
> (flags & BNXT_FLAG_TPA) == 0 ||
> - (bp->flags & BNXT_FLAG_CHIP_P5_PLUS))
> + (bp->flags & BNXT_FLAG_CHIP_P5_PLUS)) {
> re_init = true;
> + if (!(bp->flags & BNXT_FLAG_AGG_RINGS) &&
> + (flags & BNXT_FLAG_AGG_RINGS))
> + irq_re_init = true;
> + }
> }
[ ... ]
> @@ -14208,7 +14213,7 @@ static int bnxt_set_features(struct net_device *dev, netdev_features_t features)
> return bnxt_reinit_features(bp, true, false, flags, update_tpa);
>
> if (re_init)
> - return bnxt_reinit_features(bp, false, false, flags, update_tpa);
> + return bnxt_reinit_features(bp, irq_re_init, false, flags, update_tpa);
[Severity: High]
This is a pre-existing issue, not one introduced by this patch, but this
patch sends more paths into it.
irq_re_init can now be true here, and in bnxt_set_ringparam() when
tcp-data-split is enabled. That means ethtool -K gro/lro on and ethtool -G
tcp-data-split on now reach the part of __bnxt_close_nic() that frees
bp->bnapi and the ring stats. Existing triggers already include
set_channels, change_mtu, the ntuple toggle and FW reset.
That free path is protected against stats readers by a single shared
state bit:
bnxt_get_stats64() {
set_bit(BNXT_STATE_READ_STATS, &bp->state);
smp_mb__after_atomic();
if (!test_bit(BNXT_STATE_OPEN, &bp->state)) {
clear_bit(BNXT_STATE_READ_STATS, &bp->state);
...
}
bnxt_sync_ring_stats(bp);
bnxt_get_ring_stats(bp, stats);
...
clear_bit(BNXT_STATE_READ_STATS, &bp->state);
}
__bnxt_close_nic() {
clear_bit(BNXT_STATE_OPEN, &bp->state);
smp_mb__after_atomic();
while (bnxt_drv_busy(bp))
msleep(20);
...
if (irq_re_init) {
bnxt_free_irq(bp);
bnxt_del_napi(bp);
}
bnxt_free_mem(bp, irq_re_init);
}
Stats readers such as /proc/net/dev and the sysfs statistics files can run
at the same time, and they do not hold RTNL. What happens when there are
two readers?
reader A reader B
set_bit(READ_STATS) set_bit(READ_STATS)
sees OPEN sees OPEN
bnxt_get_ring_stats() bnxt_get_ring_stats()
(preempted mid-walk) clear_bit(READ_STATS)
__bnxt_close_nic()
clear_bit(OPEN)
bnxt_drv_busy() returns false
bnxt_free_mem(bp, true)
kfree(bp->bnapi)
reader A resumes
bp->bnapi[i]->cp_ring.stats <- freed or NULL
Can reader A end up dereferencing freed bnapi or stats memory in
bnxt_get_ring_stats() here?
Would a real lock or RCU in bnxt_get_stats64() and __bnxt_close_nic() be
a better fit than the BNXT_STATE_READ_STATS bit?
>
> if (update_tpa) {
> bp->flags = flags;
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120012921.2537903-1-michael.chan%40broadcom.com
next prev parent reply other threads:[~2026-11-24 2:10 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 1:29 [PATCH net-next v5 0/9] bnxt_en: Ring accounting fixes Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 1/9] bnxt_en: Clear bp->total_irqs when disabling IRQs Michael Chan
2026-11-24 2:10 ` netdev-bot+sashiko
2026-11-20 1:29 ` [PATCH net-next v5 2/9] bnxt_en: Fix bnxt_reinit_features() when irq_re_init is true Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 3/9] bnxt_en: Refactor RSS table check logic Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 4/9] bnxt_en: Refactor IRQs required logic Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 5/9] bnxt_en: Reinit IRQ when configuring LRO/GRO/HDS Michael Chan
2026-11-24 2:10 ` netdev-bot+sashiko [this message]
2026-11-20 1:29 ` [PATCH net-next v5 6/9] bnxt_en: Remove support for the old NITRO A0 chip Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 7/9] bnxt_en: Refactor bnxt_num_cp_to_tx()/bnxt_num_tx_to_cp() helpers Michael Chan
2026-11-20 1:29 ` [PATCH net-next v5 8/9] bnxt_en: Fix ring accounting/validation when rings are constrained by FW Michael Chan
2026-11-24 2:10 ` netdev-bot+sashiko
2026-11-20 1:29 ` [PATCH net-next v5 9/9] bnxt_en: Fix ring accounting/validation when IRQs are constrained Michael Chan
2026-11-24 2:10 ` netdev-bot+sashiko
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=179548625022.3135.12630325753455613911@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=andrew.gospodarek@broadcom.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=michael.chan@broadcom.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pavan.chebbi@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