๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27054

Re: [PATCH net-next v14 6/8] hsr: Assign a socket for cloned skbs

#27054
From: netdev-bot+sashiko
Date: Fri, 04 Dec 2026 17:55
143 lines
13444 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

Critical: 0 ยท High: 0 ยท Medium: 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] A PRP device now delivers a TX timestamp for a PTP frame only
  when has_hsr_header=1; with has_hsr_header=0 it silently drops it.
- [Low] Both call sites added by this patch give clones a socket only
  when the frame came through the new PTP inline header.

--

hsr: Assign a socket for cloned skbs

This patch gives skbs cloned in hsr_create_tagged_frame() and in the
has_hsr_header branch of hsr_forward_do() the socket of the original skb.
skb_clone() clears skb->sk and hsr_forward_skb() frees the original.
Without this change, skb_tstamp_tx() has no socket to report the requested
TX timestamp to.

> diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c
> index 1d1d75ed8cd06..9cb3297a8640a 100644
> --- a/net/hsr/hsr_forward.c
> +++ b/net/hsr/hsr_forward.c

[ ... ]

> @@ -347,6 +348,9 @@ struct sk_buff *hsr_create_tagged_frame(struct hsr_frame_info *frame,
>  	if (!skb)
>  		return NULL;
>  
> +	if (frame->req_tx_port != HSR_PT_NONE && frame->skb_std->sk)
> +		skb_set_owner_w(skb, frame->skb_std->sk);
> +

[Severity: Low]
This isn't a bug, but the subject ("hsr: Assign a socket for cloned
skbs") and the last paragraph ("Assign the socket of the original skb to
the clone") suggest that every HSR clone is now owned by a socket.

The socket is only assigned when the frame came in through the new PTP
inline header. Normal HSR traffic still gets clones with no owner. Could
the changelog mention that restriction?

The two sites also use different conditions. This one checks
frame->req_tx_port, while the hsr_forward_do() site below checks
frame->has_hsr_header. Both are meant to cover frames from the PTP inline
header.

That only works because hsr_ptp_parse_header() is the only place that sets
either field. It rejects frames without skb->sk, and it rejects any
req_tx_port other than HSR_PT_SLAVE_A or HSR_PT_SLAVE_B:

net/hsr/hsr_device.c:hsr_ptp_parse_header() {
    ...
	if (!skb->sk)
		return -EINVAL;
    ...
	*has_hsr_header = !!hsr_inline_hdr->has_hsr_header;
	*req_tx_port = hsr_inline_hdr->req_tx_port;
	if (*req_tx_port != HSR_PT_SLAVE_A && *req_tx_port != HSR_PT_SLAVE_B)
		return -EINVAL;
    ...
}

If a later change sets one of these fields without the other, the two
checks would no longer agree. Would a single shared condition be easier
to keep consistent?

>  	if (port->dev->features & NETIF_F_HW_HSR_TAG_INS)
>  		return skb;
>  

[ ... ]

> @@ -582,6 +586,8 @@ static void hsr_forward_do(struct hsr_frame_info *frame)
>  		 */
>  		if (frame->has_hsr_header && frame->skb_std) {
>  			skb = skb_clone(frame->skb_std, GFP_ATOMIC);
> +			if (skb && frame->skb_std->sk)
> +				skb_set_owner_w(skb, frame->skb_std->sk);
>  			goto inject_into_stack;
>  		}

[Severity: Medium]
The changelog says:

    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.

Is that accurate? This branch of hsr_forward_do() runs for both HSR and
PRP devices.

Neither hsr_dev_xmit() nor hsr_ptp_parse_header() checks
hsr->prot_version. A PRP device therefore accepts struct
hsr_inline_header with req_tx_port set to port A or B. For ETH_P_1588 it
also requires that header.

With has_hsr_header=1 on a PRP device, prp_fill_frame_info() finds no RCT
and calls handle_std_frame(). That sets skb_std, so this branch is taken.
The clone gets skb_set_owner_w() and the timestamp reaches the user.

With has_hsr_header=0 on the same device, hsr_forward_do() calls
hsr->proto_ops->create_tagged_frame(), which is prp_create_tagged_frame():

net/hsr/hsr_forward.c:prp_create_tagged_frame() {
    ...
	} else if (port->dev->features & NETIF_F_HW_HSR_TAG_INS) {
		return skb_clone(frame->skb_std, GFP_ATOMIC);
	}

	skb = skb_copy_expand(frame->skb_std, skb_headroom(frame->skb_std),
			      skb_tailroom(frame->skb_std) + HSR_HLEN,
			      GFP_ATOMIC);
	return prp_fill_rct(skb, frame, port);
}

