summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorYonghong Song <yonghong.song@linux.dev>2023-08-07 20:57:21 +0300
committerMartin KaFai Lau <martin.lau@kernel.org>2023-08-08 02:23:35 +0300
commitdb2baf82b098aa10ac16f34e44732ec450fb11c7 (patch)
tree60f02ffa5460d354357c53dc53b82ec02eafea56 /tools
parent2369e52657d371c58da0b826f8b87f01611cfc59 (diff)
downloadlinux-db2baf82b098aa10ac16f34e44732ec450fb11c7.tar.xz
bpf: Fix an incorrect verification success with movsx insn
syzbot reports a verifier bug which triggers a runtime panic. The test bpf program is: 0: (62) *(u32 *)(r10 -8) = 553656332 1: (bf) r1 = (s16)r10 2: (07) r1 += -8 3: (b7) r2 = 3 4: (bd) if r2 <= r1 goto pc+0 5: (85) call bpf_trace_printk#-138320 6: (b7) r0 = 0 7: (95) exit At insn 1, the current implementation keeps 'r1' as a frame pointer, which caused later bpf_trace_printk helper call crash since frame pointer address is not valid any more. Note that at insn 4, the 'pointer vs. scalar' comparison is allowed for privileged prog run. To fix the problem with above insn 1, the fix in the patch adopts similar pattern to existing 'R1 = (u32) R2' handling. For unprivileged prog run, verification will fail with 'R<num> sign-extension part of pointer'. For privileged prog run, the dst_reg 'r1' will be marked as an unknown scalar, so later 'bpf_trace_pointk' helper will complain since it expected certain pointers. Reported-by: syzbot+d61b595e9205573133b3@syzkaller.appspotmail.com Fixes: 8100928c8814 ("bpf: Support new sign-extension mov insns") Signed-off-by: Yonghong Song <yonghong.song@linux.dev> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/20230807175721.671696-1-yonghong.song@linux.dev Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Diffstat (limited to 'tools')
0 files changed, 0 insertions, 0 deletions