Skip to content

bpf: fix for use after free bug in inline_bpf_loop

Eduard Zingerman bpf 1 version Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 0 repliesApplied 2/2

Patches in v1 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: fix for use after free bug in inline_bpf_loopkernel/bpf/verifier.c+1 -10 repliesApplied
2/2selftest/bpf: test for use after free bug fix in inline_bpf_looptools/testing/selftests/bpf/test_verifier.c tools/testing/selftests/bpf/verifier/bpf_loop_inline.c+50 -00 repliesApplied

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH bpf-next 0/2] bpf: fix for use after free bug in inline_bpf_loop

These two patches fix the use after free bug in inline_bpf_loop() reported by Dan Carpenter. The fix for verifier.c and the test case in test_verifier.c are split into separate commits.

While the first patch is necessary, I'm not sure about the second. The test case is somewhat fragile because of the following line:

	const int len = getpagesize() - 25;

Here 25 is a magical number that allows env->prog to fit in one page before bpf_loop inlining and don't fit after the bpf_loop inlining. I'd prefer to use sizeof(struct bpf_prog) instead of this constant, but definition of the struct bpf_prog is not available in test_verifier.c.

Eduard Zingerman (2):
bpf: fix for use after free bug in inline_bpf_loop selftest/bpf: test for use after free bug fix in inline_bpf_loop

 kernel/bpf/verifier.c                         |  2 +-
 tools/testing/selftests/bpf/test_verifier.c   | 39 +++++++++++++++++++
 .../selftests/bpf/verifier/bpf_loop_inline.c  | 11 ++++++
 3 files changed, 51 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1