[PATCH bpf-next 0/2] bpf: Fix incorrect immediate spill

Hao Sun posted 2 patches 2 years, 1 month ago
There is a newer version of this series
kernel/bpf/verifier.c                             |  2 +-
tools/testing/selftests/bpf/verifier/bpf_st_mem.c | 32 +++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
[PATCH bpf-next 0/2] bpf: Fix incorrect immediate spill
Posted by Hao Sun 2 years, 1 month ago
Immediate is incorrectly cast to u32 before being spilled, losing sign
information. The range information is incorrect after load again. Fix
immediate spill by remove the cast. The second patch add a test case
for this.

Signed-off-by: Hao Sun <sunhao.th@gmail.com>
---
Hao Sun (2):
      bpf: Fix check_stack_write_fixed_off() to correctly spill imm
      selftests/bpf: Add test for immediate spilled to stack

 kernel/bpf/verifier.c                             |  2 +-
 tools/testing/selftests/bpf/verifier/bpf_st_mem.c | 32 +++++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
---
base-commit: 399f6185a1c02f39bcadb8749bc2d9d48685816f
change-id: 20231026-fix-check-stack-write-c40996694dfa

Best regards,
-- 
Hao Sun <sunhao.th@gmail.com>
Re: [PATCH bpf-next 0/2] bpf: Fix incorrect immediate spill
Posted by Eduard Zingerman 2 years, 1 month ago
On Thu, 2023-10-26 at 17:13 +0200, Hao Sun wrote:
> Immediate is incorrectly cast to u32 before being spilled, losing sign
> information. The range information is incorrect after load again. Fix
> immediate spill by remove the cast. The second patch add a test case
> for this.
> 
> Signed-off-by: Hao Sun <sunhao.th@gmail.com>

Thank you for finding and fixing this issue.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

> ---
> Hao Sun (2):
>       bpf: Fix check_stack_write_fixed_off() to correctly spill imm
>       selftests/bpf: Add test for immediate spilled to stack
> 
>  kernel/bpf/verifier.c                             |  2 +-
>  tools/testing/selftests/bpf/verifier/bpf_st_mem.c | 32 +++++++++++++++++++++++
>  2 files changed, 33 insertions(+), 1 deletion(-)
> ---
> base-commit: 399f6185a1c02f39bcadb8749bc2d9d48685816f
> change-id: 20231026-fix-check-stack-write-c40996694dfa
> 
> Best regards,