From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796031022; b=XTidrHGqD31MbVc0HdKi50+o65aZCJYEbaQLBzb7GYFitTl6tgOagasS6gy1lXFFY+6i UNM1ZrbUJ268jBtNNYJ3lf547AjkFBDb75Pg9VvnciVWuww8OTszmzy5lq/M/QLW/GXJU YlpXj+Ya4cWtBCKWsKNgcEu28h02pC8NvO7SqpGe/PuihbJXXute6q1ZKgXOLz9a0aw8x o/1GI840PVkLC4jp31xFNZXf3k6Z2puXtU/g1apUrmrRnwvyBnNACqmt0CaNJY+0JaJ3T /D/oQnSj4cJOr7/mvU5HqLxyxKTuLI/ampXUveRuNlPx+lqUZHC0Weq+lSlD04IT6Bw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796031022; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=jalQNW7UJVzp7jkX5xK6Bk3vUVsMtEybw0wMn3/LkYk=; b=IORAQWik+Ol5PgrdMfUE1ITkjsdbVkDJkHrpGHjFTZlGl04ZLu3SAbesCvFwbrlDMdds d8nO66eWc8QTca4YELiYeI4wJVNFaQUMuMwlvXt5JuaSj5qhtaFE4mvyeQf7gzW0KAABK bwynt6g15kLCGODinC51cdFBrVMHpcGmbCjw4Vlha/ApmOKffZ+5Yar3jLi2Oeeq3Y8sI +CYd9VpDxiHcoqPgVwkqPuJ5nuDZEHDtizil3JcAlttKK5ohCArLNyzOjU8qC3vrL3d3U e2qUq586oSCSgy3cXaob4WrlhQaoP88ITHI0EEEA+zUigQPHuHr6KjWmxmR3fXWYFDg== 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=VHyVZ7wI; arc=none smtp.remote-ip=100.103.45.18 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 9BD91606A33B for ; Mon, 30 Nov 2026 09:30:22 +0000 (UTC) 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=VHyVZ7wI Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76BFC1F00897; Mon, 30 Nov 2026 09:30:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796031021; bh=jalQNW7UJVzp7jkX5xK6Bk3vUVsMtEybw0wMn3/LkYk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=VHyVZ7wI/cREhXRBX1PiVqSTcFcqEGUOFYygbfgtLZwD6thmHfBYm+euc/MgUpK/r rBDVbGcO988qfBd6Cc09T16l6b7Yj6rxVN5FPKrurEAEFEnwViNJtS+lpZAPqUN2BJ HbLKd5rGy+3+U8XhTw5s1mNoddH/+ICy2MYxCPJ4MGvmDbhQejeW+2UmSobccwWeNk pHN0hB7SZIHE/+lUT2zenuJ5pgRBxJuZZkJRxSkBVaLW2qS0m7W9oSoWULmO/J1UeP vzlDq/SNjr55qgqryXZb9xxzJxSicHm86iNXjD1sRv/SVl3/Uw6F4X/yk58VOJrrCG QoiT8vO8hWGPg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net-next 3/3] net: usb: ax88179: Enable PTP Reply-To: sashiko-reviews@lists.linux.dev To: "Birger Koblitz" Cc: linux-usb@vger.kernel.org In-Reply-To: <20261129-ptp-v1-3-8148c402beaf@birger-koblitz.de> References: <20261129-ptp-v1-0-8148c402beaf@birger-koblitz.de> <20261129-ptp-v1-3-8148c402beaf@birger-koblitz.de> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 09:30:21 +0000 X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 18 potential issues to consider: - [High] net: usb: ax88179: NULL deref on skb_clone() failure in ax88179a_tx_fixup() - [High] net: usb: ax88179: unlocked tx_skbs access and leak in ax88279_process_tx_ts() - [High] net: usb: ax88179: uninitialized ptp_hdr deref on non-PTP TX timestamp SKBs - [High] net: usb: ax88179: out-of-bounds PTP timestamp read in ax88179a_rx_fixup() - [High] net: usb: ax88179: dropped PTP packet desynchronizes ax88179a_rx_fixup() - [High] net: usb: ax88179: 32-bit shift overflow in AX179A_RX_PD_PTP macro - [High] net: usb: ax88179: UAF and NULL ptp_config() deref in ax88179a_bind() - [High] net: usb: ax88179: active PTP URB double submission on resume and link up - [High] net: usb: ax88179: urb leak and UAF race in ax88179a_unbind() - [High] net: usb: ax88179: uncanceled PTP work and phylink race in ax88179a_suspend() - [High] net: usb: ax88179: data races on ep4_buf and ptp_info_buf in ax88179a_ptp_read_ts() - [High] net: usb: ax88179: wrong array index in ax88179a_ptp_read_ts() and ax88279_read_ts_complete() - [High] net: usb: ax88179: misplaced PTP_1588_CLOCK_OPTIONAL dependency in Kconfig - [Medium] net: usb: ax88179: skb_copy_expand() drops TX timestamp in ax88179a_tx_fixup() - [Medium] net: usb: ax88179: wrong speed constants passed in ax88179a_mac_link_up() - [Medium] net: usb: ax88179: capability mismatch in ax88179a_get_ts_info() - [Medium] net: usb: ax88179: resource leaks and dangling ptp in ax88179a_ptp_register() - [Medium] net: usb: ax88179: missing cpu_to_le32 conversion on 32-bit PTP register writes -- commit 43874aad48bf8ec849f6baccb1d0f436a2536594 Author: Birger Koblitz net: usb: ax88179: Enable PTP This commit adds a ptp_enable module parameter and hooks up PTP hardware timestamping support across bind, unbind, suspend, resume, link changes, ethtool, and the RX/TX paths for AX88179A and AX88279 devices. > diff --git a/drivers/net/usb/ax88179a_devices.c b/drivers/net/usb/ax88179= a_devices.c > index 69095110e7043..994e749ffaa2b 100644 > --- a/drivers/net/usb/ax88179a_devices.c > +++ b/drivers/net/usb/ax88179a_devices.c [ ... ] > @@ -137,6 +142,9 @@ static int ax88179a_suspend(struct usb_interface *int= f, pm_message_t message) > int ret; > =20 > priv =3D dev->driver_priv; > + if (netif_running(dev->net)) > + ax88179a_ptp_kill_urbs(dev); > + > ax88179_set_pm_mode(dev, true); > =20 > if (netif_running(dev->net)) { [Severity: High] Can pending phylink or PTP work run during and after ax88179a_suspend()? ax88179a_ptp_kill_urbs() runs before phylink_suspend() and usbnet_suspend(), so phylink resolve work can call ax88179a_mac_link_up() and resubmit ptp->urb in between. On AX88179A, ax88179a_ptp_kill_urbs() is a no-op, and when priv->wolopts is set phylink_suspend() does not call ax88179a_mac_link_down(). Because ax88179a_suspend() never cancels ptp->req_tx_timestamp or ptp->process_ptp_info_buf, ax88179a_ptp_read_ts_work() can run after ax88179a_suspend() clears in_pm, issuing non-PM USB control reads on the suspended device and calling netif_device_detach() on failure. [ ... ] > @@ -232,6 +242,11 @@ static int ax88179a_resume(struct usb_interface *int= f) > =20 > ax88179_set_pm_mode(dev, false); > =20 > + if (netif_running(dev->net) && > + ax179_data->chip_version =3D=3D AX_VERSION_AX88279 && ax179_data->p= tp) { > + ax179_data->ptp->ptp_read_ts(dev); > + } > + > return usbnet_resume(intf); > } [Severity: High] Does calling ptp_read_ts() in both ax88179a_resume() and ax88179a_mac_link_up() submit ptp->urb twice on AX88279? ax88279_ptp_read_ts() reinitializes and submits the single pre-allocated ptp->urb. When ax88179a_resume() calls ptp_read_ts() and phylink also calls ax88179a_mac_link_up() (either synchronously inside phylink_resume() when WoL was active, or when link negotiation completes), ptp->urb is reinitialized and submitted while already active, triggering WARN_ONCE() in usb_submit_urb(). Also, ax88279_read_ts_complete() calls ptp->ptp_read_ts(dev) from URB completion context, which passes GFP_KERNEL to usb_submit_urb() in atomic context. And if ptp->urb is submitted here while the link is down and the interface is then stopped before link-up, ax88179a_stop() never calls ax88179a_ptp_kill_urbs(dev), leaving ptp->urb active after ndo_stop. > @@ -353,6 +368,42 @@ static int ax88179a_set_eee(struct net_device *net, = struct ethtool_keee *edata) > return phylink_ethtool_set_eee(ax179_data->phylink, edata); > } > =20 > +static int ax88179a_get_ts_info(struct net_device *net, > + struct kernel_ethtool_ts_info *info) > +{ > + struct ax88179_data *ax179_data =3D netdev2data(net); > + > + if (!ax179_data->ptp) > + return ethtool_op_get_ts_info(net, info); > + > + info->so_timestamping =3D SOF_TIMESTAMPING_TX_SOFTWARE | > + SOF_TIMESTAMPING_RX_SOFTWARE | > + SOF_TIMESTAMPING_SOFTWARE | > + SOF_TIMESTAMPING_TX_HARDWARE | > + SOF_TIMESTAMPING_RX_HARDWARE | > + SOF_TIMESTAMPING_RAW_HARDWARE; > + > + info->phc_index =3D ax179_data->ptp->phc_index; > + > + info->tx_types =3D BIT(HWTSTAMP_TX_OFF) | > + BIT(HWTSTAMP_TX_ON) | > + BIT(HWTSTAMP_TX_ONESTEP_SYNC) | > + BIT(HWTSTAMP_TX_ONESTEP_P2P); > + > + info->rx_filters =3D BIT(HWTSTAMP_FILTER_NONE) | > + BIT(HWTSTAMP_FILTER_PTP_V1_L4_EVENT) | > + BIT(HWTSTAMP_FILTER_PTP_V1_L4_SYNC) | > + BIT(HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) | > + BIT(HWTSTAMP_FILTER_PTP_V2_L4_EVENT) | > + BIT(HWTSTAMP_FILTER_PTP_V2_L4_SYNC) | > + BIT(HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) | > + BIT(HWTSTAMP_FILTER_PTP_V2_L2_EVENT) | > + BIT(HWTSTAMP_FILTER_PTP_V2_L2_SYNC) | > + BIT(HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ); > + > + return 0; > +} [Severity: Medium] Do info->tx_types and info->rx_filters match what ax88179a_hwtstamp_set() actually supports? ax88179a_hwtstamp_set() only accepts HWTSTAMP_TX_OFF and HWTSTAMP_TX_ON and returns -ERANGE for HWTSTAMP_TX_ONESTEP_SYNC and HWTSTAMP_TX_ONESTEP_P2P. It also forces any non-NONE filter to HWTSTAMP_FILTER_ALL, which is missing from info->rx_filters. [ ... ] > @@ -606,6 +672,11 @@ static void ax88179a_mac_link_up(struct phylink_conf= ig *config, > =20 > ax88179_write_u8(dev, AX_ACCESS_MAC, AX88179A_MAC_PATH, 1, > AX_MAC_RX_PATH_READY | AX_MAC_TX_PATH_READY); > + > + if (ax179_data->ptp) { > + ax179_data->ptp->ptp_config(dev, speed); > + ax179_data->ptp->ptp_read_ts(dev); > + } > } [Severity: Medium] Does ax88179a_ptp_config() expect SPEED_* values here instead of ETHER_LINK_*? ax88179a_mac_link_up() passes phylink's speed (SPEED_10, SPEED_100, SPEED_1000), which matches ax88279_ptp_config(), but ax88179a_ptp_config() switches on ETHER_LINK_10 (1), ETHER_LINK_100 (2), and ETHER_LINK_1000 (3): drivers/net/usb/ax88179a_ptp.c:ax88179a_ptp_config() { ... switch (speed) { case ETHER_LINK_10: ... case ETHER_LINK_100: ... } As a result, 10M and 100M links on AX88179A always fall through to the default 1000M TX/RX PHY delay calibration values. [Severity: High] Can ptp_read_ts() in ax88179a_mac_link_up() race with ax88179a_ptp_read_ts_work() and ax88279_process_tx_ts()? On AX88179A, phylink resolve work calls ax88179a_ptp_read_ts(dev) here while ptp->req_tx_timestamp work also calls ax88179a_ptp_read_ts(dev) concurrently, writing into the shared ptp->ep4_buf and updating ptp->ptp_info_buf and ptp->ptp_info_buf_head without any lock: CPU0 (phylink resolve) CPU1 (req_tx_timestamp / process_ptp) ax88179a_mac_link_up() ax88179a_ptp_read_ts() ax88179_read_cmd(..., ep4_buf) ax88179a_ptp_read_ts_work() ax88179a_ptp_read_ts() ax88179_read_cmd(..., ep4_buf) ptp->ptp_info_buf_head++ ax88279_process_tx_ts() match_ptp_ts() ptp_info_buf[ptp_info_buf_tail] <-- data race / out-of-bounds head ptp->ptp_info_buf_head %=3D ... On both AX88179A and AX88279, the producer updates ptp_info_buf_head with non-atomic ++ followed by %=3D AX88179A_PTP_QUEUE_SIZE without locking or barriers against match_ptp_ts() running in ptp->process_ptp_info_buf work. [Severity: High] Do ax88179a_ptp_read_ts() and ax88279_read_ts_complete() read from ptp_info[0] instead of ptp_info[i]? Both functions loop over i =3D 0..AX88179A_PTP_QUEUE_SIZE - 1 and check if (ptp_info[i].status), but copy the fields from ptp_info->... instead of ptp_info[i]: drivers/net/usb/ax88179a_ptp.c:ax88179a_ptp_read_ts() { ... if (ptp_info[i].status) { int j; j =3D ptp->ptp_info_buf_head; ptp->ptp_info_buf[j].msg_type =3D ptp_info->msg_type; ptp->ptp_info_buf[j].sequence_id =3D ptp_info->sequence_id; ptp->ptp_info_buf[j].nsec =3D le32_to_cpu(ptp_info->nsec); ptp->ptp_info_buf[j].sec =3D le16_to_cpu(ptp_info->sec_h); ptp->ptp_info_buf[j].sec <<=3D 32; ptp->ptp_info_buf[j].sec |=3D le32_to_cpu(ptp_info->sec_l); ... } Any TX timestamp delivered in queue slots 1..4 is lost and replaced with slot 0. [ ... ] > @@ -927,6 +1003,30 @@ static int ax88179a_bind(struct usbnet *dev, struct= usb_interface *intf) > */ > pm_runtime_get_noresume(&intf->dev); > =20 > + if (!ptp_enable) > + return 0; > + > + ret =3D ax88179a_ptp_register(dev); > + if (ret < 0) { > + netdev_warn(dev->net, "Failed to register PHC device. (%d)\n", ret); > + netdev_warn(dev->net, "PTP disabled\n"); > + /* Disable PTP functionality again and cycle PHY to take effect */ > + ax88179_write_cmd(dev, AX_FW_MODE, AX_FW_MODE_179A, 0, 0, NULL); > + ax88179_write_u8(dev, AX88179A_PHY_POWER, 0, 0, 0); > + msleep(50); > + return 0; > + } > + > + if (ax179_data->ptp && ax179_data->chip_version =3D=3D AX_VERSION_AX881= 79A) { > + ax179_data->ptp->ptp_config(dev, SPEED_UNKNOWN); > + > + /* Power cycle PHY to make PTP settings take effect, > + * reset() will power on the PHY again > + */ > + ax88179_write_u8(dev, AX88179A_PHY_POWER, 0, 0, 0); > + msleep(50); > + } > + > return 0; [Severity: High] Can ax88179a_ptp_register() leave ax179_data->ptp dangling or with NULL callbacks when registration fails or the hardware is unsupported? In ax88179a_ptp_register(), ax179_data->ptp =3D ax88179a_ptp is assigned on entry: drivers/net/usb/ax88179a_ptp.c:ax88179a_ptp_register() { ... ax179_data->ptp =3D ax88179a_ptp; ... case AX_VERSION_AX88179A: ... if (ax88179_read_cmd(dev, AX88179A_ACCESS_BL, AX88179A_HW_EC_VERSION, 1, 1, &ptp_ver) < 0) return 0; if (ptp_ver < 3) { netdev_warn(dev->net, "PTP on AX88179A version %d < 3 unsupported\n", ptp_ver); return 0; } ... no_ctrlreq: kfree(ax88179a_ptp->urb); err: kfree(ax88179a_ptp); return ret; } On AX88179A with ptp_ver < 3 (including AX88772D) or an EC version read failure, ax88179a_ptp_register() returns 0 before setting ptp_config, pps_ctrl, and ptp_read_ts, so ax179_data->ptp->ptp_config() in ax88179a_bind() immediately dereferences a NULL function pointer. When ax88179a_ptp_register() returns a negative error, it frees ax88179a_ptp without clearing ax179_data->ptp, and ax88179a_bind() returns 0, causing a use-after-free in every later if (ax179_data->ptp) check and a double free in ax88179a_ptp_unregister(). [Severity: Medium] Does ax88179a_ptp_register() also leak urb and ctrlreq and call kfree() on a struct urb in its error paths? In the snippet above, jumping to err after ptp_clock_register() fails (or returning early on ptp_ver < 3) leaks ax88179a_ptp->urb and ax88179a_ptp->ctrlreq, and the no_ctrlreq label frees ax88179a_ptp->urb with kfree() instead of usb_free_urb(). [Severity: High] Does linking ax88179a_ptp_register() into CONFIG_USB_NET_AX88179 fail when CONFIG_USB_NET_AX88179=3Dy and CONFIG_PTP_1588_CLOCK=3Dm? In commit "net: usb: ax88179: Add PTP support", depends on PTP_1588_CLOCK_OPTIONAL was added to config USB_NET_AX8817X instead of config USB_NET_AX88179 in drivers/net/usb/Kconfig, so a built-in ax88179 driver fails to link against modular ptp_clock_register(), ptp_clock_index(), and ptp_clock_unregister(). [Severity: Medium] Do the 32-bit register writes in ax88179a_ptp_config(), ax88179a_ptp_pps_ctrl(), ax88279_ptp_pps_ctrl(), and ax88279_ptp_pbus_write_u32() miss cpu_to_le32() conversion on big-endian hosts? ax88179_write_cmd() only byte-swaps 2-byte values (size =3D=3D 2), unlike ax88179_read_cmd() and ax88179_write_u32(). Passing a CPU-endian u32 with size 4 to ax88179_write_cmd() in those helpers sends big-endian register values over USB on big-endian systems. > @@ -946,6 +1046,8 @@ static void ax88179a_unbind(struct usbnet *dev, stru= ct usb_interface *intf) > =20 > /* Configure RX control register =3D> stop operation */ > ax88179_write_u16(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, AX_RX_CTL_STOP); > + ax88179a_ptp_kill_urbs(dev); > + ax88179a_ptp_unregister(dev); > =20 > rtnl_lock(); > phylink_disconnect_phy(ax179_data->phylink); [Severity: High] Can freeing ax179_data->ptp before phylink_disconnect_phy() cause a use-after-free in ax88179a_unbind(), and does ax88179a_ptp_unregister() leak urb on AX88179A? ax88179a_ptp_unregister() frees ax179_data->ptp without clearing ax179_data->ptp =3D NULL or cancelling ax88179a_ptp->req_tx_timestamp, and it runs before phylink_disconnect_phy() flushes phylink resolve work: CPU0 CPU1 (phylink resolve / req_tx_timestamp) ax88179a_unbind() ax88179a_ptp_unregister() kfree(ax179_data->ptp) ax88179a_mac_link_down() if (ax179_data->ptp) ax179_data->ptp->pps_ctrl(...) <-- use-after-free phylink_disconnect_phy() flush_work(&pl->resolve) In addition, ax88179a_ptp_register() allocates ax88179a_ptp->urb on both AX88279 and AX88179A, but ax88179a_ptp_unregister() only calls usb_free_urb(ax88179a_ptp->urb) on AX88279, leaking the URB on every AX88179A unbind. > @@ -1017,8 +1119,10 @@ static int ax88179a_rx_fixup(struct usbnet *dev, s= truct sk_buff *skb) > hdr_off =3D FIELD_GET(AX179A_RX_DH_DESC_OFFSET, rx_hdr); > pkt_cnt =3D rx_hdr & AX179A_RX_DH_PKT_CNT_MASK; > =20 > - /* Consistency check header position */ > - if (hdr_off !=3D skb->len - (pkt_cnt * sizeof(rx_hdr))) > + /* Consistency check header position, frames with PTP timestamps > + * have longer headers than normal frames, so check for minimum size > + */ > + if (hdr_off > skb->len - (pkt_cnt * sizeof(rx_hdr))) > goto err; [Severity: High] Can AX179A_RX_PD_PTP descriptors causepkt_desc_ptr to read past the end of the SKB in ax88179a_rx_fixup()? The pre-loop check only validates 8 bytes per packet (pkt_cnt * 8 + hdr_off <=3D skb->len), and skb_trim(skb, hdr_off) then discards the origin= al metadata end offset. When AX179A_RX_PD_PTP is set on a descriptor, the loop consumes two additional 64-bit words (++pkt_desc_ptr twice) without checking that 16 extra bytes remain in the metadata area before rx_hdr. (Also, skb->len - (pkt_cnt * sizeof(rx_hdr)) can wrap around as an unsigned subtraction when pkt_cnt * 8 > skb->len.) > @@ -1075,6 +1179,13 @@ static int ax88179a_rx_fixup(struct usbnet *dev, s= truct sk_buff *skb) > __vlan_hwaccel_put_tag(ax_skb, htons(ETH_P_8021Q), vlan_tag); > } > =20 > + if (pkt_desc & AX179A_RX_PD_PTP) { > + u64 ts_l =3D get_unaligned_le64(++pkt_desc_ptr); > + u64 ts_h =3D get_unaligned_le64(++pkt_desc_ptr); > + > + ax88179a_process_rx_ts(ax_skb, ts_l, ts_h); > + } > + > usbnet_skb_return(dev, ax_skb); > skb_pull(skb, pkt_len_plus_padd); [Severity: High] What happens if a packet with AX179A_RX_PD_PTP set hits the drop/error check earlier in the ax88179a_rx_fixup() loop? When a frame has AX179A_RX_PD_DROP set, lacks AX179A_RX_PD_RX_OK, or has an invalid length, the continue branch only increments pkt_desc_ptr by one u64 instead of skipping the two 64-bit timestamp words as well, so the next iteration misinterprets ts_l as the next packet's RX descriptor. [Severity: High] Does AX179A_RX_PD_PTP overflow on 32-bit architectures? In commit "net: usb: ax88179: Add PTP support", drivers/net/usb/ax88179_lib= .h defines AX179A_RX_PD_PTP as BIT(56) instead of BIT_ULL(56). On 32-bit builds, 1UL << 56 triggers -Wshift-count-overflow (breaking the build with CONFIG_WERROR=3Dy) and evaluates to 0. > @@ -1090,6 +1201,7 @@ static int ax88179a_rx_fixup(struct usbnet *dev, st= ruct sk_buff *skb) > =20 > static struct sk_buff *ax88179a_tx_fixup(struct usbnet *dev, struct sk_b= uff *skb, gfp_t flags) > { > + struct ax88179_data *ax179_data =3D dev->driver_priv; > u64 tx_desc =3D skb->len & AX179A_TX_DESC_LEN_MASK; > int frame_size =3D dev->maxpacket; > struct sk_buff *ax_skb; > @@ -1132,6 +1244,24 @@ static struct sk_buff *ax88179a_tx_fixup(struct us= bnet *dev, struct sk_buff *skb > } > if (padding_size !=3D 0) > skb_put_zero(skb, padding_size); > + > + if (skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP && ax179_data->ptp) { > + struct sk_buff *ptp_skb; > + > + /* Keep the original SKB owned by the socket in our > + * queue with PTP SKBs, while continuing TX with a > + * clone, so that skb_tstamp_tx() can later return > + * the TX timestamp via the socket's error channel. > + */ > + skb_shinfo(skb)->tx_flags |=3D SKBTX_IN_PROGRESS; > + ptp_skb =3D skb_clone(skb, GFP_ATOMIC); > + skb_queue_tail(&ax179_data->ptp->tx_skbs, skb); > + skb =3D ptp_skb; > + // Get the TX timestamp > + if (ax179_data->chip_version =3D=3D AX_VERSION_AX88179A) > + schedule_work(&ax179_data->ptp->req_tx_timestamp); > + } > + > /* Copy TX header */ > tx_desc_ptr =3D skb_push(skb, sizeof(tx_desc)); [Severity: High] If skb_clone() fails in ax88179a_tx_fixup(), won't skb_push() immediately dereference a NULL skb pointer? ptp_skb is not checked for NULL, so on allocation failure the original skb is queued onto ax179_data->ptp->tx_skbs, skb becomes NULL, and skb_push() crashes. [Severity: Medium] Does skb_copy_expand() earlier in ax88179a_tx_fixup() drop the socket and SKBTX_HW_TSTAMP flag before this check runs? When the outgoing skb is cloned or needs headroom or tailroom (for example, when padding_size is 8..15 bytes and exceeds needed_tailroom of 8), ax88179a_tx_fixup() replaces skb with skb_copy_expand() and frees the original socket-owned skb. Because skb_copy_expand() does not copy skb->sk or skb_shinfo(skb)->tx_flags, SKBTX_HW_TSTAMP is already cleared by the time execution reaches this check and the TX timestamp is silently lost. Even when skb_copy_expand() is not taken, skb_put_zero() mutates the length of the original skb before skb_clone(), skb_push() writes the TX descriptor into the shared head buffer of a cloned skb, and on AX88179A schedule_work(&ax179_data->ptp->req_tx_timestamp) runs before usbnet_start_xmit() has submitted the TX URB. [Severity: High] Can queuing non-PTP packets with SKBTX_HW_TSTAMP here dereference an uninitialized ptp_hdr pointer in ax88279_process_tx_ts()? ax88179a_tx_fixup() queues any SKB with SKBTX_HW_TSTAMP onto ptp->tx_skbs without checking ax179_data->ptp->tx_tstamp or classifying the packet. In ax88279_process_tx_ts(), ptp_hdr is uninitialized on the stack and is only assigned when type !=3D PTP_CLASS_NONE: drivers/net/usb/ax88179a_ptp.c:ax88279_process_tx_ts() { struct ptp_header *ptp_hdr; ... skb_queue_walk_safe(&ptp->tx_skbs, skb, tmp) { type =3D ptp_classify_raw(skb); if (type !=3D PTP_CLASS_NONE) { ptp_hdr =3D ptp_parse_header(skb, type); if (!ptp_hdr) goto frame_err; } match_ptp_ts(ptp, ptp_hdr, skb, type); } When a user sends a non-PTP packet on a socket with SOF_TIMESTAMPING_TX_HARDWARE, type is PTP_CLASS_NONE and match_ptp_ts() immediately dereferences the uninitialized (or stale) ptp_hdr pointer at ntohs(ptp_hdr->sequence_id). [Severity: High] Does ax88279_process_tx_ts() walk and unlink from ptp->tx_skbs without holding ptp->tx_skbs.lock? ax88179a_tx_fixup() enqueues with skb_queue_tail(), which takes tx_skbs.lock, while ax88279_process_tx_ts() walks ptp->tx_skbs with skb_queue_walk_safe() and unlinks entries with unlocked __skb_unlink(): CPU0 (TX path) CPU1 (process_ptp_info_buf work) ax88179a_tx_fixup() ax88279_process_tx_ts() skb_queue_tail(&ptp->tx_skbs) skb_queue_walk_safe(&ptp->tx_skbs, ...) spin_lock_irqsave(&lock) __skb_queue_tail(...) __skb_unlink(skb, &ptp->tx_skbs) <-- list corruption spin_unlock_irqrestore(&lock) Also, neither ax88179a_mac_link_down() nor ax88179a_stop() cancels ptp->process_ptp_info_buf or purges ptp->tx_skbs, leaving any queued SKBs pinned until unbind. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261129-ptp-v1-0-8= 148c402beaf@birger-koblitz.de?part=3D3