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=1796406951; b=ShOJaX5qFWzgHPdGXwvA/2EWJ7XxI2lBG7BOdfhbxTOjEfKzuviqqzUUc/QeosZ+kvQh mU/87kkF7v48aIAuF5iggPuWygHaITFCajv1L0EeK2scplAlrBVcI47togZJi0PSoz2iO S+fC0RhcticNzjZKOACleqm/31l9cG9BhnLx0gO8zWu5Vp/frKDtCTLwdI7uOxlq6wJyg XfYrFHtE34G8xK1J2K+vgOWVxBJHAvUTRy4TXRx5d+3cQBIP10PeYAX9G8pt8lQ4tR9Z4 +e7TU7pBz03QaAnpPHIOaIwSabmzQimVY+SIQueGz2sSAwiix1f3SmbVwd9PmSr31yw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796406951; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=n3p252oWJ8CcNEk08Skmx5YTJvTTiomG8GGTXjMMiwg=; b=NVhiewcUqYhi9a9Pcd70EbLjaBDaEIM7QLSu5174ed7uZxeDIqoHvM+l714B2tIpXC2+ F1EP40VmTzkT897J+d3mKSHWRwJv84DHBNJMb2wFoN6Qu1mX5m55kTP/sMgxc8nBdzhtB i0VT/MTsSFxt9kjZz1Ts69Iz4RQBt/diaNO427YGKKMB9mZLYwAIJQRRjLrDkEcHPJrri TwczWKBUlVY2vdDni2y7/3Tjel76ymCRIcM93kVrcU77b0pxM+w7iUlV0llm6zsny7HTX rEo3UC21uOz44BF58c9TZh38RJuPJgJc5Dhhv/xtWtd3tS65klJZ0Fe47OP+Yz2xW1g== 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=b1s6DrXg; 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 B63C2606A322 for ; Fri, 4 Dec 2026 17:55:51 +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=b1s6DrXg Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A6121F00A06; Fri, 4 Dec 2026 17:55:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796406951; bh=n3p252oWJ8CcNEk08Skmx5YTJvTTiomG8GGTXjMMiwg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=b1s6DrXgLbqj2A4ZoB5qn0LzcolNZ3kpvoy4wzHrCIb8LCymz7a3o3RHlRui8prGF oggThp1HvmCde/t7Fv7nAmmCJzlTsJKDiiktwK49oJML0cACJrzpIytz++Zqo7ikB6 NILKyxCiKJEMeHNQuY7wxLT2fFPW4LY3e0rs2WovLLqEBEiugho+MtVcxcwDCaSHU/ o9z+5i9JSeQ/OpKrt0hhUreWwOuOoHXv94Z7PqPmOic8IS/GLXHytoYNCuyc32gcpj ghL6iYBSH25HCWTlof5oyyt3xYFEas8topd+yeYgF5cxl5Kh+IeU2Q+T2YFMxCkxBv eB9NF1FLkODZQ== Subject: Re: [PATCH net-next v14 2/8] hsr: Use skb_clone() while adding the HSR header From: netdev-bot+sashiko@kernel.org To: bigeasy@linutronix.de Cc: netdev@vger.kernel.org, j-rameshbabu@ti.com, andrew+netdev@lunn.ch, danishanwar@ti.com, d-qiu@ti.com, davem@davemloft.net, fmaurer@redhat.com, kuba@kernel.org, neelima@ti.com, pabeni@redhat.com, praneeth@ti.com, pratheesh@ti.com, richardcochran@gmail.com, horms@kernel.org, vigneshr@ti.com, willemdebruijn.kernel@gmail.com, daniel.machon@microchip.com, edumazet@kernel.org Date: Fri, 04 Dec 2026 17:55:49 +0000 Message-ID: <179640694996.3146.70057174470778615@kernel.org> In-Reply-To: <20261203-hsr_ptp-v14-2-1511ffd4c362@linutronix.de> References: <20261203-hsr_ptp-v14-2-1511ffd4c362@linutronix.de> X-sashiko-severity: Medium Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 (1) · Low: 1 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] hsr: hsr_create_tagged_frame() retains TX timestamp flags on unowned clones - [Low] prp_create_tagged_frame() (net/hsr/hsr_forward.c) still builds tagged frames with skb_copy_expand(). Pre-existing issues: - [Medium] This problem wasn't introduced by this patch, but hsr_create_tagged_frame() returns a bare skb_clone() in two places… -- hsr: Use skb_clone() while adding the HSR header This commit replaces __pskb_copy() in hsr_create_tagged_frame() with skb_clone() followed by skb_cow_head(). This keeps skb_shared_info, and any timestamp request in it, on the HSR tagged frame. The NETIF_F_HW_HSR_TAG_INS case now shares the same clone path, and skb_postpush_data_move() and skb_reset_mac_len() move the header and metadata and update mac_len. > diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c > index 44f6d9c83180a..b183358207506 100644 > --- a/net/hsr/hsr_forward.c > +++ b/net/hsr/hsr_forward.c [ ... ] > @@ -342,33 +341,40 @@ struct sk_buff *hsr_create_tagged_frame(struct hsr_frame_info *frame, > /* set the lane id properly */ > hsr_set_path_id(frame, hsr_ethhdr, port); > return skb_clone(frame->skb_hsr, GFP_ATOMIC); > - } else if (port->dev->features & NETIF_F_HW_HSR_TAG_INS) { > - return skb_clone(frame->skb_std, GFP_ATOMIC); > } > > - /* Create the new skb with enough headroom to fit the HSR tag */ > - skb = __pskb_copy(frame->skb_std, > - skb_headroom(frame->skb_std) + HSR_HLEN, GFP_ATOMIC); > + skb = skb_clone(frame->skb_std, GFP_ATOMIC); > if (!skb) > return NULL; > - skb_reset_mac_header(skb); > > - if (skb->ip_summed == CHECKSUM_PARTIAL) > - skb->csum_start += HSR_HLEN; > + if (port->dev->features & NETIF_F_HW_HSR_TAG_INS) > + return skb; [Severity: Medium] Before this patch, __pskb_copy() went through skb_copy_header(), which only carries over the gso fields of skb_shared_info. The software tagged frames handed to the slaves therefore never had any SKBTX_* bits set. With skb_clone() that changes. __skb_clone() sets n->sk to NULL. Since frame->skb_std is still alive, skb_header_cloned() is true here, so skb_cow_head() always ends up in pskb_expand_head(). That copies the old skb_shared_info, tx_flags and tskey included, into the new private one. So the frames for SLAVE_A and SLAVE_B now reach the slave drivers with SKBTX_HW_TSTAMP still set and skb->sk == NULL. Drivers such as igb only look at the flag: drivers/net/ethernet/intel/igb/igb_main.c:igb_xmit_frame_ring() { ... if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { ... if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON && !test_and_set_bit_lock(__IGB_PTP_TX_IN_PROGRESS, &adapter->state)) { ... } The timestamp they eventually report is then thrown away by the !sk check in __skb_tstamp_tx(). Requesting SOF_TIMESTAMPING_TX_HARDWARE needs no privileges, so any socket sending over hsr0 can now take the single TX timestamp slot on both slaves for nothing. A ptp4l frame sent at the same time can then be skipped (tx_hwtstamp_skipped). "hsr: Assign a socket for cloned skbs" later in the series only calls skb_set_owner_w() when frame->req_tx_port != HSR_PT_NONE. hsr_dev_xmit() sets that only for ETH_P_1588 frames carrying the HSR_INLINE_HDR magic header. All other traffic still ends up with this combination at the end of the series. This path already owns a private skb_shared_info after skb_cow_head(). Would it make sense to clear SKBTX_ANY_TSTAMP there when the clone has no socket? Also, the commit message says skb_shared_info is shared via skb_clone() and skb_cow_head(). On this path pskb_expand_head() makes a private copy of it instead. Could that sentence be reworded? [Severity: Medium] This isn't a bug introduced by this patch, but the clone returned here still shares its head with frame->skb_std and with the clone made for the other port. The same applies to skb_clone(frame->skb_hsr) above. Is that safe, given what hsr_xmit() writes into the header afterwards? When frame->port_rcv is the master, hsr_xmit() does: net/hsr/hsr_forward.c:hsr_xmit() { ... if (frame->port_rcv->type == HSR_PT_MASTER) { hsr_addr_subst_dest(frame->node_src, skb, port); ... ether_addr_copy(eth_hdr(skb)->h_source, port->dev->dev_addr); } ... } hsr_addr_subst_dest() rewrites h_dest for only one of the ports: net/hsr/hsr_framereg.c:hsr_addr_subst_dest() { ... if (port->type != node_dst->addr_B_port) return; if (is_valid_ether_addr(node_dst->macaddress_B)) ether_addr_copy(eth_hdr(skb)->h_dest, node_dst->macaddress_B); } The h_source writes look harmless, because hsr_dev_finalize() gives both slaves the same MAC address. The h_dest substitution is per port, though. Take a slave with NETIF_F_HW_HSR_TAG_INS but without NETIF_F_HW_HSR_DUP, and a unicast destination node with a valid macaddress_B on SLAVE_B. Could port A's frame, still queued, go out with port B's macaddress_B as its destination? Taps that share the head would also see the rewritten addresses. The comment above hsr_create_tagged_frame() says "Otherwise, create a private frame especially tagged for 'port'", but only the non-offloaded path provides that. Should these clones also get a private header before they are returned? [ ... ] > /* skb_put_padto free skb on error and hsr_fill_tag returns NULL in > * that case > */ > return hsr_fill_tag(skb, frame, port, port->hsr->prot_version); > +err: > + kfree_skb(skb); > + return NULL; > } > > struct sk_buff *prp_create_tagged_frame(struct hsr_frame_info *frame, [Severity: Low] prp_create_tagged_frame() still builds its tagged frame with skb_copy_expand(): skb = skb_copy_expand(frame->skb_std, skb_headroom(frame->skb_std), skb_tailroom(frame->skb_std) + HSR_HLEN, GFP_ATOMIC); skb_copy_expand() ends in skb_copy_header(), which copies only gso_size, gso_segs and gso_type from skb_shared_info. Doesn't that mean PRP frames still lose the SKBTX_* tx_flags and tskey, the same loss this commit fixes for HSR? A later patch in the series, "hsr: Assign a socket for cloned skbs", says PRP is left out on purpose: "This does not consider PRP part of the stack. The specification says that PTP-PRP packets do not have the RCT therefore these packets can be sent directly from userland skipping the stack." PRP also adds an RCT trailer rather than an HSR header, so it is outside the scope of this patch. Could the commit message say that PRP is intentionally left unchanged? -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-hsr_ptp-v14-0-1511ffd4c362%40linutronix.de