Skip to content

bpf, sockmap: fix bpf_msg_pop_data() integer overflow

Sechang Lim bpf linux-kselftest lkml netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 1 replyIn review
  2. v11 patch 3 repliesSuperseded

Changes in v2 from the cover letter

- add selftest (Cong Wang)
- change pop to u32 (Emil Tsalapatis)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf, sockmap: fix integer overflow in bpf_msg_pop_data() bounds checknet/core/filter.c+2 -21 reply
2/2selftests/bpf: add test for bpf_msg_pop_data() overflowtools/testing/selftests/bpf/prog_tests/sockmap_basic.c tools/testing/selftests/bpf/progs/test_sockmap_msg_pop_data.c+75 -00 replies

Reviews trailers per patch

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

Read the v2 thread

Cover letter [PATCH bpf v2 0/2] bpf, sockmap: fix bpf_msg_pop_data() integer overflow

bpf_msg_pop_data() computes "u64 last = start + len" with u32 operands, so a len close to U32_MAX wraps the sum and passes the bounds check. The pop loop then walks off the end of the sk_msg scatterlist and sk_msg_shift_left() calls put_page() on the empty msg->sg.end slot.

v2:
- add selftest (Cong Wang)
- change pop to u32 (Emil Tsalapatis)

v1:
- https://lore.kernel.org/all/[email protected]/

Sechang Lim (2):
bpf, sockmap: fix integer overflow in bpf_msg_pop_data() bounds check selftests/bpf: add test for bpf_msg_pop_data() overflow

 net/core/filter.c                             |  4 +-
 .../selftests/bpf/prog_tests/sockmap_basic.c  | 48 +++++++++++++++++++
 .../bpf/progs/test_sockmap_msg_pop_data.c     | 27 +++++++++++
 3 files changed, 77 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_sockmap_msg_pop_data.c
Signature · 1 line
2.43.0