Skip to content

net/tls: fix UAF when TLS_RX is set on sockmap socket

Xingwang Xiang bpf netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v4 Latest2 patches 4 repliesIn review

Patches in v4 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2net/tls: reject TLS_RX setsockopt on psock-owned socketsnet/tls/tls_main.c+9 -00 replies
2/2selftests: bpf: add test for KTLS+sockmap reverse-order UAFtools/testing/selftests/bpf/prog_tests/sockmap_ktls.c tools/testing/selftests/bpf/progs/test_sockmap_ktls.c+130 -00 replies

Reviews trailers per patch

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

Read the v4 thread

Cover letter [PATCH net v4 0/2] net/tls: fix UAF when TLS_RX is set on sockmap socket

This series fixes a use-after-free triggered by configuring TLS RX on a socket that is already inserted into a sockmap (the reverse of the order that is already guarded against by tcp_bpf_check_ulp).

Patch 1 adds the symmetric check to do_tls_setsockopt_conf: if a psock is already attached when TLS_RX is requested, return -EBUSY before any strparser state is touched.

Patch 2 adds a regression test to the KTLS selftest suite that drives the vulnerable setup and verifies the kernel either rejects the combination or handles it correctly end-to-end.

Xingwang Xiang (2):
net/tls: reject TLS_RX setsockopt on psock-owned sockets
selftests: bpf: add test for KTLS+sockmap reverse-order UAF

 net/tls/tls_main.c                            |   9 ++
 .../selftests/bpf/prog_tests/sockmap_ktls.c   | 109 ++++++++++++++++++
 .../selftests/bpf/progs/test_sockmap_ktls.c   |  21 ++++
 3 files changed, 139 insertions(+)
Signature · 1 line
2.54.0