From: sashiko-bot@kernel.org
To: "Birger Koblitz" <mail@birger-koblitz.de>
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH net-next 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A
Date: Sat, 28 Nov 2026 06:37:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-238500@kernel.org> (raw)
In-Reply-To: <20261127-fcs-v1-2-0c4ede015bf5@birger-koblitz.de>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] net: usb: ax88179: 32-bit truncation of features in
ax88179a_rx_fixup()
- [Medium] net: usb: ax88179: unwanted FCS appended on RXALL in
ax88179a_rx_fixup()
- [Medium] net: usb: ax88179: unsynchronized rxctl update in
ax88179a_set_features()
- [Low] net: usb: ax88179: incomplete CRC error stats in
ax88179a_rx_fixup()
--
commit 1060139744fbd9f7c43f8f37047d38dafe16412f
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,
adjusts the RX length check for the trailing FCS, and updates RX drop and
CRC error statistics in ax88179a_rx_fixup().
> diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179a_devices.c
> index 69095110e7043..a6b35ad7d5404 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,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);
> + ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, rxctl);
> + }
> +
> return 0;
> }
[Severity: Medium]
Can this unlocked update to ax179_data->rxctl and AX_RX_CTL race with
ax88179_set_multicast() and ax88179a_mac_link_up()?
__netdev_update_features() calls ndo_set_features() before assigning
net->features = features, while ax88179_set_multicast() runs under
netif_addr_lock_bh(net) without rtnl_lock and rebuilds rxctl from
net->features:
CPU0 CPU1
__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()
ax88179_set_multicast()
reads old net->features
WRITE_ONCE(data->rxctl, rxctl)
ax88179_write_cmd_async(...)
<-- reverts AX_RX_CTL_DROPCRCERR
net->features = features
If ax88179_set_multicast() instead runs between READ_ONCE() and
WRITE_ONCE() in ax88179a_set_features(), ax88179a_set_features()
overwrites the new multicast bits in rxctl. In addition,
ax88179a_mac_link_up() runs from the phylink workqueue under
ax179_data->medium_status_mutex without rtnl_lock, temporarily writing
AX_RX_CTL_STOP to AX_RX_CTL before restoring ax179_data->rxctl, so an
unsynchronized ax88179_write_u16() here can re-enable RX in the middle of
link configuration.
[ ... ]
> @@ -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);
> + long 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;
[Severity: High]
Does storing dev->net->features in a long truncate away NETIF_F_RXFCS and
NETIF_F_RXALL on 32-bit architectures?
netdev_features_t is u64, with NETIF_F_RXFCS at bit 43 and NETIF_F_RXALL
at bit 44. On 32-bit platforms a long is 32 bits, so features never has
either bit set: fcs_trailer remains 0 even though AX_RX_CTL_DROPCRCERR
causes the hardware to append the 4-byte FCS, dropping full-MTU frames as
oversized and still discarding errored frames when NETIF_F_RXALL is
enabled. Declaring features as netdev_features_t avoids the truncation.
[Severity: Medium]
When NETIF_F_RXALL is enabled without NETIF_F_RXFCS, does this deliver an
unwanted 4-byte FCS at the end of every received skb?
Setting AX_RX_CTL_DROPCRCERR for NETIF_F_RXALL causes the AX88179A to
append the 4-byte FCS to received frames, and ax88179a_rx_fixup() copies
all pkt_len bytes into ax_skb without stripping ETH_FCS_LEN when
NETIF_F_RXFCS is off.
> 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 +1074,18 @@ 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++;
> +
> /* Next RX Packet Descriptor */
> pkt_desc_ptr++;
> continue;
[Severity: Low]
Should CRC errors also increment dev->net->stats.rx_errors and be counted
when NETIF_F_RXALL is enabled?
Because ax88179a_info sets FLAG_MULTI_PACKET and ax88179a_rx_fixup() skips
bad sub-packets with continue before returning 1, usbnet's rx_process()
does not increment dev->net->stats.rx_errors for them, leaving
rx_crc_errors unreflected in the total rx_errors count. Also, because the
check is inside the !(features & NETIF_F_RXALL) discard branch, frames
with bad CRC received while NETIF_F_RXALL is enabled are not counted in
rx_crc_errors at all.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261127-fcs-v1-0-0c4ede015bf5@birger-koblitz.de?part=2
next prev parent reply other threads:[~2026-11-28 6:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-27 6:36 [PATCH net-next 0/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-11-27 6:36 ` [PATCH net-next 1/2] net: usb: ax88179: Make receiving FCS on AX88179A configurable Birger Koblitz
2026-11-28 6:42 ` netdev-bot+sashiko
2026-11-28 17:54 ` Andrew Lunn
2026-11-27 6:36 ` [PATCH net-next 2/2] net: usb: ax88179: Support NETIF_F_RXFCS and NETIF_F_RXALL on AX88179A Birger Koblitz
2026-11-28 6:37 ` sashiko-bot [this message]
2026-11-28 6:42 ` netdev-bot+sashiko
2026-11-28 6:37 ` [PATCH net-next 0/2] " sashiko-bot
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-238500@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