Commit 51a52a29 authored by David Vernet's avatar David Vernet Committed by Alexei Starovoitov

bpf: Pass const struct bpf_prog * to .check_member

The .check_member field of struct bpf_struct_ops is currently passed the
member's btf_type via const struct btf_type *t, and a const struct
btf_member *member. This allows the struct_ops implementation to check
whether e.g. an ops is supported, but it would be useful to also enforce
that the struct_ops prog being loaded for that member has other
qualities, like being sleepable (or not). This patch therefore updates
the .check_member() callback to also take a const struct bpf_prog *prog
argument.
Signed-off-by: default avatarDavid Vernet <void@manifault.com>
Link: https://lore.kernel.org/r/20230125164735.785732-4-void@manifault.comSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 913b2255
...@@ -1422,7 +1422,8 @@ struct bpf_struct_ops { ...@@ -1422,7 +1422,8 @@ struct bpf_struct_ops {
const struct bpf_verifier_ops *verifier_ops; const struct bpf_verifier_ops *verifier_ops;
int (*init)(struct btf *btf); int (*init)(struct btf *btf);
int (*check_member)(const struct btf_type *t, int (*check_member)(const struct btf_type *t,
const struct btf_member *member); const struct btf_member *member,
const struct bpf_prog *prog);
int (*init_member)(const struct btf_type *t, int (*init_member)(const struct btf_type *t,
const struct btf_member *member, const struct btf_member *member,
void *kdata, const void *udata); void *kdata, const void *udata);
......
...@@ -16792,7 +16792,7 @@ static int check_struct_ops_btf_id(struct bpf_verifier_env *env) ...@@ -16792,7 +16792,7 @@ static int check_struct_ops_btf_id(struct bpf_verifier_env *env)
} }
if (st_ops->check_member) { if (st_ops->check_member) {
int err = st_ops->check_member(t, member); int err = st_ops->check_member(t, member, prog);
if (err) { if (err) {
verbose(env, "attach to unsupported member %s of struct %s\n", verbose(env, "attach to unsupported member %s of struct %s\n",
......
...@@ -248,7 +248,8 @@ static int bpf_tcp_ca_init_member(const struct btf_type *t, ...@@ -248,7 +248,8 @@ static int bpf_tcp_ca_init_member(const struct btf_type *t,
} }
static int bpf_tcp_ca_check_member(const struct btf_type *t, static int bpf_tcp_ca_check_member(const struct btf_type *t,
const struct btf_member *member) const struct btf_member *member,
const struct bpf_prog *prog)
{ {
if (is_unsupported(__btf_member_bit_offset(t, member) / 8)) if (is_unsupported(__btf_member_bit_offset(t, member) / 8))
return -ENOTSUPP; return -ENOTSUPP;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment