Netdev List
 help / color / mirror / Atom feed
* [PATCH bpf v2 0/2] bpf, sockmap: fix bpf_msg_pop_data() integer overflow
@ 2026-06-10  8:11 Sechang Lim
  2026-06-10  8:11 ` [PATCH bpf v2 1/2] bpf, sockmap: fix integer overflow in bpf_msg_pop_data() bounds check Sechang Lim
  2026-06-10  8:11 ` [PATCH bpf v2 2/2] selftests/bpf: add test for bpf_msg_pop_data() overflow Sechang Lim
  0 siblings, 2 replies; 4+ messages in thread
From: Sechang Lim @ 2026-06-10  8:11 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, John Fastabend,
	Andrii Nakryiko, Martin KaFai Lau
  Cc: Eduard Zingerman, Stanislav Fomichev, Kumar Kartikeya Dwivedi,
	Song Liu, Yonghong Song, Jiri Olsa, Shuah Khan, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
	Cong Wang, Emil Tsalapatis, bpf, netdev, linux-kselftest,
	linux-kernel

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/20260609183927.4021802-1-rhkrqnwk98@gmail.com/

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

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-06-10 17:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-10  8:11 [PATCH bpf v2 0/2] bpf, sockmap: fix bpf_msg_pop_data() integer overflow Sechang Lim
2026-06-10  8:11 ` [PATCH bpf v2 1/2] bpf, sockmap: fix integer overflow in bpf_msg_pop_data() bounds check Sechang Lim
2026-06-10 17:35   ` Alexei Starovoitov
2026-06-10  8:11 ` [PATCH bpf v2 2/2] selftests/bpf: add test for bpf_msg_pop_data() overflow Sechang Lim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox