public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf v5 0/2] bpf: Fix OOB in pcpu_init_value and add a test
@ 2026-04-02  7:39 xulang
  2026-04-02  7:42 ` [PATCH bpf v5 1/2] bpf: Fix OOB in pcpu_init_value xulang
  2026-04-02  7:42 ` [PATCH bpf v5 2/2] selftests/bpf: Add test for cgroup storage OOB read xulang
  0 siblings, 2 replies; 14+ messages in thread
From: xulang @ 2026-04-02  7:39 UTC (permalink / raw)
  To: martin.lau
  Cc: andrii, ast, bpf, daniel, dzm91, eddyz87, haoluo, ihor.solodrai,
	john.fastabend, jolsa, kaiyanm, kernel, kpsingh, linux-kernel,
	paul.chaignon, sdf, song, yonghong.song, Lang Xu

From: Lang Xu <xulang@uniontech.com>

Fix OOB read when copying element from a BPF_MAP_TYPE_CGROUP_STORAGE
map to another pcpu map with the same value_size that is not rounded
up to 8 bytes, and add a test case to reproduce the issue.

The root cause is that pcpu_init_value() uses copy_map_value_long() which
rounds up the copy size to 8 bytes, but CGROUP_STORAGE map values are not
8-byte aligned (e.g., 4-byte). This causes a 4-byte OOB read when
the copy is performed.

Lang Xu (2):
  bpf: Fix OOB in pcpu_init_value
  selftests/bpf: Add test for cgroup storage OOB read

Signed-off-by: Lang Xu <xulang@uniontech.com>
---
Changes since v4:
- Make the summary phrase of the cover different from patch 1
- Fix patch series format issues

Changes since v3:
- nothing changed, just resend the patch series manually.
  There is something wrong with my email server(Message-ID overrided).

Changes since v2:
- Fix patch series format issues
- Instead of aligning CGROUP_STORAGE allocation,
  fix it by replacing copy_map_value_long with copy_map_value in
  pcpu_init_value

Changes since v1:
- Add self-test program to reproduce the issue

base-commit: 7aaa8047eafd ("Linux 7.0-rc6")

 kernel/bpf/hashtab.c                               |  2 +-
 tools/testing/selftests/bpf/prog_tests/cgroup_storage.c | 42 +++++++++++++++++++++
 tools/testing/selftests/bpf/progs/cgroup_storage.c      | 43 ++++++++++++++++++++++
 3 files changed, 86 insertions(+), 1 deletion(-)

--
2.51.0

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

end of thread, other threads:[~2026-04-03  2:46 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02  7:39 [PATCH bpf v5 0/2] bpf: Fix OOB in pcpu_init_value and add a test xulang
2026-04-02  7:42 ` [PATCH bpf v5 1/2] bpf: Fix OOB in pcpu_init_value xulang
2026-04-02 14:17   ` Alexei Starovoitov
2026-04-02 17:01     ` Martin KaFai Lau
2026-04-02 18:36       ` Alexei Starovoitov
2026-04-02 19:58         ` Martin KaFai Lau
2026-04-03  0:05           ` Alexei Starovoitov
2026-04-03  1:59             ` Martin KaFai Lau
2026-04-03  2:09               ` Alexei Starovoitov
2026-04-03  2:24                 ` Martin KaFai Lau
2026-04-03  2:28                   ` Alexei Starovoitov
2026-04-03  2:41                     ` Martin KaFai Lau
2026-04-03  2:46                       ` Alexei Starovoitov
2026-04-02  7:42 ` [PATCH bpf v5 2/2] selftests/bpf: Add test for cgroup storage OOB read xulang

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