Message ID | 3268db8bc504f4118e1baee5e49f917f0e2767fa.1660761470.git.dxu@dxuuu.xyz (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | BPF |
Headers | show |
Series | Support direct writes to nf_conn:mark | expand |
On Wed, 17 Aug 2022 at 20:43, Daniel Xu <dxu@dxuuu.xyz> wrote: > > Since commit 27ae7997a661 ("bpf: Introduce BPF_PROG_TYPE_STRUCT_OPS") > there has existed bpf_verifier_ops:btf_struct_access. When > btf_struct_access is _unset_ for a prog type, the verifier runs the > default implementation, which is to enforce read only: > > if (env->ops->btf_struct_access) { > [...] > } else { > if (atype != BPF_READ) { > verbose(env, "only read is supported\n"); > return -EACCES; > } > > [...] > } > > When btf_struct_access is _set_, the expectation is that > btf_struct_access has full control over accesses, including if writes > are allowed. > > Rather than carve out an exception for each prog type that may write to > BTF ptrs, delete the redundant check and give full control to > btf_struct_access. > > Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> > --- Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 2c1f8069f7b7..ca2311bf0cfd 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -13474,9 +13474,6 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env) insn->code = BPF_LDX | BPF_PROBE_MEM | BPF_SIZE((insn)->code); env->prog->aux->num_exentries++; - } else if (resolve_prog_type(env->prog) != BPF_PROG_TYPE_STRUCT_OPS) { - verbose(env, "Writes through BTF pointers are not allowed\n"); - return -EINVAL; } continue; default:
Since commit 27ae7997a661 ("bpf: Introduce BPF_PROG_TYPE_STRUCT_OPS") there has existed bpf_verifier_ops:btf_struct_access. When btf_struct_access is _unset_ for a prog type, the verifier runs the default implementation, which is to enforce read only: if (env->ops->btf_struct_access) { [...] } else { if (atype != BPF_READ) { verbose(env, "only read is supported\n"); return -EACCES; } [...] } When btf_struct_access is _set_, the expectation is that btf_struct_access has full control over accesses, including if writes are allowed. Rather than carve out an exception for each prog type that may write to BTF ptrs, delete the redundant check and give full control to btf_struct_access. Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> --- kernel/bpf/verifier.c | 3 --- 1 file changed, 3 deletions(-)