History

bpf: Set meta->raw_mode for pointers close to use

If we encounter a pointer to memory, we set meta->raw_mode depending on the type of memory we point at. What isn't obvious is that this information is only used when the next memory size argument is encountered. Move the assignment closer to where it's used, and add a comment that explains what is going on.

Lorenz Bauer committed 6 years ago

Commit a2bbe7c1 parent feec7041 file · +5 −1Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/bpf/verifier.c+5−1
@@ -4067,7 +4067,6 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, · 4066 unmodified lines
40674067 type != PTR_TO_RDWR_BUF &&
40684068 type != expected_type)
40694069 goto err_type;
4070− meta->raw_mode = arg_type == ARG_PTR_TO_UNINIT_MEM;
40714070 } else if (arg_type_is_alloc_mem_ptr(arg_type)) {
40724071 expected_type = PTR_TO_MEM;
40734072 if (register_is_null(reg) &&
@@ -4156,6 +4155,11 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg, · 82 unmodified lines
41564155 err = check_helper_mem_access(env, regno,
41574156 meta->map_ptr->value_size, false,
41584157 meta);
4158+ } else if (arg_type_is_mem_ptr(arg_type)) {
4159+ /* The access to this pointer is only checked when we hit the
4160+ * next is_mem_size argument below.
4161+ */
4162+ meta->raw_mode = (arg_type == ARG_PTR_TO_UNINIT_MEM);
41594163 } else if (arg_type_is_mem_size(arg_type)) {
41604164 bool zero_size_allowed = (arg_type == ARG_CONST_SIZE_OR_ZERO);
41614165

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t