Skip to content

bpf, skmsg: fix verdict sk_data_ready racing with ktls rx

Xingwang Xiang bpf netdev 1 version Applied

Status from this message: This series was applied to netdev/net.git (main)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v5 Latest2 patches 0 repliesApplied 2/2

Patches in v5 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf, skmsg: fix verdict sk_data_ready racing with ktls rxnet/core/skmsg.c+7 -20 repliesApplied
2/2selftests/bpf: add regression test for ktls+sockmap verdict UAFtools/testing/selftests/bpf/prog_tests/sockmap_ktls.c tools/testing/selftests/bpf/progs/test_sockmap_ktls.c+124 -00 repliesApplied

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH net v5 0/2] bpf, skmsg: fix verdict sk_data_ready racing with ktls rx

sk_psock_verdict_data_ready() lacks the tls_sw_has_ctx_rx() guard that sk_psock_strp_data_ready() gained in e91de6afa81c. When a socket is inserted into a sockmap (BPF_SK_SKB_VERDICT) before TLS RX is configured, the missing guard causes tcp_read_skb() to drain sk_receive_queue without advancing copied_seq, leaving a dangling frag_list pointer that tls_decrypt_sg() walks — a use-after-free.

Patch 1 mirrors the fix from e91de6afa81c: add the tls_sw_has_ctx_rx() check to sk_psock_verdict_data_ready() so that when a TLS RX context is present the function defers to psock->saved_data_ready (sock_def_readable) instead of calling tcp_read_skb().

Patch 2 adds a selftest that drives the vulnerable sequence end-to-end and verifies recv() returns the correct decrypted data.

Xingwang Xiang (2):
bpf, skmsg: fix verdict sk_data_ready racing with ktls rx selftests/bpf: add regression test for ktls+sockmap verdict UAF

 net/core/skmsg.c                              |   9 +-
 .../selftests/bpf/prog_tests/sockmap_ktls.c   | 103 ++++++++++++++++++
 .../selftests/bpf/progs/test_sockmap_ktls.c   |  21 ++++
 3 files changed, 131 insertions(+), 2 deletions(-)