On Sat, Sep 28, 2024 at 7:14 AM Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> wrote: > > On Sun, Sep 22, 2024 at 12:59 PM Tyrone Wu <wudevelops@xxxxxxxxx> wrote: > > > > Hello, > > > > When retrieving bpf_link_info.perf_event kprobe/uprobe/tracepoint > > data, I noticed that the name_len field always returns 0. After some > > digging, I see that name_len is never actually populated, which > > explains the 0 value. > > > > I expected it to function similarly to > > bpf_link_info.raw_tracepoint.tp_name_len, where that field is filled > > with the length of tp_name. However, I noticed that the selftest > > explicitly asserts that name_len should be 0. I was wondering if > > someone could clarify whether it is intended for the > > bpf_link_info.perf_event name_len field to not be populated. > > This sounds like a bug. It should behave consistently with the other > users of input/output string buffer size fields: on input we get > maximum buffer size, on output we should put an actual size of the > string (especially if it was truncated). > > Yafang, Jiri, WDYT? The reason name_len is 0 is that the user did not set both the buffer and the length. IOW, this happens when the user buffer is NULL and the input length is 0. However, we should make this behavior consistent by returning the actual size to the user if both the buffer and length are unset. I will submit a fix. -- Regards Yafang