Re: [PATCH bpf-next v4 2/4] bpf: Improve error reporting for freplace attachment failure

Leon Hwang
2025-02-25T13:59:19Z

On 2025/2/25 06:08, Andrii Nakryiko wrote:
> On Mon, Feb 24, 2025 at 11:41 AM Alexei Starovoitov
> <alexei.starovoitov@gmail.com> wrote:
>>
>> On Mon, Feb 24, 2025 at 7:34 AM Leon Hwang <leon.hwang@linux.dev> wrote:
>>>
>>> @@ -3539,7 +3540,7 @@ static int bpf_tracing_prog_attach(struct bpf_prog *prog,
>>> */
>>> struct bpf_attach_target_info tgt_info = {};
>>>
>>> - err = bpf_check_attach_target(NULL, prog, tgt_prog, btf_id,
>>> + err = bpf_check_attach_target(log, prog, tgt_prog, btf_id,
>>> &tgt_info);
>>
>> I still don't like this uapi addition.
>>
>> It only helps a rare corner case of freplace usage:
>> /* If there is no saved target, or the specified target is
>> * different from the destination specified at load time, we
>> * need a new trampoline and a check for compatibility
>> */
>>
>> If it was useful in more than one case we could consider it,
>> but uapi addition for a single rare use, is imo wrong trade off.
>
> Agreed. I think the idea of verbose log is useful for bpf() syscall,
> given how complicated some of its conditions are. But it should be
> done more generically, ideally at syscall (or at least the entire BPF
> command) level, not for one particular kind of link.
>

Cool!

But, how can we achieve it?

Thanks,
Leon