Skip to content
Snippets Groups Projects
Commit 49ebd5c8 authored by Luis Gerhorst's avatar Luis Gerhorst
Browse files

[DRAFT] bpf: Prevent variable-offset stack access using nospec_v1

parent 691513d2
No related branches found
No related tags found
No related merge requests found
...@@ -6624,6 +6624,8 @@ static int check_atomic(struct bpf_verifier_env *env, int insn_idx, struct bpf_i ...@@ -6624,6 +6624,8 @@ static int check_atomic(struct bpf_verifier_env *env, int insn_idx, struct bpf_i
return 0; return 0;
} }
   
static struct bpf_insn_aux_data *cur_aux(struct bpf_verifier_env *env);
/* When register 'regno' is used to read the stack (either directly or through /* When register 'regno' is used to read the stack (either directly or through
* a helper function) make sure that it's within stack boundary and, depending * a helper function) make sure that it's within stack boundary and, depending
* on the access type, that all elements of the stack are initialized. * on the access type, that all elements of the stack are initialized.
...@@ -6678,12 +6680,8 @@ static int check_stack_range_initialized( ...@@ -6678,12 +6680,8 @@ static int check_stack_range_initialized(
* See also retrieve_ptr_limit(). * See also retrieve_ptr_limit().
*/ */
if (!env->bypass_spec_v1) { if (!env->bypass_spec_v1) {
char tn_buf[48]; /* Variable offset stack access prohibited for !root. */
cur_aux(env)->nospec_v1 = true;
tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off);
verbose(env, "R%d%s variable offset stack access prohibited for !root, var_off=%s\n",
regno, err_extra, tn_buf);
return -EACCES;
} }
/* Only initialized buffer on stack is allowed to be accessed /* Only initialized buffer on stack is allowed to be accessed
* with variable offset. With uninitialized buffer it's hard to * with variable offset. With uninitialized buffer it's hard to
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment