From: Jakub Kicinski <hidden> Date: 2018-01-16 23:52:53
Hi!
This series combines a number of random improvements ranging from
libbpf to nfp driver. NFP patches make better use of the verifier
log. There is a requested adjustment to the map offload code, and
a warning fix for a W=1 build to the disassembler. Quentin also
fixes the libbpf program type detection, while Jiong allows the use
of libbfd compiled from source.
Jakub Kicinski (3):
bpf: offload: make bpf_offload_dev_match() reject host+host case
bpf: annotate bpf_insn_print_t with __printf
nfp: bpf: print map lookup problems into verifier log
Jiong Wang (1):
tools: bpftool: add -DPACKAGE when including bfd.h
Quentin Monnet (2):
libbpf: fix string comparison for guessing eBPF program type
nfp: bpf: reject program on instructions unknown to the JIT compiler
drivers/net/ethernet/netronome/nfp/bpf/jit.c | 5 +++++
drivers/net/ethernet/netronome/nfp/bpf/main.h | 1 +
drivers/net/ethernet/netronome/nfp/bpf/verifier.c | 20 ++++++++++++++------
kernel/bpf/disasm.h | 4 ++--
kernel/bpf/offload.c | 4 +---
tools/bpf/bpftool/Makefile | 2 +-
tools/build/feature/Makefile | 2 +-
tools/lib/bpf/libbpf.c | 2 +-
8 files changed, 26 insertions(+), 14 deletions(-)
--
2.15.1
From: Jakub Kicinski <hidden> Date: 2018-01-16 23:52:54
Daniel suggests it would be more logical for bpf_offload_dev_match()
to return false is either the program or the map are not offloaded,
rather than treating the both not offloaded case as a "matching
CPU/host device".
This makes no functional difference today, since verifier only calls
bpf_offload_dev_match() when one of the objects is offloaded.
Signed-off-by: Jakub Kicinski <redacted>
---
kernel/bpf/offload.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
From: Jakub Kicinski <hidden> Date: 2018-01-16 23:52:55
Functions of type bpf_insn_print_t take printf-like format
string, mark the type accordingly.
Signed-off-by: Jakub Kicinski <redacted>
Reviewed-by: Quentin Monnet <redacted>
---
kernel/bpf/disasm.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Jakub Kicinski <hidden> Date: 2018-01-16 23:52:56
From: Jiong Wang <redacted>
bfd.h is requiring including of config.h except when PACKAGE or
PACKAGE_VERSION are defined.
/* PR 14072: Ensure that config.h is included first. */
#if !defined PACKAGE && !defined PACKAGE_VERSION
#error config.h must be included before this header
#endif
This check has been introduced since May-2012. It doesn't show up in bfd.h
on some Linux distribution, probably because distributions have remove it
when building the package.
However, sometimes the user might just build libfd from source code then
link bpftool against it. For this case, bfd.h will be original that we need
to define PACKAGE or PACKAGE_VERSION.
Acked-by: Jakub Kicinski <redacted>
Signed-off-by: Jiong Wang <redacted>
---
tools/bpf/bpftool/Makefile | 2 +-
tools/build/feature/Makefile | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
From: Jakub Kicinski <hidden> Date: 2018-01-16 23:52:57
From: Quentin Monnet <redacted>
libbpf is able to deduce the type of a program from the name of the ELF
section in which it is located. However, the comparison is made on the
first n characters, n being determined with sizeof() applied to the
reference string (e.g. "xdp"). When such section names are supposed to
receive a suffix separated with a slash (e.g. "kprobe/"), using sizeof()
takes the final NUL character of the reference string into account,
which implies that both strings must be equal. Instead, the desired
behaviour would consist in taking the length of the string, *without*
accounting for the ending NUL character, and to make sure the reference
string is a prefix to the ELF section name.
Subtract 1 to the total size of the string for obtaining the length for
the comparison.
Fixes: 583c90097f72 ("libbpf: add ability to guess program type based on section name")
Signed-off-by: Quentin Monnet <redacted>
Acked-by: Jakub Kicinski <redacted>
---
tools/lib/bpf/libbpf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
@@ -132,22 +132,24 @@ nfp_bpf_check_call(struct nfp_prog *nfp_prog, struct bpf_verifier_env *env,caseBPF_FUNC_map_lookup_elem:if(!bpf->helpers.map_lookup){-pr_info("map_lookup: not supported by FW\n");+pr_vlog(env,"map_lookup: not supported by FW\n");return-EOPNOTSUPP;}if(reg2->type!=PTR_TO_STACK){-pr_info("map_lookup: unsupported key ptr type %d\n",+pr_vlog(env,+"map_lookup: unsupported key ptr type %d\n",reg2->type);return-EOPNOTSUPP;}if(!tnum_is_const(reg2->var_off)){-pr_info("map_lookup: variable key pointer\n");+pr_vlog(env,"map_lookup: variable key pointer\n");return-EOPNOTSUPP;}off=reg2->var_off.value+reg2->off;if(-off%4){-pr_info("map_lookup: unaligned stack pointer %lld\n",+pr_vlog(env,+"map_lookup: unaligned stack pointer %lld\n",-off);return-EOPNOTSUPP;}
@@ -160,7 +162,7 @@ nfp_bpf_check_call(struct nfp_prog *nfp_prog, struct bpf_verifier_env *env,meta->arg2_var_off|=off!=old_off;if(meta->arg1.map_ptr!=reg1->map_ptr){-pr_info("map_lookup: called for different map\n");+pr_vlog(env,"map_lookup: called for different map\n");return-EOPNOTSUPP;}break;
@@ -263,7 +265,7 @@ nfp_bpf_check_ptr(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta,if(reg->type==PTR_TO_MAP_VALUE){if(is_mbpf_store(meta)){-pr_info("map writes not supported\n");+pr_vlog(env,"map writes not supported\n");return-EOPNOTSUPP;}}
From: Jakub Kicinski <hidden> Date: 2018-01-16 23:52:59
From: Quentin Monnet <redacted>
If an eBPF instruction is unknown to the driver JIT compiler, we can
reject the program at verification time.
Signed-off-by: Quentin Monnet <redacted>
Reviewed-by: Jakub Kicinski <redacted>
Reviewed-by: Jiong Wang <redacted>
---
drivers/net/ethernet/netronome/nfp/bpf/jit.c | 5 +++++
drivers/net/ethernet/netronome/nfp/bpf/main.h | 1 +
drivers/net/ethernet/netronome/nfp/bpf/verifier.c | 6 ++++++
3 files changed, 12 insertions(+)
From: Daniel Borkmann <daniel@iogearbox.net> Date: 2018-01-17 01:03:38
On 01/17/2018 12:51 AM, Jakub Kicinski wrote:
Hi!
This series combines a number of random improvements ranging from
libbpf to nfp driver. NFP patches make better use of the verifier
log. There is a requested adjustment to the map offload code, and
a warning fix for a W=1 build to the disassembler. Quentin also
fixes the libbpf program type detection, while Jiong allows the use
of libbfd compiled from source.