Subject: Re: [PATCH bpf 1/2] xdp: check prog type before updating BPF link

From: Toke Høiland-Jørgensen <[email-masked]>
Date: Fri, 07 Jan 2022 22:26:07 +0100

Andrii Nakryiko <[email-masked]> writes:

> On Fri, Jan 7, 2022 at 10:31 AM Toke Høiland-Jørgensen <[email-masked]> wrote:
>>
>> The bpf_xdp_link_update() function didn't check the program type before
>> updating the program, which made it possible to install any program type as
>> an XDP program, which is obviously not good. Syzbot managed to trigger this
>> by swapping in an LWT program on the XDP hook which would crash in a helper
>> call.
>>
>> Fix this by adding a check and bailing out if the types don't match.
>>
>> Fixes: 026a4c28e1db ("bpf, xdp: Implement LINK_UPDATE for BPF XDP link")
>> Reported-by: [email-masked]
>> Signed-off-by: Toke Høiland-Jørgensen <[email-masked]>
>> ---
>
> The fix looks good to me, thanks. I'd love it if this was done
> generically in link_update, but each link type has its own locking
> schema for link->prog, so I didn't figure out a way to do this in a
> centralized way.

Yeah, moving it to be a generic check was my first thought as well, but
I came to the same conclusion :)

> Acked-by: Andrii Nakryiko <[email-masked]>

Thanks!

-Toke