Re: [PATCH] kobject: fix use-after-free in tagged uevent broadcast

From: Greg KH

Date: Sun Nov 22 2026 - 04:42:04 EST


On Sun, Nov 22, 2026 at 09:17:46AM +0300, Ömer Mete Kaya wrote:
> kobject_uevent_net_broadcast() accesses net->uevent_sock->sk without
> protection in the tagged (namespace-aware) path. During network namespace
> teardown, uevent_net_exit() frees the uevent_sock while a concurrent
> kobject_uevent_env() call can still reference it, causing a
> use-after-free.
>
> Extend uevent_sock_mutex to cover the tagged broadcast path and the
> netlink receive path, serializing them with teardown: in
> uevent_net_exit(), set net->uevent_sock to NULL under the mutex before
> releasing the socket. In the tagged broadcast path and in
> uevent_net_rcv_skb(), check for NULL under the same mutex before
> accessing the socket.
>
> Discovered by Sashiko, not triggered, not runtime tested.

Please test and get a reproducer before attempting such a change.

thanks,

greg k-h