Message ID | 08b306f207cc6c516500a58ee0bc506f09859d26.1620499942.git.yifeifz2@illinois.edu (mailing list archive) |
---|---|
State | RFC |
Delegated to: | BPF |
Headers | show |
Series | eBPF seccomp filters | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 7 maintainers not CCed: netdev@vger.kernel.org yhs@fb.com kpsingh@kernel.org andrii@kernel.org kafai@fb.com john.fastabend@gmail.com songliubraving@fb.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 10045 this patch: 10045 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 16 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 10459 this patch: 10459 |
netdev/header_inline | success | Link |
diff --git a/include/linux/bpf.h b/include/linux/bpf.h index 02b02cb29ce2..86f3e8784e43 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -484,6 +484,7 @@ struct bpf_verifier_ops { enum bpf_access_type atype, u32 *next_btf_id); bool (*check_kfunc_call)(u32 kfunc_btf_id); + bool (*map_access)(enum bpf_access_type type); }; struct bpf_prog_offload_ops { diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 8fd552c16763..8eec1796caaa 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -3100,6 +3100,9 @@ static int check_map_access_type(struct bpf_verifier_env *env, u32 regno, struct bpf_map *map = regs[regno].map_ptr; u32 cap = bpf_map_flags_to_cap(map); + if (env->ops->map_access && !env->ops->map_access(type)) + cap = 0; + if (type == BPF_WRITE && !(cap & BPF_MAP_CAN_WRITE)) { verbose(env, "write into map forbidden, value_size=%d off=%d size=%d\n", map->value_size, off, size);