Article View: linux.kernel.netdev
Article #20278Re: [PATCH net v4 2/2] net: atl1c: free the RX buffer when the descriptor reports an error
From: netdev-bot+sashiko
Date: Sat, 21 Nov 2026 23:18
Date: Sat, 21 Nov 2026 23:18
214 lines
15744 bytes
15744 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (2) · Medium: 1 · Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] In atl1c_clean_rx()
(drivers/net/ethernet/atheros/atl1c/atl1c_main.c), the RRD valid bit…
Pre-existing issues:
- [High] This patch adds a new schedule_work(&adapter->common_task) call
(atl1c_clean_rx(), line 1939) in NAPI context.
- [High] The reset branch of atl1c_common_task() (lines 363-367) calls
atl1c_down()/atl1c_up() without rtnl_lock and without taking…
--
net: atl1c: free the RX buffer when the descriptor reports an error
With this patch, atl1c_clean_rx() unmaps and frees the skb for RRDs that
report RRS_RX_ERR_SUM or RRS_802_3_LEN_ERR. Before, those buffers leaked.
Each RRD's RFD count and index are now checked against
rfd_ring->next_to_clean, and a mismatch schedules an adapter reset. The
RRD ring is also zeroed in atl1c_clean_rx_ring().
> diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> index e9baee8fa7e5e..5d00f2489d154 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> @@ -933,8 +933,9 @@ static void atl1c_clean_rx_ring(struct atl1c_adapter *adapter, u32 queue)
> buffer_info = &rfd_ring->buffer_info[j];
> atl1c_clean_buffer(pdev, buffer_info, 0);
> }
> - /* zero out the descriptor ring */
> + /* zero out the descriptor rings */
> memset(rfd_ring->desc, 0, rfd_ring->size);
> + memset(rrd_ring->desc, 0, rrd_ring->size);
> rfd_ring->next_to_clean = 0;
> rfd_ring->next_to_use = 0;
> rrd_ring->next_to_use = 0;
[ ... ]
> @@ -1914,47 +1909,59 @@ static int atl1c_clean_rx(struct napi_struct *napi, int budget)
> if (work_done >= budget)
> break;
> rrs = ATL1C_RRD_DESC(rrd_ring, rrd_ring->next_to_clean);
> - if (likely(RRS_RXD_IS_VALID(rrs->word3))) {
> - rfd_num = (rrs->word0 >> RRS_RX_RFD_CNT_SHIFT) &
> - RRS_RX_RFD_CNT_MASK;
> - if (unlikely(rfd_num != 1))
> - /* TODO support mul rfd*/
> - if (netif_msg_rx_err(adapter))
> - dev_warn(&pdev->dev,
> - "Multi rfd not support yet!\n");
> - goto rrs_checked;
> - } else {
> + if (!RRS_RXD_IS_VALID(rrs->word3))
> + break;
> +
> + rrs_word0 = le32_to_cpu(rrs->word0);
[Severity: Medium]
Should there be a dma_rmb() between the RRS_RXD_IS_VALID() test on word3
and the read of word0 here?
The notes after the commit message say the missing barrier is
pre-existing and will be fixed in a separate patch. Before this patch, a
stale word0 only made one poll stop early. Now the RFD count and index
taken from word0 decide whether ATL1C_WORK_EVENT_RESET is scheduled, and
that runs atl1c_down()/atl1c_up() from atl1c_common_task().
On weakly ordered CPUs such as arm64 and powerpc, the control dependency
on the word3 test does not order the later word0 load. So word0 can be
read before the device's RRD write is visible.
The RRD ring is zero after open, because dma_alloc_coherent() zeroes it.
With the memset added to atl1c_clean_rx_ring() above, it is also zero
after every reset. On the first lap after open or reset, a stale word0
would then be 0 and give rfd_num == 0, which hits:
if (unlikely(rfd_num != 1 ||
rfd_index != rfd_ring->next_to_clean ||
!buffer_info->skb)) {
...
set_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event);
schedule_work(&adapter->common_task);
Could this produce a spurious "RRD out of sync" message and a full MAC
reset that drops the link? The reset zeroes the ring again, so the next
lap is exposed in the same way.
Without the memset, a stale word0 at slot k would still hold the
previous lap's value (count 1, index k) and pass the check.
Would a dma_rmb() right after the RRS_RXD_IS_VALID() test close this
window?
> + rfd_num = (rrs_word0 >> RRS_RX_RFD_CNT_SHIFT) &
> + RRS_RX_RFD_CNT_MASK;
> + rfd_index = (rrs_word0 >> RRS_RX_RFD_INDEX_SHIFT) &
> + RRS_RX_RFD_INDEX_MASK;
> + buffer_info = &rfd_ring->buffer_info[rfd_ring->next_to_clean];
[ ... ]
> + if (unlikely(rfd_num != 1 ||
> + rfd_index != rfd_ring->next_to_clean ||
> + !buffer_info->skb)) {
> + dev_err_ratelimited(&pdev->dev,
> + "RRD out of sync: RFD count %u index %u, expected index %u%s; resetting\n",
> + rfd_num, rfd_index,
> + rfd_ring->next_to_clean,
> + buffer_info->skb ? "" : " (no buffer)");
> + set_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event);
> + schedule_work(&adapter->common_task);
[Severity: High]
This isn't a bug introduced by this patch, but this schedule_work() is a
new producer for common_task that only napi_disable() can quiesce. Can
common_task be queued again after it has been cancelled, and then outlive
the adapter?
atl1c_close() cancels the work before atl1c_down() quiesces NAPI and the
IRQ:
atl1c_close() {
set_bit(__AT_DOWN, &adapter->flags);
cancel_work_sync(&adapter->common_task);
atl1c_down(adapter);
...
}
atl1c_down() {
atl1c_del_timer(adapter);
adapter->work_event = 0; /* clear all event */
...
napi_disable(&adapter->rrd_ring[i].napi);
atl1c_irq_disable(adapter);
atl1c_free_irq(adapter);
...
}
An RX poll still running in this window that hits an out-of-sync RRD
sets ATL1C_WORK_EVENT_RESET and calls schedule_work() again. The existing
ISR_ERROR path in the interrupt handler and atl1c_link_chg_event() can do
the same.
atl1c_remove() then does:
unregister_netdev(netdev);
...
free_netdev(netdev);
There is no cancel_work_sync() or flush_work() between the two. If the
worker has not run by then, the queued work_struct sits in freed
netdev_priv() memory. atl1c_common_task() would then run container_of()
and test_bit(__AT_DOWN, &adapter->flags) on freed memory.
Would a cancel_work_sync() once NAPI and the IRQ are quiesced avoid this?
That could go at the end of atl1c_close(), or in atl1c_remove() after
unregister_netdev().
[Severity: High]
This is a pre-existing issue, but this patch adds a new trigger (an
out-of-sync RRD) for the reset in atl1c_common_task(). The existing
triggers are tx_timeout and ISR_ERROR. Is that reset path serialized
against other callers of atl1c_down()/atl1c_up()?
atl1c_common_task() {
if (test_bit(__AT_DOWN, &adapter->flags))
return;
if (test_and_clear_bit(ATL1C_WORK_EVENT_RESET, &adapter->work_event)) {
netif_device_detach(netdev);
atl1c_down(adapter);
atl1c_up(adapter);
netif_device_attach(netdev);
}
...
}
It takes neither rtnl_lock nor __AT_RESETTING. atl1c_change_mtu() runs
under rtnl and takes __AT_RESETTING before its own atl1c_down() and
atl1c_up(). Nothing keeps the two apart.
Suppose atl1c_change_mtu()'s atl1c_down() runs while common_task is
between napi_disable() and napi_enable(). The second napi_disable() takes
netdev_lock() and waits on NAPI_STATE_SCHED, which is already set.
common_task's napi_enable() then blocks on netdev_lock().
Can this deadlock while atl1c_change_mtu() holds rtnl?
Other interleavings look like they could unmap and free the same RX
buffers twice through atl1c_reset_dma_ring(). They could also call
free_irq()/request_irq() twice.
The previous patch in this series, "net: atl1c: wait for in-flight RX
polls before the link-down ring reset", describes the same
napi_disable()/netdev_lock() deadlock for the link-change work.
> break;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261117225521.19689-1-federico%40rimpianto.com
Technical Details
Message-ID:
<179530311840.3135.8141689247648916052@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368512-linux-kernel-netdev=dewy.ruReferences:
<20261117225521.19689-3-federico@rimpianto.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-368512-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v4 2/2] net: atl1c: free the RX buffer when the descriptor reports an error Date: Sat, 21 Nov 2026 23:18:38 +0000 Organization: Usenet Network Message-ID: <179530311840.3135.8141689247648916052@kernel.org> References: <20261117225521.19689-3-federico@rimpianto.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3519588"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:SFCXh6Ed9kM6OUfejA+oPw13oJI= sha256:T8OQyBVCCbqxqBcYIgk0eAOKI2w6Sfpd9SpS7K7JuGU= sha1:KEvDBQL4Xg+OI+wd9ghHRl4nYbc= sha256:bV3Hk/MEXLV7S71IxVVpz4DG0HB3qJDde6KAPtnxnB8= 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 E912F115C28; Sun, 22 Nov 2026 02:19:00 +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 NYBTV7mSedsx; Sun, 22 Nov 2026 02:18:57 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-368512-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 tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 09BF0DFFA1; Sun, 22 Nov 2026 02:18:48 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 0CF482EE7E; Sat, 21 Nov 2026 23:18:45 +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=1795303120; b=nQfsaBUx0P77MZXYPibX6RYDJZ8AbpludfgJmVsxNU3O7Le4bIA4S2Up4+ZiHanvGApn RJkakVTQqNd0nYpjZrbTIvVCw15/Ojt/QVJYy7VdQorWrNjAz13VFzpZvtoNpCqQE1JD+ rZ1olFRo4P3vKebJ6mw/7xlv0aayzQGikvrQ2/nbPgGH8KbgdT6m24eJ0cNKPEHQmPqWc s+++lo/iHjSUa9mLRnMMGuuC1UK2I1nRikNZ4kD6Y7QDZbNnFkCTKJ60lLQWnG3kseNyW NtgOOZIWJL9OoXw9tStydb1OM+QI3euzJ2yuqxUDJn9CR5PY05AkADxM6C+X1qYl39A== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795303120; 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=OmQA8w8TiDFNVOcBCsrodxB2z/WYpL97V8Uh0g4rbSA=; b=wxsivghuFfoJ/ln3VnEMbne95ygQ3xL4feDnVClwla4v2iHfbhGFqc2E9D20TZ3Qed0e +srSbeR8lsIvojDWxWkhdr/t7zdWbaquNyBMrwd06971hc1P+MDghd8vVt3JTPtgoV05M 2zlw328iE+nHT4mBjoukQJquUBkH17PZE+1iu2R4/T9pcqnhD9khlDiKzr/rtpNDSm/Iy 2c7muoXUHGeEIVSM1GBy5VXgK0pRs59ZosXHKnynYXJqLfni/o9ua5xycNq1/mcyaLEZy y0XE4FIjJOWBiNyMq3RhSkE/Y/qZfiOoaavygV81Z/MtzTfPxqw4efwpCw6M6k8YsaQ== 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=F4AfGPBP; 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 5C003606A689; Sat, 21 Nov 2026 23:18:40 +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=F4AfGPBP 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=1795303119; b=kWxN3qLnOWqG80P3sYiK+fjggqX5c5B3TQop3kCO0cC32TkZaED8Rc6GfXt6Tr8oQ7pv 3M9qVin5C0RV41Aih2AX3/xaLy0alq2DAvQHxvmfNMsZNWX/8+EL+q/y7+yOWSehP0iq+ X6lVKqrgHWwmbfyOU+CNaONusqzorw2C+DWUZytL1t0oSEyn4OzMNNug5bXL09LN5f7qg 9VCXaBwsOjhJYrfvtaX37N4g1/Yr8DeEBorz459Pzq2dfppWmx2PJ9oiyk+fHfQoJ0h2+ 3uq9mlxglrYdnK4UZFXiwFedhU0zDvVtaHycU51e9e8QacEDiSHaXlCXpHo4/Yht97A== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795303119; 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=OmQA8w8TiDFNVOcBCsrodxB2z/WYpL97V8Uh0g4rbSA=; b=f2kEpDzeoutP3c7I+VAztGtBo999QzGi+bkcSRW/qV/BHTKmHzvicQCGt0BkPfOV3+nv ZBqDrw+3OPBuh6WpGcaWwmTdm8slr6Ok0MXgVVdJLUzi6yDce65Ct2qOIwK3441pCrsX5 x5mxZFNaDPVY8mBP0Ojsz8N4ORRxlvU6CeDlKtK+L4zdk69Xy5MKlvv+Rpu/wlWUn+XDY Vq0flay7ojQyOshkKgq0kJxbDVSDfSRT0MSKbIFmLlm3x4dMid+K4YFJK0DVhcZ1SZMWK wTaAJvuCDsUG3PAxotHj96S5ouTSfvEJu/UsfijmF4iwuvE0R18bDk+rplaMHWhOQ5A== 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=F4AfGPBP; 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 77E2D606A335; Sat, 21 Nov 2026 23:18:39 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7B571F000C0; Sat, 21 Nov 2026 23:18:38 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795303119; bh=OmQA8w8TiDFNVOcBCsrodxB2z/WYpL97V8Uh0g4rbSA=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=F4AfGPBPkv1KuRM+0ej8g2nycut8iZ7fHjvhKC28hnndqHJsu/jGu83Cn7Q+To2W5 KC9bq/T/ky4hp7FQ0DNZEv9Oy7rGwzyVKdCoJS8gVGGhT9nZOlnqQKTfTApU7fksKT vl4UFkqzWPCgXRirqjDcIVk/gg1PR0/1GZl6dgwM2NmvZApsoCYtBRoBQka5R2I03l osq26cy/SriSZLJEy8su6xVGvV0nnvR9mitiWdUD1W5VmPOwUC2Bl/dXC6fyiuinNu BEYmQnzCahl2ewf01/2T4/oYg4tyBFcm39inYqDFlCVH3cV+3Ud2yIyjtPVJbpBmJk Ix2rXzkotb8Tw== X-Cc: chris.snook@gmail.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org X-In-Reply-To: <20261117225521.19689-3-federico@rimpianto.com> X-sashiko-severity: Medium 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