On Tue, Aug 16, 2022 at 2:33 PM Hao Luo <haoluo@xxxxxxxxxx> wrote: > > On Mon, Aug 15, 2022 at 8:53 PM Andrii Nakryiko <andrii@xxxxxxxxxx> wrote: > > > > Make sure that entire libbpf code base is initializing bpf_attr and > > perf_event_attr with memset(0). Also for bpf_attr make sure we > > clear and pass to kernel only relevant parts of bpf_attr. bpf_attr is > > a huge union of independent sub-command attributes, so there is no need > > to clear and pass entire union bpf_attr, which over time grows quite > > a lot and for most commands this growth is completely irrelevant. > > > > Few cases where we were relying on compiler initialization of BPF UAPI > > structs (like bpf_prog_info, bpf_map_info, etc) with `= {};` were > > switched to memset(0) pattern for future-proofing. > > > > Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx> > > --- > > Looks good to me. I went over all the functions in this change and Thanks! > verified the conversion is correct. There is only one question: I > noticed, for bpf_prog_load() and probe_memcg_account(), we only cover > up to fd_array and attach_btf_obj_fd. Should we cover up to the last > field i.e. core_relo_rec_size? libbpf never sets those fields, I think it's only used from light skeleton generated loaded BPF program, so I felt like it's unnecessary to include that yet > > Acked-by: Hao Luo <haoluo@xxxxxxxxxx> > > > > tools/lib/bpf/bpf.c | 173 ++++++++++++++++++++-------------- > > tools/lib/bpf/libbpf.c | 43 ++++++--- > > tools/lib/bpf/netlink.c | 3 +- > > tools/lib/bpf/skel_internal.h | 10 +- > > 4 files changed, 138 insertions(+), 91 deletions(-) > > [...]