On 2026/10/25 09:19, Alexei Starovoitov wrote:
> On Sat, Oct 24, 2026 at 08:36 AM Leon Hwang <[email protected]> wrote:
>> Instead of passing bpf log or extack to bpf_xdp_link_attach(), pass an
>> errmsg pointer to receive the kstrdup() error msg, because
> 
> [...]
> 
>> 2) passing extack will access underlying driver string out of dev_put()
>>    guard, which will crash kernel when the device is unloaded
>>    concurrently.
> 
> Netlink does exactly that.
> rtnl_setlink() looks up the dev with __dev_get_by_index(), so no refcnt,
> do_setlink() -> dev_change_xdp_fd(dev, extack, ...) calls into the same
> drivers that set the same strings, rtnl is unlocked, and only then
> netlink_rcv_skb() -> netlink_ack() does strlen(extack->_msg).
> All extack users work this way. kstrdup() in one of them fixes nothing.

Oops, I was overthinking about it when self-reviewing the patch. Failed
to verify the describing crash issue just now. I should verify my review
when self-reviewing.

> 
> Instead of patches 1 and 2:
> 

Will change like this.

> 
> I'm think I gave this suggestion earlier. Why did you go with strdup()?
> 

Sorry for my overthinking. Will verify my review to my patches in the
future.

Thanks,
Leon


Reply via email to