From: sashiko-bot@kernel.org
To: "Birger Koblitz" <mail@birger-koblitz.de>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next v3 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
Date: Wed, 02 Dec 2026 17:17:42 +0000 [thread overview]
Message-ID: <sashiko-outbox-246318@kernel.org> (raw)
In-Reply-To: <20261201-fcs-v3-2-6c355917b17e@birger-koblitz.de>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] net: usb: ax88179: unsynchronized rxctl update in
ax88179a_set_features()
- [Medium] net: usb: ax88179: FCS stripping race on features in
ax88179a_rx_fixup()
- [Medium] net: usb: ax88179: bad-FCS frames skip stats and checksum
check on RXALL
- [Low] net: usb: ax88179: ax88179a_set_features() enables RX while
stopped
--
commit 38bd5184999fcc79ca797c6f439fd670ad6ab639
Author: Birger Koblitz <mail@birger-koblitz.de>
net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
This commit adds NETIF_F_RXFCS and NETIF_F_RXALL support for AX88179A
chips, adjusts RX length validation and FCS stripping in
ax88179a_rx_fixup(), and updates RX drop and CRC error counters.
> diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
> index 69095110e7043..04d8f37bc7ebe 100644
> --- a/drivers/net/usb/ax88179a_devices.c
> +++ b/drivers/net/usb/ax88179a_devices.c
> @@ -717,10 +717,12 @@ static int ax88179a_mii_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
> static int ax88179a_set_features(struct net_device *net, netdev_features_t features)
> {
> struct usbnet *dev = netdev_priv(net);
> + struct ax88179_data *ax179_data;
> netdev_features_t changed;
> int ret;
> u8 tmp;
>
> + ax179_data = dev->driver_priv;
> changed = net->features ^ features;
>
> ret = ax88179_set_features(net, features);
> @@ -780,6 +782,20 @@ 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);
> + ret = ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
> + if (ret < 0)
> + return ret;
> + }
> +
> return 0;
> }
[Severity: Medium]
Can this unlocked update to ax179_data->rxctl and AX_RX_CTL race with
ax88179_set_multicast()?
__netdev_update_features() invokes ndo_set_features before updating
net->features, while ax88179_set_multicast() runs in BH context under
netif_addr_lock_bh(net) without rtnl_lock and recomputes
AX_RX_CTL_DROPCRCERR from net->features:
drivers/net/usb/ax88179_lib.c:ax88179_set_multicast() {
...
if (data->chip_version >= AX_VERSION_AX88179A) {
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);
} else {
rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_DROPCRCERR);
}
if (data->ip_align)
rxctl |= AX_RX_CTL_IPE;
if (net->features & (NETIF_F_RXFCS | NETIF_F_RXALL) ||
data->chip_version != AX_VERSION_AX88179A)
rxctl |= AX_RX_CTL_DROPCRCERR;
...
WRITE_ONCE(data->rxctl, rxctl);
ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL,
2, 2, &data->rxctl);
}
When ax88179_set_multicast() runs while ax88179a_set_features() is blocked
in ax88179_write_u16(), it reads the old net->features value and overwrites
both data->rxctl and AX_RX_CTL:
CPU0 CPU1 (<softirq>)
__netdev_update_features()
ax88179a_set_features()
rxctl |= AX_RX_CTL_DROPCRCERR
WRITE_ONCE(ax179_data->rxctl, ...)
ax88179_write_u16(..., AX_RX_CTL, ...)
dev_mc_add()
__dev_set_rx_mode()
ax88179_set_multicast()
/* net->features still old */
rxctl &= ~AX_RX_CTL_DROPCRCERR
WRITE_ONCE(data->rxctl, rxctl)
ax88179_write_cmd_async(...)
<-- reverts DROPCRCERR
net->features = features
Once AX_RX_CTL_DROPCRCERR in hardware disagrees with dev->net->features,
ax88179a_rx_fixup() either strips 4 bytes of valid packet payload (when
NETIF_F_RXALL is enabled without NETIF_F_RXFCS) or leaves 4 bytes of FCS
attached and drops full-MTU packets. Conversely, if
ax88179_set_multicast() updates AX_RX_CTL_PRO, AX_RX_CTL_AMALL, or
AX_RX_CTL_AM between READ_ONCE() and WRITE_ONCE() in
ax88179a_set_features(), those filter changes are lost.
Also, WRITE_ONCE(ax179_data->rxctl, rxctl) happens before checking whether
ax88179_write_u16() succeeded; if the USB control transfer fails,
__netdev_update_features() keeps the old net->features while
ax179_data->rxctl retains the new bit and is later written to hardware by
ax88179a_mac_link_up().
[Severity: Low]
Does toggling NETIF_F_RXFCS or NETIF_F_RXALL while the interface is down
or mid-link-up re-enable RX in hardware?
ax88179a_reset() sets AX_RX_CTL_START in ax179_data->rxctl, and
ax88179a_stop() writes 0 to AX_RX_CTL without clearing AX_RX_CTL_START in
ax179_data->rxctl. Similarly, ax88179a_mac_link_up() writes
AX_RX_CTL_STOP to AX_RX_CTL while reconfiguring link registers before
restoring ax179_data->rxctl under medium_status_mutex. Because
ax88179a_set_features() unconditionally writes ax179_data->rxctl to
AX_RX_CTL without checking netif_running(net) or synchronizing with
ax88179a_mac_link_up(), changing rx-fcs or rx-all re-asserts
AX_RX_CTL_START while the interface is stopped or while link registers are
being reconfigured.
[ ... ]
> @@ -1039,9 +1060,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;
> 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;
> +
> pkt_len = FIELD_GET(AX179A_RX_PD_LEN, pkt_desc);
> pkt_len -= (ax179_data->ip_align ? 2 : 0);
> pkt_len_plus_padd = ((pkt_len + 7 + (ax179_data->ip_align ? 2 : 0)) & 0x7FFF8);
> @@ -1050,10 +1076,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 + fcs_trailer) {
> 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++;
> + }
> /* Next RX Packet Descriptor */
> pkt_desc_ptr++;
> continue;
> }
[Severity: Medium]
When NETIF_F_RXALL is enabled, frames with !(pkt_desc & AX179A_RX_PD_RX_OK)
or (pkt_desc & AX179A_RX_PD_DROP) bypass this discard block and reach
ax88179a_rx_checksum(). Can those corrupted frames be marked
CHECKSUM_UNNECESSARY and skip error accounting?
drivers/net/usb/ax88179a_devices.c:ax88179a_rx_checksum() {
...
skb->ip_summed = CHECKSUM_NONE;
/* checksum error bit is set */
if (pkt_desc & AX179A_RX_PD_L4_ERR || pkt_desc & AX179A_RX_PD_L3_ERR)
return;
pkt_type = pkt_desc & AX179A_RX_PD_L4_TYPE_MASK;
/* It must be a TCP or UDP packet with a valid checksum */
if (pkt_type == AX179A_RX_PD_L4_TCP || pkt_type == AX179A_RX_PD_L4_UDP)
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
Because ax88179a_rx_checksum() only checks AX179A_RX_PD_L4_ERR and
AX179A_RX_PD_L3_ERR, a TCP or UDP packet with an L2 CRC error accepted via
NETIF_F_RXALL can have skb->ip_summed set to CHECKSUM_UNNECESSARY. Bypassing
the discard block also means rx_crc_errors and rx_errors are never
incremented for bad-FCS packets when NETIF_F_RXALL is active.
In addition, if a frame has AX179A_RX_PD_RX_OK set and AX179A_RX_PD_DROP
clear but fails the pkt_len bounds checks, it enters the discard block and
is dropped without incrementing any error or drop counter.
>
> ax_skb = netdev_alloc_skb_ip_align(dev->net, pkt_len);
> 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 reading dev->net->features in ax88179a_rx_fixup() truncate 4 bytes of
payload from in-flight RX URBs when NETIF_F_RXALL is toggled on a live
interface?
Whether a frame in an RX URB carries a 4-byte FCS depends on whether
AX_RX_CTL_DROPCRCERR was set in hardware when the frame was received, not
on dev->net->features when the URB is later processed in BH context:
CPU0 CPU1 (<softirq>)
/* URB queued in dev->done without FCS */
__netdev_update_features()
ax88179a_set_features()
/* enables AX_RX_CTL_DROPCRCERR */
net->features |= NETIF_F_RXALL
usbnet_bh()
ax88179a_rx_fixup()
fcs_trailer = ETH_FCS_LEN
pkt_len -= fcs_trailer
<-- strips 4B of payload
Conversely, during the window after ax88179a_set_features() writes
AX_RX_CTL and before __netdev_update_features() updates dev->net->features
(or for in-flight URBs when disabling NETIF_F_RXALL or NETIF_F_RXFCS),
frames captured with an appended FCS are processed with fcs_trailer == 0,
leaving the 4-byte FCS attached and dropping full-MTU frames as oversized.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-fcs-v3-0-6c355917b17e@birger-koblitz.de?part=2
prev parent reply other threads:[~2026-12-02 17:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 17:17 [PATCH net-next v3 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-12-01 17:17 ` [PATCH net-next v3 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz
2026-12-02 17:17 ` sashiko-bot
2026-12-01 17:17 ` [PATCH net-next v3 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-12-02 17:17 ` sashiko-bot [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=sashiko-outbox-246318@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mail@birger-koblitz.de \
--cc=sashiko-reviews@lists.linux.dev \
/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