Message ID | 20210514195534.1440970-1-andrii@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Commit | 513f485ca5163c6cba869602d076a8e2f04d1ca1 |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next] libbpf: reject static entry-point BPF programs | 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 | 6 maintainers not CCed: yhs@fb.com kpsingh@kernel.org kafai@fb.com ast@kernel.org 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: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: line length of 104 exceeds 80 columns WARNING: line length of 97 exceeds 80 columns |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
On Fri, May 14, 2021 at 1:33 PM Andrii Nakryiko <andrii@kernel.org> wrote: > > Detect use of static entry-point BPF programs (those with SEC() markings) and > emit error message. This is similar to > c1cccec9c636 ("libbpf: Reject static maps") but for BPF programs. > > Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Acked-by: Song Liu <songliubraving@fb.com> > --- > tools/lib/bpf/libbpf.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 182bd3d3f728..e58f51b24574 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -677,6 +677,11 @@ bpf_object__add_programs(struct bpf_object *obj, Elf_Data *sec_data, > return -LIBBPF_ERRNO__FORMAT; > } > > + if (sec_idx != obj->efile.text_shndx && GELF_ST_BIND(sym.st_info) == STB_LOCAL) { > + pr_warn("sec '%s': program '%s' is static and not supported\n", sec_name, name); > + return -ENOTSUP; > + } > + > pr_debug("sec '%s': found program '%s' at insn offset %zu (%zu bytes), code size %zu insns (%zu bytes)\n", > sec_name, name, sec_off / BPF_INSN_SZ, sec_off, prog_sz / BPF_INSN_SZ, prog_sz); > > -- > 2.30.2 >
On Fri, May 14, 2021 at 1:34 PM Andrii Nakryiko <andrii@kernel.org> wrote: > > Detect use of static entry-point BPF programs (those with SEC() markings) and > emit error message. Applied. I was wondering whether you've seen such combinations ?
Hello: This patch was applied to bpf/bpf-next.git (refs/heads/master): On Fri, 14 May 2021 12:55:34 -0700 you wrote: > Detect use of static entry-point BPF programs (those with SEC() markings) and > emit error message. This is similar to > c1cccec9c636 ("libbpf: Reject static maps") but for BPF programs. > > Signed-off-by: Andrii Nakryiko <andrii@kernel.org> > --- > tools/lib/bpf/libbpf.c | 5 +++++ > 1 file changed, 5 insertions(+) Here is the summary with links: - [bpf-next] libbpf: reject static entry-point BPF programs https://git.kernel.org/bpf/bpf-next/c/513f485ca516 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
On Fri, May 14, 2021 at 4:14 PM Alexei Starovoitov <alexei.starovoitov@gmail.com> wrote: > > On Fri, May 14, 2021 at 1:34 PM Andrii Nakryiko <andrii@kernel.org> wrote: > > > > Detect use of static entry-point BPF programs (those with SEC() markings) and > > emit error message. > > Applied. I was wondering whether you've seen such combinations ? Haven't seen this anywhere in the real code, only tested locally by adding static to one of selftests. Unlikely to break anyone, but good to be as strict as with maps.
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 182bd3d3f728..e58f51b24574 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -677,6 +677,11 @@ bpf_object__add_programs(struct bpf_object *obj, Elf_Data *sec_data, return -LIBBPF_ERRNO__FORMAT; } + if (sec_idx != obj->efile.text_shndx && GELF_ST_BIND(sym.st_info) == STB_LOCAL) { + pr_warn("sec '%s': program '%s' is static and not supported\n", sec_name, name); + return -ENOTSUP; + } + pr_debug("sec '%s': found program '%s' at insn offset %zu (%zu bytes), code size %zu insns (%zu bytes)\n", sec_name, name, sec_off / BPF_INSN_SZ, sec_off, prog_sz / BPF_INSN_SZ, prog_sz);
Detect use of static entry-point BPF programs (those with SEC() markings) and emit error message. This is similar to c1cccec9c636 ("libbpf: Reject static maps") but for BPF programs. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> --- tools/lib/bpf/libbpf.c | 5 +++++ 1 file changed, 5 insertions(+)