lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251103103442.180270-1-mlichvar@redhat.com>
Date: Mon,  3 Nov 2025 11:34:36 +0100
From: Miroslav Lichvar <mlichvar@...hat.com>
To: netdev@...r.kernel.org
Cc: Miroslav Lichvar <mlichvar@...hat.com>,
	"Jason A. Donenfeld" <Jason@...c4.com>,
	Willem de Bruijn <willemb@...gle.com>
Subject: [PATCH net-next v2] wireguard: queuing: preserve napi_id on decapsulation

The socket timestamping option SOF_TIMESTAMPING_OPT_PKTINFO needs the
skb napi_id in order to provide the index of the device that captured
the hardware receive timestamp. However, wireguard resets most of the
skb headers, including the napi_id, which prevents the timestamping
option from working as expected. The missing index prevents applications
that rely on it (e.g. chrony) from processing hardware receive
timestamps (unlike with transmit timestamps looped back to the error
queue, where the IP_PKTINFO index identifies the device that captured
the timestamp).

Preserve the napi_id in wg_reset_packet() of received packets in order
to make the timestamping option useful with wireguard tunnels and enable
highly accurate synchronization.

Cc: Jason A. Donenfeld <Jason@...c4.com>
Cc: Willem de Bruijn <willemb@...gle.com>
Signed-off-by: Miroslav Lichvar <mlichvar@...hat.com>
---

Notes:
    v2:
    - don't copy napi_id if only CONFIG_XPS is defined
    - improve commit message

 drivers/net/wireguard/queueing.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireguard/queueing.h b/drivers/net/wireguard/queueing.h
index 79b6d70de236..a5b76cecf429 100644
--- a/drivers/net/wireguard/queueing.h
+++ b/drivers/net/wireguard/queueing.h
@@ -75,6 +75,7 @@ static inline bool wg_check_packet_protocol(struct sk_buff *skb)
 
 static inline void wg_reset_packet(struct sk_buff *skb, bool encapsulating)
 {
+	unsigned int napi_id = skb_napi_id(skb);
 	u8 l4_hash = skb->l4_hash;
 	u8 sw_hash = skb->sw_hash;
 	u32 hash = skb->hash;
@@ -84,6 +85,10 @@ static inline void wg_reset_packet(struct sk_buff *skb, bool encapsulating)
 		skb->l4_hash = l4_hash;
 		skb->sw_hash = sw_hash;
 		skb->hash = hash;
+	} else {
+#ifdef CONFIG_NET_RX_BUSY_POLL
+		skb->napi_id = napi_id;
+#endif
 	}
 	skb->queue_mapping = 0;
 	skb->nohdr = 0;
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