Skip to content

Commit

Permalink
Revert "bpf: Sanity check max value for var_off stack access"
Browse files Browse the repository at this point in the history
ANBZ: torvalds#342

This reverts commit 443226a.

Signed-off-by: Qiao Ma <[email protected]>
Acked-by: Mao Wenan <[email protected]>
Acked-by: Tony Lu <[email protected]>
  • Loading branch information
shiloong authored and maqiao-mq committed Apr 20, 2022
1 parent 6e79b40 commit 6647be9
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions kernel/bpf/verifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -1834,28 +1834,16 @@ static int check_stack_boundary(struct bpf_verifier_env *env, int regno,
if (meta && meta->raw_mode)
meta = NULL;

if (reg->smax_value >= BPF_MAX_VAR_OFF ||
reg->smax_value <= -BPF_MAX_VAR_OFF) {
verbose(env, "R%d unbounded indirect variable offset stack access\n",
regno);
return -EACCES;
}
min_off = reg->smin_value + reg->off;
max_off = reg->smax_value + reg->off;
max_off = reg->umax_value + reg->off;
err = __check_stack_boundary(env, regno, min_off, access_size,
zero_size_allowed);
if (err) {
verbose(env, "R%d min value is outside of stack bound\n",
regno);
if (err)
return err;
}
err = __check_stack_boundary(env, regno, max_off, access_size,
zero_size_allowed);
if (err) {
verbose(env, "R%d max value is outside of stack bound\n",
regno);
if (err)
return err;
}
}

if (meta && meta->raw_mode) {
Expand Down

0 comments on commit 6647be9

Please sign in to comment.