Skip to content

Fix stale register bounds on LSM retval context load

Tristan Madani bpf stable 3 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 2 repliesApplied 2/2
  2. v21 patch 1 replySuperseded
  3. v11 patch 1 replySuperseded

Changes in v3 from the cover letter

- Add selftest demonstrating the issue (Eduard Zingerman)
- No code change in patch 1 from v2

Patches in v3 All 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: Reset register bounds before narrowing retval range in check_mem_access()kernel/bpf/verifier.c+1 -01 replyApplied
2/2selftests/bpf: Add test for stale bounds on LSM retval context loadtools/testing/selftests/bpf/progs/verifier_lsm.c+15 -01 replyApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchEduard Zingerman
1/2A-b
2/2A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH bpf v3 0/2] Fix stale register bounds on LSM retval context load

From: Tristan Madani <[email protected]>

check_mem_access() calls __mark_reg_s32_range() to narrow a register to the LSM hook retval range, but the intersection preserves stale bounds from prior instructions. Add mark_reg_unknown() before narrowing (same pattern as the else branch) and a selftest that catches the mismatch.

Changes in v3:
- Add selftest demonstrating the issue (Eduard Zingerman)
- No code change in patch 1 from v2

Tristan Madani (2):
bpf: Reset register bounds before narrowing retval range in
check_mem_access()
selftests/bpf: Add test for stale bounds on LSM retval context load

 kernel/bpf/verifier.c                            |  1 +
 tools/testing/selftests/bpf/progs/verifier_lsm.c | 15 +++++++++++++++
 2 files changed, 16 insertions(+)
Signature · 1 line
2.47.3