mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: federico@rimpianto.com
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
Subject: Re: [PATCH net v5 2/2] net: atl1c: free the RX buffer when the descriptor reports an error
Date: Sun, 29 Nov 2026 11:48:38 +0000	[thread overview]
Message-ID: <179595291831.3146.7906490727635927112@kernel.org> (raw)
In-Reply-To: <20261125113120.99743-3-federico@rimpianto.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · 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 new RRD check…

--

net: atl1c: free the RX buffer when the descriptor reports an error

This commit changes atl1c_clean_rx() so that errored frames no longer
leak their skb and DMA mapping: the buffer is now unmapped and freed. It
also checks the RFD count and index in each RRD against
rfd_ring->next_to_clean. On a mismatch it schedules an adapter reset
through ATL1C_WORK_EVENT_RESET. Finally, it adds a dma_rmb() after the
valid-bit test and clears the RRD ring 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 afab3e16903ba..8383203623c17 100644
> --- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
> +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c

[ ... ]

> @@ -1952,47 +1947,66 @@ 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);
> +		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);
>  			break;
>  		}

[Severity: Medium]
Can this check turn a legitimate multi-RFD frame into a full controller
reset?

For any mtu <= 1522, atl1c_set_rxbufsize() leaves rx_buffer_len at
AT_RX_BUF_SIZE (1522):

	adapter->rx_buffer_len = mtu > AT_RX_BUF_SIZE ?
		roundup(mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN, 8) : AT_RX_BUF_SIZE;

atl1c_configure_rx() writes that value to REG_RX_BUF_SIZE. Meanwhile
atl1c_configure_mac() sets the MAC frame limit to mtu + 22:

	AT_WRITE_REG(hw, REG_MTU, hw->max_frame_size + ETH_HLEN +
			VLAN_HLEN + ETH_FCS_LEN);

So with 1501 <= mtu <= 1522 (mtu 1508 for RFC 4638 PPPoE, for example),
the MAC accepts frames of up to 1523..1544 bytes into 1522-byte RFDs.

Suppose the device splits such a frame over two RFDs and reports
RRS_RX_RFD_CNT = 2. This branch then sets ATL1C_WORK_EVENT_RESET, and
atl1c_common_task() runs netif_device_detach(), atl1c_down() and
atl1c_up() once per frame.

Errored multi-RFD frames (RRS_RX_ERR_SUM or RRS_802_3_LEN_ERR) used to
be consumed by atl1c_clean_rrd() and atl1c_clean_rfd() with rfd_num, and
RX carried on. With this patch they also reset the controller. Nothing
limits how often the reset can be scheduled, so a peer that keeps sending
such frames could keep the link flapping.

The commit message names alx_clean_rx_irq() as the model. alx can treat
a count other than 1 as fatal because its rxbuf_size comes from
ALX_MAX_FRAME_LEN(mtu), which is always at least the ALX_MTU register
value. atl1c does not hold to that for mtu 1501..1522.

It isn't confirmed whether the hardware splits an oversized frame across
RFDs or truncates it into one. The old "TODO support mul rfd" branches
and the 4-bit RFD count field suggest that splitting can happen.

Would it work to size rx_buffer_len from the same expression as REG_MTU,
for example max(AT_RX_BUF_SIZE, roundup(mtu + ETH_HLEN + VLAN_HLEN +
ETH_FCS_LEN, 8))? Another option is to drop and recycle a multi-RFD frame
whose index matches next_to_clean, and keep the reset for a real desync.

[ ... ]

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261125113120.99743-1-federico%40rimpianto.com

      reply	other threads:[~2026-11-29 11:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 11:31 [PATCH net v5 0/2] net: atl1c: fix the RX buffer leak on errored frames Federico Musto
2026-11-25 11:31 ` [PATCH net v5 1/2] net: atl1c: wait for in-flight RX polls before the link-down ring reset Federico Musto
2026-11-29 11:48   ` netdev-bot+sashiko
2026-11-25 11:31 ` [PATCH net v5 2/2] net: atl1c: free the RX buffer when the descriptor reports an error Federico Musto
2026-11-29 11:48   ` netdev-bot+sashiko [this message]

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=179595291831.3146.7906490727635927112@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=chris.snook@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=federico@rimpianto.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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®