On Mon, Aug 15, 2022 at 02:59:50PM -0700, Andrii Nakryiko wrote: > I did a small adjustment to not fill out entire big bpf_attr union > completely (and added a bit more meaningful "libbpf_nametest" prog > name): > Thanks for the adjustment. Hangbin > $ git diff --staged > diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c > index 4a351897bdcc..f05dd61a8a7f 100644 > --- a/tools/lib/bpf/libbpf.c > +++ b/tools/lib/bpf/libbpf.c > @@ -4415,6 +4415,7 @@ static int probe_fd(int fd) > > static int probe_kern_prog_name(void) > { > + const size_t attr_sz = offsetofend(union bpf_attr, prog_name); > struct bpf_insn insns[] = { > BPF_MOV64_IMM(BPF_REG_0, 0), > BPF_EXIT_INSN(), > @@ -4422,12 +4423,12 @@ static int probe_kern_prog_name(void) > union bpf_attr attr; > int ret; > > - memset(&attr, 0, sizeof(attr)); > + memset(&attr, 0, attr_sz); > attr.prog_type = BPF_PROG_TYPE_SOCKET_FILTER; > attr.license = ptr_to_u64("GPL"); > attr.insns = ptr_to_u64(insns); > attr.insn_cnt = (__u32)ARRAY_SIZE(insns); > - libbpf_strlcpy(attr.prog_name, "test", sizeof(attr.prog_name)); > + libbpf_strlcpy(attr.prog_name, "libbpf_nametest", > sizeof(attr.prog_name)); > > Pushed to bpf-next, thanks!