Skip to content

bpf: fix sock_ops rtt_min OOB read

Werner Kasselman bpf linux-kselftest lkml netdev stable 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 1 replyIn review
  2. v23 patches 0 repliesSuperseded 1 of 3 applied

Changes in v3 from the cover letter

- drop the overlapping dst_reg == src_reg fix, now upstream as 10f86a2a5c91
- keep only the helper extraction plus the rtt_min fix
- add an rtt_min subtest on top of the landed sock_ops_get_sk selftest

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: extract SOCK_OPS_LOAD_TCP_SOCK_FIELD from SOCK_OPS_GET_FIELDnet/core/filter.c+12 -70 replies
2/2bpf: guard sock_ops rtt_min against non-locked tcp_socknet/core/filter.c tools/testing/selftests/bpf/prog_tests/sock_ops_get_sk.c tools/testing/selftests/bpf/progs/sock_ops_get_sk.c+45 -71 reply

Reviews trailers per patch

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

Read the v3 thread

Cover letter [PATCH bpf v3 0/2] bpf: fix sock_ops rtt_min OOB read

Patch 1 from v2 is upstream as 10f86a2a5c91 ("bpf: Fix same-register dst/src OOB read and pointer leak in sock_ops"), so this reroll keeps only the remaining work for ctx->rtt_min.

Patch 1 extracts the guarded field-load sequence out of SOCK_OPS_GET_FIELD() so the rtt_min sub-field access can reuse the same is_locked_tcp_sock guard and dst_reg == src_reg handling without open-coding it again.

Patch 2 uses that helper for rtt_min and extends the landed sock_ops_get_sk selftest with an rtt_min subtest covering the request_sock-backed !fullsock path.

Changes since v2:
- drop the overlapping dst_reg == src_reg fix, now upstream as 10f86a2a5c91
- keep only the helper extraction plus the rtt_min fix
- add an rtt_min subtest on top of the landed sock_ops_get_sk selftest

Werner Kasselman (2):
bpf: extract SOCK_OPS_LOAD_TCP_SOCK_FIELD from SOCK_OPS_GET_FIELD
bpf: guard sock_ops rtt_min against non-locked tcp_sock

 net/core/filter.c                             | 31 ++++++++++---------
 .../bpf/prog_tests/sock_ops_get_sk.c          |  9 ++++++
 .../selftests/bpf/progs/sock_ops_get_sk.c     | 31 +++++++++++++++++++
 3 files changed, 57 insertions(+), 14 deletions(-)
Signature · 1 line
2.43.0