Article View: linux.kernel.netdev
Article #21469Re: [PATCH net-next v5 5/9] bnxt_en: Reinit IRQ when configuring LRO/GRO/HDS
From: netdev-bot+sashiko
Date: Tue, 24 Nov 2026 02:10
Date: Tue, 24 Nov 2026 02:10
160 lines
13238 bytes
13238 bytes
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
Technical Details
Message-ID:
<179548625022.3135.12630325753455613911@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369953-linux-kernel-netdev=dewy.ruReferences:
<20261120012921.2537903-6-michael.chan@broadcom.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-369953-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev 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 Organization: Usenet Network Message-ID: <179548625022.3135.12630325753455613911@kernel.org> References: <20261120012921.2537903-6-michael.chan@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="4031942"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:Uy5wIki8c/V6RFy0ks0tHkeBmVI= sha256:QR+FiHD8pGuEAPMJW9oX3/es/5bmKBy2gKOws+fTWns= sha1:Awz0QdYSrpt9MQbgpLBqAB6+IbI= sha256:PyqwlHmSt3suNId/RAitRH5ZVRgLIFv6+mygyuL9roY= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 1F92B125DC8; Tue, 24 Nov 2026 05:11:08 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uY81iag_lr0D; Tue, 24 Nov 2026 05:11:04 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-369953-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 364CE125DCA; Tue, 24 Nov 2026 05:10:55 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 9C2A82F6ED; Tue, 24 Nov 2026 02:10:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795486252; b=JBlqFHaDsXQqe+zLnNtrdv0TM8ZwJXTaE27CUQyqvbUoaNiFHNSQUFjWv6lNzpI8xYbv jU1eHNA3UEIc+5Mv2g8BKFfumSwoDSQB9W41AC/K3+LbDecmmnkbXiI1AuVwLFtiSUmFZ /8LYDSwI+7QGvEfwc+vdkeJ81aBPXJrmRMcyOecT61DIrxNbKUi6rr9vE0yZ7VjOBfpqf UnfO1HQOnVFJJUFLCzCSqbyBjIM6g1ZNOAF45L/8Ueupz3M1HGxfcNf55OwMZTQ+ssksv iqYZ36AUUakDW8O5VXH3tJjjm1zCrQnIS6fkR5Uhp31LnLGr3ckYszN62q41BTwt2HQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795486252; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=oJmAlrgxrBlKgqKHo0n5T0b+LujKVapl/bClJpE9yZs=; b=sZBmmS4C765X9ocu5k/khAX/8tmQLCfurEmU3I1Uq3Qmx1kzW9lwzGLWjoFzgVh9OWwx Vg376ZXYmPZlW48J4UnWpgrgJSTqo1VpC+4g37nT+d7F0VHMk+PYDWsTbool5hjJ/nOdw F8Bg7XL6dcbXQBWAyu6AtUCm2PQo0EMFT9IzTTltUMNqetOfGH2MhJWVqDveGi41ImELM aUzcY7NQW+XzbEyhz6q5Elpn+ffxrtDuWYmW0eljwOkBSpGFayxD41NXrd0LiesPYadlf V83u/Rk3UnM8RFD9HlqiWewAktH5oJyjB6/A9dwqJ8SlMFELDmlJp25xzxBL2vBUbog== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KOnY5W4x; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 70363606A32A; Tue, 24 Nov 2026 02:10:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KOnY5W4x X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795486251; b=aVpJIM05Sf7O6k/fi0purNjm8xE3FXvCRTHYXQMi3vold4h+vWQoIk7suD84tT4iicTh e3PfTvjLsZN59Rew4b4j8lvlHpM1PYj+57b0cweBe8uYUadFP1MRmiL6H+Cvr0D0GTelp yuA10wlIyZxnKXSLlIV/LVU+pyvfUDKtq3VriLM82PKzcY7wCdRbAPibGT5iSo7qa1D1w LDi+dPUgzP3n+ea+UkzGPwXG+/p79f71oPhD9/s/5f7DFC9n84GX7fa0JDiEJP2g9R70P U3IHKbZDn0SD8xfAVb8m/8pR6VMqrWltwwkSN0zk1nt0nN6Lz/cs7MA2pHycEhKeLWQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795486251; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=oJmAlrgxrBlKgqKHo0n5T0b+LujKVapl/bClJpE9yZs=; b=IIAKG9pZCkikurq8YxhOl0f6zgYdzH9oKVvz/ndztnLW3qPFbU3dmvecuiTCd8hGVSyA 48Kr37q+5x7RBmiZtuNNCmv4ipM/PQ7QGALRe5aOWAwrQ9b3+sSvErDvJWwCs8JzOnIpn yFU8tm9JYt6NJADviWxRVollQDDi4zXAinHaTRZI8fFLeVg99j522tPU4WT3ZA7KRxhg6 wKi/gUlM2ddaAL39Rr/6Z7rW5jxNsPZkt6RS6NOL1ZTW0XtohUzHfWOOvKpq366436JZQ /KQX/bW7uDNalhQmFTQELYN/VmdIggkRsJi9wGMi4IZRTo/1UHDhQ6CyKth0BE+Q6pA== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KOnY5W4x; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F719606A330 for <netdev@vger.kernel.org>; Tue, 24 Nov 2026 02:10:51 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A521E1F000C6; Tue, 24 Nov 2026 02:10:50 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795486251; bh=oJmAlrgxrBlKgqKHo0n5T0b+LujKVapl/bClJpE9yZs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=KOnY5W4xbnCWFUMzHdg+TEQ1glidl7KxVvlIv0QFW4vDOWos5h+rAjlSzjbd6HPmB nKapBlwDrISxMWqNOcdeib6AHu78KKeAQ/Ye71fe1YypEXLzRW+VN5ZZdnH5ipYMXr OcyloDHC9k2QMvLWTPm3xpmcMJFWgu0bZ2BXa4FMSRdAQbXh91L1waehCZYqs+6XUn rMs+8AkbRbiVpTCeBKu9VbTxAwl+u/xZo9uzi39TnZzFsWOA/Yk4WwtMfahrBH5h7/ BBWv7h4HwedGCP3nCkaNgoN3cXViC2+TVYt/vc+dDgs1pkX6K0of35s0wyr98RX4n3 D9cstcDwg5rdA== X-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 X-In-Reply-To: <20261120012921.2537903-6-michael.chan@broadcom.com> X-sashiko-severity: Low X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list