From: netdev-bot+sashiko@kernel.org
To: mail@birger-koblitz.de
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org,
linux-usb@vger.kernel.org, benjamin.larsson@genexis.eu
Subject: Re: [PATCH net-next v2 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
Date: Mon, 30 Nov 2026 08:35:21 +0000 [thread overview]
Message-ID: <179602772117.3146.6275925348080038117@kernel.org> (raw)
In-Reply-To: <20261129-fcs-v2-2-f60d6b105a15@birger-koblitz.de>
Thank you for your contribution! Sashiko AI review found 9 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 6 · Low: 3
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] The patch contains the second half of the FCS-leak fix but has
no Fixes: tag, and its commit message does not mention the change to…
- [Medium] ax88179a_rx_fixup() checks the minimum length (`pkt_len < 2 +
ETH_HLEN`, line 1079) before it strips the FCS (`pkt_len -=…
- [Medium] The new error counting in ax88179a_rx_fixup() (lines
1081-1088) gives misleading uAPI statistics.
- [Medium] ax88179a_rx_fixup() decides whether a frame carries a 4-byte
FCS trailer from dev->net->features (read per packet at line 1061),…
- [Medium] The new RXFCS/RXALL branch in ax88179a_set_features() (lines
786-795) ignores the return value of ax88179_write_u16(dev,…
- [Medium] Across this series ax179_data->rxctl has become a shared read-
modify-write variable, and no common lock covers its writers.
- [Low] When RXFCS or RXALL changes, the new block in
ax88179a_set_features() (lines 786-795) writes the cached…
- [Low] The two writers of ax179_data->rxctl in the AX88179A driver now
use different chip-version tests to decide on AX_RX_CTL_DROPCRCERR.
- [Low] The new counters in ax88179a_rx_fixup()
(dev->net->stats.rx_dropped++, rx_crc_errors++, rx_errors++ at lines…
--
net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
This patch adds NETIF_F_RXFCS and NETIF_F_RXALL support for the AX88179A.
It accounts for a trailing FCS in the rx_fixup() length checks and counts
dropped and bad-FCS frames. It also makes AX_RX_CTL_DROPCRCERR in
ax88179a_reset() conditional on the new features, or on the AX88279.
> diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
> index 69095110e7043..21cf90d69f502 100644
> --- a/drivers/net/usb/ax88179a_devices.c
> +++ b/drivers/net/usb/ax88179a_devices.c
[ ... ]
> @@ -780,6 +782,18 @@ static int ax88179a_set_features(struct net_device *net, netdev_features_t featu
> if (ret < 0)
> return ret;
> }
> +
> + if (changed & (NETIF_F_RXFCS | NETIF_F_RXALL)) {
> + u16 rxctl = READ_ONCE(ax179_data->rxctl);
> +
> + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL))
> + rxctl |= AX_RX_CTL_DROPCRCERR;
> + else
> + rxctl &= ~AX_RX_CTL_DROPCRCERR;
> + WRITE_ONCE(ax179_data->rxctl, rxctl);
[Severity: Medium]
Can this read-modify-write of ax179_data->rxctl race with the other rxctl
writers? This path runs under RTNL only.
After the earlier patch in this series, ax88179_set_multicast() also does
a read-modify-write of the same field. It holds only netif_addr_lock_bh(),
and RTNL is not guaranteed on the __dev_set_rx_mode() path:
drivers/net/usb/ax88179_lib.c:ax88179_set_multicast() {
...
rxctl = READ_ONCE(data->rxctl);
rxctl &= ~(AX_RX_CTL_IPE | AX_RX_CTL_DROPCRCERR | AX_RX_CTL_PRO |
AX_RX_CTL_AMALL | AX_RX_CTL_AM);
...
}
ax88179a_mac_link_up() writes the cached value under medium_status_mutex.
Neither of the other writers takes that mutex:
ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, READ_ONCE(ax179_data->rxctl));
Suppose set_multicast sets AX_RX_CTL_AM between the READ_ONCE() and the
WRITE_ONCE() here. The stale copy then goes to both the cache and the
hardware, and the multicast hash filter stays off until the next rx-mode
event. IPv6 solicited-node multicast, for example, would not be received.
The reverse interleaving loses the DROPCRCERR change instead.
Does rxctl need one lock shared by all of its writers?
> + ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
> + }
> +
> return 0;
> }
[Severity: Medium]
Should the return value of ax88179_write_u16() be checked here? The VLAN
branches above return ret on failure, but this branch always reaches
return 0.
WRITE_ONCE() has already updated the cache. If the control transfer fails,
ax179_data->rxctl and the soon-to-be-committed dev->features have the new
DROPCRCERR setting, while the hardware keeps the old one.
ax88179a_rx_fixup() would then parse every frame with the wrong FCS
assumption until mac_link_up() or reset() rewrites AX_RX_CTL from the
cache. One example is enabling rx-all with rx-fcs off: 4 bytes of payload
would be stripped from every frame.
[Severity: Low]
Can this write restart RX on an interface that is down? After
ax88179a_stop() has done this:
ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 0);
ax179_data->rxctl still holds AX_RX_CTL_START, AP, AMALL and AB.
ndo_set_features is not gated on IFF_UP, so ethtool -K rx-fcs or rx-all
on a down interface writes START back to the MAC.
This write is also not serialized against ax88179a_mac_link_up(). That
function runs from phylink's resolve work and does a stop, reconfigure,
restart sequence:
ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, AX_RX_CTL_STOP);
ax88179_write_u8(dev, AX_ACCESS_MAC, AX88179A_MAC_PATH, 1, 0);
...
Could a set_features call landing in that window restart RX before the
bulk-in and MAC path setup is finished?
[ ... ]
> @@ -1039,9 +1058,14 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
> pkt_end = 0;
> while (pkt_cnt--) {
> u64 pkt_desc = get_unaligned_le64(pkt_desc_ptr);
> + netdev_features_t features = dev->net->features;
[Severity: Medium]
Is dev->net->features a reliable way to tell whether the hardware
appended an FCS to this frame? In __netdev_update_features(),
ndo_set_features() runs before dev->features is assigned:
net/core/dev.c:__netdev_update_features() {
...
err = dev->netdev_ops->ndo_set_features(dev, features);
...
}
So ax88179a_set_features() changes DROPCRCERR in hardware while
dev->features still holds the old flags. Some frames were formatted under
the old setting: those already aggregated into outstanding bulk-in URBs,
or queued on dev->done. They are then parsed with whatever features value
is current at the time.
Take turning rx-all off while rx-fcs is off. The MAC stops appending the
FCS right away, but this loop can still see NETIF_F_RXALL and strip 4
bytes of real payload. Turning it on can leave an FCS attached to frames
treated as having none.
There is a second path. ax88179_set_multicast() rebuilds DROPCRCERR from
net->features and writes both the cache and the hardware. If it runs in
the set_features window before the features are committed, it stores the
old DROPCRCERR value. mac_link_up() later writes that value back from the
cache. Could hardware and dev->features then disagree until the next
rx-mode event or reset?
Would resetting the RX path on these toggles help, as e1000e and igb do?
> u32 pkt_len_plus_padd;
> + u32 fcs_trailer = 0;
> u32 pkt_len;
>
> + if (features & (NETIF_F_RXFCS | NETIF_F_RXALL))
> + fcs_trailer = ETH_FCS_LEN;
> +
[ ... ]
> @@ -1050,10 +1074,19 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
> if (pkt_end > hdr_off || (pkt_cnt == 0 && pkt_end != hdr_off))
> goto err;
>
> - if (pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK) ||
> - pkt_len > (dev->hard_mtu + AX179A_RX_HW_PAD) || pkt_len < 2 + ETH_HLEN) {
> + if (((pkt_desc & AX179A_RX_PD_DROP || !(pkt_desc & AX179A_RX_PD_RX_OK)) &&
> + !(features & NETIF_F_RXALL)) ||
> + pkt_len > dev->hard_mtu + AX179A_RX_HW_PAD + fcs_trailer ||
> + pkt_len < 2 + ETH_HLEN) {
> skb_pull(skb, pkt_len_plus_padd);
>
> + if (pkt_desc & AX179A_RX_PD_DROP)
> + dev->net->stats.rx_dropped++;
> +
> + if (!(pkt_desc & AX179A_RX_PD_RX_OK)) {
> + dev->net->stats.rx_crc_errors++;
> + dev->net->stats.rx_errors++;
> + }
[Severity: Medium]
Is it intended that these counters stop counting when rx-all is enabled?
With NETIF_F_RXALL set, frames without AX179A_RX_PD_RX_OK no longer take
this branch. They are delivered and counted as rx_packets by
usbnet_skb_return(), so rx_crc_errors and rx_errors stay flat.
Some frames have RX_OK set and DROP clear but are rejected only by the
length checks (pkt_len > hard_mtu + pad + fcs_trailer, or
pkt_len < 2 + ETH_HLEN). Those are not counted in rx_length_errors,
rx_errors or rx_dropped. Does that match the commit message?
Count dropped packets and those with incorrect FCS.
Also, AX179A_RX_PD_RX_OK is defined as a general RX status bit:
#define AX179A_RX_PD_RX_OK BIT(11)
Is it known that a missing RX_OK always means a CRC error, and not a
runt, oversize or PHY error? These counters reach user space through
dev_get_tstats64() -> netdev_stats_to_stats64().
[Severity: Low]
These are plain increments on dev->net->stats. ax88179a_rx_fixup() runs
from usbnet_bh(), which is both the dev->delay timer callback and the body
of bh_work. usbnet's rx_complete() also increments
dev->net->stats.rx_errors from URB completion context.
Can concurrent updates lose increments here? For rx_dropped,
dev_core_stats_rx_dropped_inc() would avoid the race.
> /* Next RX Packet Descriptor */
> pkt_desc_ptr++;
> continue;
> @@ -1063,6 +1096,9 @@ static int ax88179a_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
> if (!ax_skb)
> goto err;
>
> + if (!(features & NETIF_F_RXFCS))
> + pkt_len -= fcs_trailer;
> +
> skb_put(ax_skb, pkt_len);
> memcpy(ax_skb->data, skb->data + (ax179_data->ip_align ? AX179A_RX_HW_PAD : 0),
> pkt_len);
[Severity: Medium]
Can this subtraction produce an skb shorter than ETH_HLEN? The minimum
length check above runs before it:
pkt_len < 2 + ETH_HLEN) {
With rx-all on and rx-fcs off, fcs_trailer is 4. A descriptor reporting a
16 or 17 byte frame passes the check and is then cut to 12 or 13 bytes.
rx-all lets runt frames through, so such a descriptor can come from a
runt frame or from a crafted USB device. ax_skb was allocated with the
longer length, so its remaining bytes are uninitialized.
ax88179a_info uses FLAG_MULTI_PACKET, so rx_process() returns before its
own ETH_HLEN check:
drivers/net/usb/usbnet.c:rx_process() {
...
if (dev->driver_info->flags & FLAG_MULTI_PACKET)
return -EALREADY;
if (skb->len < ETH_HLEN) {
...
}
The short skb goes to usbnet_skb_return() -> eth_type_trans(). There
eth_skb_pull_mac() fails without reporting it, and eth->h_proto is read
from uninitialized bytes past skb->len.
Should the lower bound include fcs_trailer, for example
pkt_len < 2 + ETH_HLEN + fcs_trailer?
[ ... ]
> @@ -1216,12 +1252,14 @@ static int ax88179a_reset(struct usbnet *dev)
> ax88179_write_u8(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, *tmp);
>
> /* Configure RX control register => start operation */
> - rxctl = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_START | AX_RX_CTL_AP |
> - AX_RX_CTL_AMALL | AX_RX_CTL_AB;
> + rxctl = AX_RX_CTL_START | AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB;
> if (ax179_data->ip_align)
> rxctl |= AX_RX_CTL_IPE;
> if (dev->net->flags & IFF_PROMISC)
> rxctl |= AX_RX_CTL_PRO;
> + if (dev->net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) ||
> + ax179_data->chip_version == AX_VERSION_AX88279)
> + rxctl |= AX_RX_CTL_DROPCRCERR;
[Severity: Medium]
This hunk stops setting AX_RX_CTL_DROPCRCERR unconditionally. That
changes the default AX_RX_CTL value for every AX88179A/AX88772D user, not
only those who enable the new features. The commit message does not
mention this.
The previous patch in the series, "net: usb: ax88179: Make receiving FCS
on AX88179A configurable" (Fixes: 7d573278f9a5), says DROPCRCERR makes
the MAC keep the 4-byte FCS on frames passed to the host. That patch only
changed ax88179_set_multicast().
With only that patch applied, ax88179a_reset() still sets DROPCRCERR.
ax88179a_resume() calls ax88179a_reset() without re-running
ndo_set_rx_mode, so the FCS comes back on every received frame after
resume. The same happens in the window between reset() on open and the
next set_multicast().
Max-size jumbo frames would also be dropped in that configuration. The
earlier patch does not account for the FCS in the rx_fixup() length
check.
This hunk completes that fix. Should it carry the same Fixes: tag, or be
folded into the earlier patch, so a stable backport of the Fixes-tagged
patch alone is not incomplete?
[Severity: Low]
This test uses chip_version == AX_VERSION_AX88279. ax88179_set_multicast()
in ax88179_lib.c decides the same bit for the same rxctl shadow with a
different test:
if (net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) ||
data->chip_version != AX_VERSION_AX88179A)
rxctl |= AX_RX_CTL_DROPCRCERR;
The two only agree for AX_VERSION_AX88179A and AX_VERSION_AX88279, and
ax88179a_bind() does not reject other chip_version values. For any other
value, reset() leaves DROPCRCERR clear and the next set_rx_mode sets it.
Before this patch, reset() set the bit unconditionally, so both paths
agreed. Could both paths use the same condition?
> WRITE_ONCE(ax179_data->rxctl, rxctl);
> ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
>
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261129-fcs-v2-0-f60d6b105a15%40birger-koblitz.de
prev parent reply other threads:[~2026-11-30 8:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-29 7:40 [PATCH net-next v2 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-11-29 7:40 ` [PATCH net-next v2 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz
2026-11-30 8:35 ` netdev-bot+sashiko
2026-11-29 7:40 ` [PATCH net-next v2 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-11-30 8:35 ` 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=179602772117.3146.6275925348080038117@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=benjamin.larsson@genexis.eu \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mail@birger-koblitz.de \
--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