Neither of these paths assigns an owner. skb_tstamp_tx() then has no
socket, so the requested timestamp is silently lost. The frame also gets
an RCT appended, and the changelog says PTP-PRP frames should not carry
one.

After this patch, hsr_create_tagged_frame() and the shared has_hsr_header
branch both set the owner for req_tx_port frames.
prp_create_tagged_frame() is the only req_tx_port transmit path that
doesn't. On PRP, whether the timestamp arrives therefore depends on the
HSR-named has_hsr_header flag.

Should hsr_ptp_parse_header() reject the inline header on PRP_V1 devices?
Alternatively, should prp_create_tagged_frame() handle req_tx_port frames
the same way hsr_create_tagged_frame() now does? If neither, could the
changelog at least describe what happens on PRP?

-- 
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261203-hsr_ptp-v14-0-1511ffd4c362%40linutronix.de
Technical Details
Message-ID: <179640695518.3146.18120858440869969765@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-377521-linux-kernel-netdev=dewy.ru
References: <20261203-hsr_ptp-v14-6-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-377521-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v14 6/8] hsr: Assign a socket for cloned skbs
Date: Fri, 04 Dec 2026 17:55:55 +0000
Organization: Usenet Network
Message-ID: <179640695518.3146.18120858440869969765@kernel.org>
References: <20261203-hsr_ptp-v14-6-1511ffd4c362@linutronix.de>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2823614"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:XIUst6DUGkkdjf1s5AUzF9zCiRQ= sha256:rdkk9jxgH9pk46LiuD2OlZsyf1033VkTRKEQXlh4Bvo=
	sha1:oMmzsAVt6iDHTxk8JPHJKZ7R6JI= sha256:bORQbKqoL51wE+PdinNl7hdsgdA1eogOHDe3KOVlJEs=
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 EAB14117C79; Fri,  4 Dec 2026 20:56:16 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.542
X-Spam-Status: No, score=-3.542 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] 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 afh4HDjhEJGx;
	Fri,  4 Dec 2026 20:56:13 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-377521-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 DFFA2117C76; Fri,  4 Dec 2026 20:56:04 +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 0453880FCA; Fri,  4 Dec 2026 17:55:58 +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=1796406957;
	b=11DAJrdG/sNdtOOh5CTAj1j5Mj8yPc0wNy8kUl3JC/EdDSa8IkKLgqHuAT5ufEW8RSB+
	 yyNmT0AeM6JRxlfbtg9VsWA5JcmEO6J/QwIgU1Do/ABy+Iy8dUFoF+5hdTpyRsrpLye1g
	 ywHI/gW7owHZFbCLREMSQlUjQKujAnCd0h2QEf6jq0wgZnEBkveaZ4JC+c8uSTsl34G0m
	 8Nm5pYYxYxRgl9IZn9Ls2/A0RaWOkTtZGFBgWpIdjXwJYdK5ZH7JEZLaymXMzdBd6REhd
	 Na70dKiFmf08YdG8az9vEW4ITmWypWDFskYQALDiOyMbaDnzFqodCK75lr2CdGU9h7g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796406957;
	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=D8I8oTNf0zhOX6+fvKWfJjlRDfSgFOnvGsg24ZFnVbY=;
	b=nXz+w4zjl3eJGLQzTNMTeXUup0AY4EqT0LSZa9MVQRIGSRcH5uw9dxXuIrQ+Ku9sxUJb
	 QNqVp7mnWE7LEwtRDCq578h9uTqNlF5bJJGThAMyfJF7t0pv42lQdaIdUdPyeQmh+PrFt
	 11/gpAFsX6AniiImEDjYhOVTXVbUZycoUmbPiGTY4yoV5dsk3B54pYPm2MoDPGZBjWuqe
	 WJo7K5xNLawQtF8SVc7Uw1I5L1WDxRnYwo4IUb1oAUOK/+F+tMYXEvnfVoPee2+uANK50
	 /3nTGJOZB5ZcMkd0Qk7l8nCptM9I2V6pCYbY25XwMGqckAubt+a13xq7Gv2uC73gjIQ==
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=G8iOvrK8;
	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 C74E0606A336;
	Fri,  4 Dec 2026 17:55:57 +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=G8iOvrK8
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=1796406957;
	b=lV79hebZ92bDScFhmVgTnJucFI/egGYyUNK2ss7Bsa1h+qioFmClB0+yBoF/8rM/TpSX
	 qa+dpvCJyRSAtnj1aIL95nfvyHtBn2tXqz7HGl2AhJhmCG9eZiTM2xttHVtfEBLUxgT4w
	 U9F8p/b62MsI/LSxbKs3CmPpRNSg33DDV/zSVIX8faBJGRYYmr+xCGo9816a2XfaKnnNr
	 EX3GhdhLQwMspqPQI6ktL7Q+ra5UvViERPrz+oq97B86mAmdQPIfjQK3A/9+0JJn4nTTv
	 Mn3IiBFiDL8cHbSBplnrygHhwdOJ8N+BGQyLDUaVTztxZXZMu1W0iOOsaZM2lp3jsXw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796406957;
	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=D8I8oTNf0zhOX6+fvKWfJjlRDfSgFOnvGsg24ZFnVbY=;
	b=pmnAr/wd67PgEpC7YOq4sfooWcNVGBWkgmyNAPrHM59pvmJGW+UMJ7A6BcZwnqTqkWZ8
	 mqzf8SOyZrc5YAzkcWG7TvFKdfLUQf1GnvaJybXD5TfrfwevZJP1Vchl71/BwUhlsAXBU
	 l15R5LoC3xX2RXzW6pmKRCmb07uuuNgoHIjy13IETuFRfroPh79YCL8h09LKuUFISeBa4
	 jnjllBD05FW/zfBBExOQ67Yu6ooOu8lcoTZ+8Qh88oVrYPZ0TLCKpKbhWkrj5k49Fu06T
	 UERyphmidE4+0/uioq+fPpTL1yR429po0zfJCKhk+LGWWq2E0/5FauSTWi+NDqnjSyg==
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=G8iOvrK8;
	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 E5F27606A335
	for <netdev@vger.kernel.org>; Fri,  4 Dec 2026 17:55:56 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 932201F00936;
	Fri,  4 Dec 2026 17:55:55 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796406956;
	bh=D8I8oTNf0zhOX6+fvKWfJjlRDfSgFOnvGsg24ZFnVbY=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=G8iOvrK8LDO2zwzi6c/5+Kb2lMaiAYCQHt7p+nFeBH/mmRXLeddk0AWLlnKML/1jg
	 4XnDs1F/egmyrYB6PDoHkYhJzqYgwOMrhWFmxFUpjYPPmt3iZ72039fmGJyyzQIebf
	 nxUjn8Zvk5/igHoCkCbAq8nVxawsOJ0Vxja9NEQ5GCKXO8hPJ3/dPI0xfk6oZ8cpSx
	 XS4KYKgKgpenGDgUNMsmqZRO6umKNVEeGMOpm6eyGWrPrUcNxrINkJ1b+Rj9UGxpQa
	 kV03LWtSYmmnW4yRHd60OzeZ+kdnvvMt3wLFKqE64++kuCK+Ki87XnttTfjZB5O/Ih
	 DEYetAqX0psgg==
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-6-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