]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
xsk: clear metadata pointer when no timestamp is requested
authorStanislav Fomichev <sdf.kernel@gmail.com>
Mon, 27 Jul 2026 16:19:56 +0000 (09:19 -0700)
committerJakub Kicinski <kuba@kernel.org>
Mon, 3 Aug 2026 23:43:53 +0000 (16:43 -0700)
commit9f60a67df8d3c862503bee62bada8e7089cba438
tree118018fdbdc9375cf8ee676e462efcd19296088f
parent19366db6dfccac9b0867a151678cd7b89fb8fd99
xsk: clear metadata pointer when no timestamp is requested

User space can change metadata flags after request processing. Rereading
them during completion can therefore make the kernel write a timestamp
that was not requested when the packet was submitted.

Clear the metadata pointer during request processing unless timestamp
completion is requested. Completion handling can then use the pointer
itself instead of rereading the flags.

On the mlx5 multi-packet WQE path metadata is evaluated per batch:
xsk_tx_metadata_request() runs only for the descriptor that starts a
session, just like the checksum offload that is applied once through the
shared WQE. Only that descriptor's pointer is reset, so completion
handling can record a timestamp for the other descriptors of the session
regardless of their own XDP_TXMD_FLAGS_TIMESTAMP bit. The write stays
inside the metadata area; the single-WQE, other zero-copy, and generic
paths reset the pointer per descriptor and are unaffected.

Fixes: ca4419f15abd ("xsk: Add launch time hardware offload support to XDP Tx metadata")
Cc: Cen Zhang (Microsoft) <blbllhy@gmail.com>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20260727161959.885642-4-sdf@fomichev.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/net/xdp_sock.h
net/xdp/xsk.c