Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
linux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Luis Gerhorst
linux
Commits
49ebd5c8
Commit
49ebd5c8
authored
1 year ago
by
Luis Gerhorst
Browse files
Options
Downloads
Patches
Plain Diff
[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
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
kernel/bpf/verifier.c
+4
-6
4 additions, 6 deletions
kernel/bpf/verifier.c
with
4 additions
and
6 deletions
kernel/bpf/verifier.c
+
4
−
6
View file @
49ebd5c8
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment