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(+)
@@ -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);
From: Song Liu <song@kernel.org> Date: 2021-05-14 20:52:16
On Fri, May 14, 2021 at 1:33 PM Andrii Nakryiko [off-list ref] 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>
@@ -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);--
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(+)
On Fri, May 14, 2021 at 4:14 PM Alexei Starovoitov
[off-list ref] wrote:
On Fri, May 14, 2021 at 1:34 PM Andrii Nakryiko [off-list ref] wrote:
quoted
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.