🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27057

Re: [PATCH net-next v14 2/8] hsr: Use skb_clone() while adding the HSR header

#27057
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 17:55
186 lines
15261 bytes
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
Technical Details
Message-ID: <179640694996.3146.70057174470778615@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377518-linux-kernel-netdev=dewy.ru
References: <20261203-hsr_ptp-v14-2-1511ffd4c362@linutronix.de>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-377518-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v14 2/8] hsr: Use skb_clone() while adding the HSR header
Date: Fri, 04 Dec 2026 17:55:49 +0000
Organization: Usenet Network
Message-ID: <179640694996.3146.70057174470778615@kernel.org>
References: <20261203-hsr_ptp-v14-2-1511ffd4c362@linutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2825997"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:2/ngegDu+lniV7P7oUR8Io3y4QE= sha256:Swc/81nf1WOVXYq+Beh5fA9uyj8XTOF+mHUyjupQw3k=
	sha1:PY8GJ/57nCP9vmqLXQ7AfLogW64= sha256:P4ON6NmJW8lYoVrlsTEnsO4OnilKChYfEAxsTH5ZDn0=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 45796117C8A; Fri,  4 Dec 2026 21:04:27 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.541
X-Spam-Status: No, score=-3.541 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.142, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id QQY4sJfKjLS4;
	Fri,  4 Dec 2026 21:04:23 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377518-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 85070117C89; Fri,  4 Dec 2026 21:04:18 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 0FBBA67239; Fri,  4 Dec 2026 17:55:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796406952;
	b=RUJLy7QWcV6G7U1tPHqDWkJgiZYy7eXyIuX28ZmXPaA0BgWnnbxnsKAz/5OCS+k0naTE
	 xN2GsZq2GT5qawAlG9L4YldbFTN47T1EdxC92+iSjq5U4O+xgrV/XZvdbFdZzacrcHVo/
	 VmlY0bCnW7BZle0cD26fZuMen49oxaHYrhyk7CVHoZ4Hn9Xp1aX6ZtmVVwxM9ITOFKtln
	 bEY4VO4FDAYJ00E/oGBNYvLqQrsz7oWyHL/5mwYk29dnxIih37lRpWErSpJNdXYbdSjou
	 YLEywy4ICK5oQZm/8entVEHcbNjNAPnFGphAOUFFMznlGYBFYO/IfJvmJeDa4Y5dftQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796406952;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=n3p252oWJ8CcNEk08Skmx5YTJvTTiomG8GGTXjMMiwg=;
	b=aqtO8pyG2k1t7AWj79IU9VPNblXYfhGJDZSolWNQvtFzI75gRmxzrmFTrp9wdaS/UHI2
	 wQzcmTjwUBL6iMqdYKJa6lTokV7JgfF5iSbEM9r98NRols5lOQ4DMwBwKdsVKb6t5Rkdk
	 d2qTlsQkt9u4py4vhyOo/3iwOJg3RZPOkXfddr1PKPMtwGX/fiiL/CtPQyedotq2J5U2t
	 VQiWf/gL/HwLI0lwqeab6E0Xk5gL4qP+CSgYI2dF6XOAsj0FlUdlzb2sbBhV8DCRV+iv8
	 rup1pPB9Ik2PZKOVjnBcd3uNMyCNT8CtuXqg+6CDTiPoA2vI3C4I9v+oXB6llrlkJAQ==
X-ARC-Authentication-Results: i=2; 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=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 964F4606A338;
	Fri,  4 Dec 2026 17:55:52 +0000 (UTC)
X-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
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-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==
X-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==
X-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
X-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 <netdev@vger.kernel.org>; Fri,  4 Dec 2026 17:55:51 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A6121F00A06;
	Fri,  4 Dec 2026 17:55:50 +0000 (UTC)
X-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==
X-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
X-In-Reply-To: <20261203-hsr_ptp-v14-2-1511ffd4c362@linutronix.de>
X-sashiko-severity: Medium
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list