milos-linux/net/xdp
Jason Xing 22ba97ea9c xsk: cache csum_start/csum_offset to fix TOCTOU in xsk_skb_metadata()
The TX metadata area resides in the UMEM buffer which is memory-mapped
and concurrently writable by userspace. In xsk_skb_metadata(),
csum_start and csum_offset are read from shared memory for bounds
validation, then read again for skb assignment. A malicious userspace
application can race to overwrite these values between the two reads,
bypassing the bounds check and causing out-of-bounds memory access
during checksum computation in the transmit path.

Fix this by reading csum_start and csum_offset into local variables
once, then using the local copies for both validation and assignment.

Note that other metadata fields (flags, launch_time) and the cached
csum fields may be mutually inconsistent due to concurrent userspace
writes, but this is benign: the only security-critical invariant is
that each field's validated value is the same one used, which local
caching guarantees.

Closes: https://lore.kernel.org/all/20260503200927.73EA1C2BCB4@smtp.kernel.org/
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Jason Xing <kernelxing@tencent.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Fixes: 48eb03dd26 ("xsk: Add TX timestamp and TX checksum offload support")
Link: https://patch.msgid.link/20260530042630.80626-1-kerneljasonxing@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-06-03 17:45:42 -07:00
..
Kconfig
Makefile
xdp_umem.c xsk: tighten UMEM headroom validation to account for tailroom and min frame 2026-04-06 18:43:51 -07:00
xdp_umem.h
xsk.c xsk: cache csum_start/csum_offset to fix TOCTOU in xsk_skb_metadata() 2026-06-03 17:45:42 -07:00
xsk.h xsk: remove repeated defines 2026-03-16 19:28:21 -07:00
xsk_buff_pool.c xsk: reject sw-csum UMEM binding to IFF_TX_SKB_NO_LINEAR devices 2026-05-05 19:27:49 -07:00
xsk_diag.c net: change sock.sk_ino and sock_i_ino() to u64 2026-03-06 14:31:26 +01:00
xsk_queue.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
xsk_queue.h xsk: avoid double checking against rx queue being full 2026-02-24 17:11:58 -08:00
xskmap.c xskmap: reject TX-only AF_XDP sockets 2026-05-09 16:17:01 -07:00