Re: [PATCH v2] kobject: fix use-after-free in tagged uevent broadcast
From: Greg KH
Date: Mon Nov 23 2026 - 09:12:35 EST
On Mon, Nov 23, 2026 at 04:16:50PM +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.
>
> Closes: https://syzkaller.appspot.com/bug?extid=7db35adbc02c5b86d4e0
> Fixes: 5c0941c55e5f ("kobject: reduce uevent_sock_mutex scope")
> Signed-off-by: Ömer Mete Kaya <omermetekaya0@xxxxxxxxx>
> ---
> v2: Add Closes: tag.
>
> lib/kobject_uevent.c | 30 ++++++++++++++++++++++--------
> 1 file changed, 22 insertions(+), 8 deletions(-)
>
> diff --git a/lib/kobject_uevent.c b/lib/kobject_uevent.c
> index ddbc4d7482d2..fd61307c045e 100644
> --- a/lib/kobject_uevent.c
> +++ b/lib/kobject_uevent.c
> @@ -411,9 +411,15 @@ static int kobject_uevent_net_broadcast(struct kobject *kobj,
> devpath);
> else {
> const struct net *net = container_of(ns, struct net, ns);
> + struct uevent_sock *ue_sk;
>
> - ret = uevent_net_broadcast_tagged(net->uevent_sock->sk, env,
> - action_string, devpath);
> + mutex_lock(&uevent_sock_mutex);
guard()?