* [PATCH bpf] bpf: Reuse log from btf_prase_vmlinux() in btf_struct_ops_init()
@ 2020-01-27 17:51 Martin KaFai Lau
2020-01-27 18:34 ` Andrii Nakryiko
2020-01-29 16:24 ` Daniel Borkmann
0 siblings, 2 replies; 4+ messages in thread
From: Martin KaFai Lau @ 2020-01-27 17:51 UTC (permalink / raw)
To: bpf
Cc: Alexei Starovoitov, Daniel Borkmann, David Miller, kernel-team, netdev
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: 27ae7997a661 ("bpf: Introduce BPF_PROG_TYPE_STRUCT_OPS")
Signed-off-by: Martin KaFai Lau <kafai@fb.com>
---
include/linux/bpf.h | 7 +++++--
kernel/bpf/bpf_struct_ops.c | 5 ++---
kernel/bpf/btf.c | 2 +-
3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 8e9ad3943cd9..49b1a70e12c8 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -728,7 +728,7 @@ struct bpf_struct_ops {
#if defined(CONFIG_BPF_JIT) && defined(CONFIG_BPF_SYSCALL)
#define BPF_MODULE_OWNER ((void *)((0xeB9FUL << 2) + POISON_POINTER_DELTA))
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);
void bpf_struct_ops_put(const void *kdata);
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)
{
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)
{
return try_module_get(owner);
diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c
index 8ad1c9ea26b2..042f95534f86 100644
--- a/kernel/bpf/bpf_struct_ops.c
+++ b/kernel/bpf/bpf_struct_ops.c
@@ -96,12 +96,11 @@ const struct bpf_prog_ops bpf_struct_ops_prog_ops = {
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;
const struct btf_member *member;
struct bpf_struct_ops *st_ops;
- struct bpf_verifier_log log = {};
const struct btf_type *t;
char value_name[128];
const char *mname;
@@ -172,7 +171,7 @@ void bpf_struct_ops_init(struct btf *btf)
member->type,
NULL);
if (func_proto &&
- btf_distill_func_proto(&log, btf,
+ btf_distill_func_proto(log, btf,
func_proto, mname,
&st_ops->func_models[j])) {
pr_warn("Error in parsing func ptr %s in struct %s\n",
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
index b7c1660fb594..8c9d8f266bef 100644
--- a/kernel/bpf/btf.c
+++ b/kernel/bpf/btf.c
@@ -3643,7 +3643,7 @@ struct btf *btf_parse_vmlinux(void)
goto errout;
}
- bpf_struct_ops_init(btf);
+ bpf_struct_ops_init(btf, log);
btf_verifier_env_free(env);
refcount_set(&btf->refcnt, 1);
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] bpf: Reuse log from btf_prase_vmlinux() in btf_struct_ops_init()
2020-01-27 17:51 [PATCH bpf] bpf: Reuse log from btf_prase_vmlinux() in btf_struct_ops_init() Martin KaFai Lau
@ 2020-01-27 18:34 ` Andrii Nakryiko
2020-01-27 18:46 ` Alexei Starovoitov
2020-01-29 16:24 ` Daniel Borkmann
1 sibling, 1 reply; 4+ messages in thread
From: Andrii Nakryiko @ 2020-01-27 18:34 UTC (permalink / raw)
To: Martin KaFai Lau
Cc: bpf, Alexei Starovoitov, Daniel Borkmann, David Miller,
Kernel Team, Networking
On Mon, Jan 27, 2020 at 9:52 AM Martin KaFai Lau <kafai@fb.com> wrote:
>
> 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: 27ae7997a661 ("bpf: Introduce BPF_PROG_TYPE_STRUCT_OPS")
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> ---
LGTM, but there is typo in subject (btf_prase_vmlinux).
Acked-by: Andrii Nakryiko <andriin@fb.com>
[...]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] bpf: Reuse log from btf_prase_vmlinux() in btf_struct_ops_init()
2020-01-27 18:34 ` Andrii Nakryiko
@ 2020-01-27 18:46 ` Alexei Starovoitov
0 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2020-01-27 18:46 UTC (permalink / raw)
To: Andrii Nakryiko
Cc: Martin KaFai Lau, bpf, Alexei Starovoitov, Daniel Borkmann,
David Miller, Kernel Team, Networking
On Mon, Jan 27, 2020 at 10:34 AM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Mon, Jan 27, 2020 at 9:52 AM Martin KaFai Lau <kafai@fb.com> wrote:
> >
> > 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: 27ae7997a661 ("bpf: Introduce BPF_PROG_TYPE_STRUCT_OPS")
> > Signed-off-by: Martin KaFai Lau <kafai@fb.com>
> > ---
>
> LGTM, but there is typo in subject (btf_prase_vmlinux).
>
> Acked-by: Andrii Nakryiko <andriin@fb.com>
Tested. All works.
Dave,
if you haven't sent PR yet may be you can apply this patch
directly to silence the warning?
Not a big deal if not. I don't see this warn with default config.
Acked-by: Alexei Starovoitov <ast@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf] bpf: Reuse log from btf_prase_vmlinux() in btf_struct_ops_init()
2020-01-27 17:51 [PATCH bpf] bpf: Reuse log from btf_prase_vmlinux() in btf_struct_ops_init() Martin KaFai Lau
2020-01-27 18:34 ` Andrii Nakryiko
@ 2020-01-29 16:24 ` Daniel Borkmann
1 sibling, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2020-01-29 16:24 UTC (permalink / raw)
To: Martin KaFai Lau, bpf
Cc: Alexei Starovoitov, David Miller, kernel-team, netdev
On 1/27/20 6:51 PM, Martin KaFai Lau wrote:
> 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: 27ae7997a661 ("bpf: Introduce BPF_PROG_TYPE_STRUCT_OPS")
> Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-01-29 16:24 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-27 17:51 [PATCH bpf] bpf: Reuse log from btf_prase_vmlinux() in btf_struct_ops_init() Martin KaFai Lau
2020-01-27 18:34 ` Andrii Nakryiko
2020-01-27 18:46 ` Alexei Starovoitov
2020-01-29 16:24 ` Daniel Borkmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).