Thread (14 messages) 14 messages, 4 authors, 3d ago

Re: [PATCH bpf-next v4 2/6] bpf: Add syscall common attrs support for xdp link_create

flat view

From: Leon Hwang <hidden>
Date: 2026-10-26 15:07:02
Also in: bpf, linux-kselftest, lkml, netdev

On 2026/10/25 09:19, Alexei Starovoitov wrote:
On Sat, Oct 24, 2026 at 08:36 AM Leon Hwang [off-list ref] wrote:
quoted
Instead of passing bpf log or extack to bpf_xdp_link_attach(), pass an
errmsg pointer to receive the kstrdup() error msg, because
[...]
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help