Commit d3e42bb0 authored by Martin KaFai Lau's avatar Martin KaFai Lau Committed by Daniel Borkmann

bpf: Reuse log from btf_prase_vmlinux() in btf_struct_ops_init()

Instead of using a locally defined "struct bpf_verifier_log log = {}",
btf_struct_ops_init() should reuse the "log" from its calling
function "btf_parse_vmlinux()".  It should also resolve the
frame-size too large compiler warning in some ARCH.

Fixes: 27ae7997 ("bpf: Introduce BPF_PROG_TYPE_STRUCT_OPS")
Signed-off-by: default avatarMartin KaFai Lau <kafai@fb.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200127175145.1154438-1-kafai@fb.com
parent 44efc78d
...@@ -728,7 +728,7 @@ struct bpf_struct_ops { ...@@ -728,7 +728,7 @@ struct bpf_struct_ops {
#if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL) #if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL)
#define BPF_MODULE_OWNER ((void *)((0xeB9FUL << 2) + POISON_POINTER_DELTA)) #define BPF_MODULE_OWNER ((void *)((0xeB9FUL << 2) + POISON_POINTER_DELTA))
const struct bpf_struct_ops *bpf_struct_ops_find(u32 type_id); const struct bpf_struct_ops *bpf_struct_ops_find(u32 type_id);
void bpf_struct_ops_init(struct btf *btf); void bpf_struct_ops_init(struct btf *btf, struct bpf_verifier_log *log);
bool bpf_struct_ops_get(const void *kdata); bool bpf_struct_ops_get(const void *kdata);
void bpf_struct_ops_put(const void *kdata); void bpf_struct_ops_put(const void *kdata);
int bpf_struct_ops_map_sys_lookup_elem(struct bpf_map *map, void *key, int bpf_struct_ops_map_sys_lookup_elem(struct bpf_map *map, void *key,
...@@ -752,7 +752,10 @@ static inline const struct bpf_struct_ops *bpf_struct_ops_find(u32 type_id) ...@@ -752,7 +752,10 @@ static inline const struct bpf_struct_ops *bpf_struct_ops_find(u32 type_id)
{ {
return NULL; return NULL;
} }
static inline void bpf_struct_ops_init(struct btf *btf) { } static inline void bpf_struct_ops_init(struct btf *btf,
struct bpf_verifier_log *log)
{
}
static inline bool bpf_try_module_get(const void *data, struct module *owner) static inline bool bpf_try_module_get(const void *data, struct module *owner)
{ {
return try_module_get(owner); return try_module_get(owner);
......
...@@ -96,12 +96,11 @@ const struct bpf_prog_ops bpf_struct_ops_prog_ops = { ...@@ -96,12 +96,11 @@ const struct bpf_prog_ops bpf_struct_ops_prog_ops = {
static const struct btf_type *module_type; static const struct btf_type *module_type;
void bpf_struct_ops_init(struct btf *btf) void bpf_struct_ops_init(struct btf *btf, struct bpf_verifier_log *log)
{ {
s32 type_id, value_id, module_id; s32 type_id, value_id, module_id;
const struct btf_member *member; const struct btf_member *member;
struct bpf_struct_ops *st_ops; struct bpf_struct_ops *st_ops;
struct bpf_verifier_log log = {};
const struct btf_type *t; const struct btf_type *t;
char value_name[128]; char value_name[128];
const char *mname; const char *mname;
...@@ -172,7 +171,7 @@ void bpf_struct_ops_init(struct btf *btf) ...@@ -172,7 +171,7 @@ void bpf_struct_ops_init(struct btf *btf)
member->type, member->type,
NULL); NULL);
if (func_proto && if (func_proto &&
btf_distill_func_proto(&log, btf, btf_distill_func_proto(log, btf,
func_proto, mname, func_proto, mname,
&st_ops->func_models[j])) { &st_ops->func_models[j])) {
pr_warn("Error in parsing func ptr %s in struct %s\n", pr_warn("Error in parsing func ptr %s in struct %s\n",
......
...@@ -3643,7 +3643,7 @@ struct btf *btf_parse_vmlinux(void) ...@@ -3643,7 +3643,7 @@ struct btf *btf_parse_vmlinux(void)
goto errout; goto errout;
} }
bpf_struct_ops_init(btf); bpf_struct_ops_init(btf, log);
btf_verifier_env_free(env); btf_verifier_env_free(env);
refcount_set(&btf->refcnt, 1); refcount_set(&btf->refcnt, 1);
......
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