Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -16429,6 +16429,10 @@ static int reg_set_min_max(struct bpf_verifier_env *env,
if (false_reg1->type != SCALAR_VALUE || false_reg2->type != SCALAR_VALUE)
return 0;

/* If conditional jumps on the same register, skip the adjustment */
if (false_reg1 == false_reg2)
return 0;

/* fallthrough (FALSE) branch */
regs_refine_cond_op(false_reg1, false_reg2, rev_opcode(opcode), is_jmp32);
reg_bounds_sync(false_reg1);
Expand Down
17 changes: 17 additions & 0 deletions tools/testing/selftests/bpf/progs/verifier_bounds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1709,4 +1709,21 @@ __naked void jeq_disagreeing_tnums(void *ctx)
: __clobber_all);
}

SEC("socket")
__description("JGT on same register")
__success __log_level(2)
__naked void jgt_same_register(void *ctx)
{
asm volatile(" \
call %[bpf_get_prandom_u32]; \
w8 = 0x80000000; \
r0 &= r8; \
if r0 > r0 goto +1; \
call %[bpf_get_prandom_u32]; \
exit; \
" :
: __imm(bpf_get_prandom_u32)
: __clobber_all);
}

char _license[] SEC("license") = "GPL";
Loading