On Wed, Jan 24, 2024 at 11:55 AM Martin KaFai Lau <martin.lau@xxxxxxxxx> wrote: > > From: Martin KaFai Lau <martin.lau@xxxxxxxxxx> > > Passing -1 in value_type_btf_obj_fd to the kernel will break backward > compatibility. This patch fixes it by using 0 as the default. > > Cc: Kui-Feng Lee <thinker.li@xxxxxxxxx> > Reported-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > Fixes: 9e926acda0c2 ("libbpf: Find correct module BTFs for struct_ops maps and progs.") > Signed-off-by: Martin KaFai Lau <martin.lau@xxxxxxxxxx> > --- > tools/lib/bpf/bpf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c > index 3a35472a17c5..b133acfe08fb 100644 > --- a/tools/lib/bpf/bpf.c > +++ b/tools/lib/bpf/bpf.c > @@ -192,7 +192,7 @@ int bpf_map_create(enum bpf_map_type map_type, > attr.btf_key_type_id = OPTS_GET(opts, btf_key_type_id, 0); > attr.btf_value_type_id = OPTS_GET(opts, btf_value_type_id, 0); > attr.btf_vmlinux_value_type_id = OPTS_GET(opts, btf_vmlinux_value_type_id, 0); > - attr.value_type_btf_obj_fd = OPTS_GET(opts, value_type_btf_obj_fd, -1); > + attr.value_type_btf_obj_fd = OPTS_GET(opts, value_type_btf_obj_fd, 0); imo the commit log is too vague why it's ok to set this field to zero when it's not specified in opts. It took me some time to go through the kernel and libbpf bits to see that there is a BPF_F_VTYPE_BTF_OBJ_FD flag that gates the use of value_type_btf_obj_fd and fd=0 is not special. Please improve commit log and respin. Thanks