From nobody Thu Apr 9 12:06:17 2026 Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5648636657C for ; Mon, 9 Mar 2026 07:53:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773042819; cv=none; b=NyAhU72B5vKV6MreM7uw9jiQUXGcOGE/eRweDPk8EURLgQQbAxx1tMHr6RrqlekXxHa2TjfsFlYiPuO/OCpj5WXvek8eZeoHoCYrDXq5SlwCdNHD5UXkQXHYTZR4jWTr7pbeft43HOhuQq61gfq7TvwODsyCk4RPY+L4oVYZP2M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773042819; c=relaxed/simple; bh=RSNECjlgnfgB9+OwiBeAKkvgniS+mPDTRDcPQ0uEfg8=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=jGOSd16//xhn/UAQccLK4+yvoB7MvtGm93Hto2kKuigs62W3ypavcZzKnG8QKxjNvTysByc8Uh7vcG4Nk01mVZKdxNXDIY3GhQI5Cre6+q1vbUq7VijYLFLEJUvjaWN/iDEKn1sfBOeCpkTjbv9yRhjH6efUjQd+sgnaHh70i5Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.161.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oo1-f72.google.com with SMTP id 006d021491bc7-67bb58103daso3701430eaf.2 for ; Mon, 09 Mar 2026 00:53:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773042817; x=1773647617; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IHN7Zbhr9JKeE4Ci70X93h3xBqN7NosntKTxsD0L3xU=; b=WY53ImPQSvYndN+PSOBp85DsM/0KFD1ZDkwvEhqnEX6J0OvRp83bqQLzEIsPD1uWqi KZrGMaHeisGiSIhMaC28q2V6sh2XBFool9f2irLXdsKnhW2mNWN3iDRdDpO2pR6ZI6lD uSe4rkJu5OSMcw7cMMFBiLxj6QlTXogniUlGSuRf/75Q3Rcd+ZVkQyFvFqW17PCsbrwW XqVDNN60/7lSCMbskhid5QayHwuUkdaBw60o+10p2Q9Jy/HobI+zlfSxspgSaEbst5ij TKDiKkwNpGq8KMfyS4acWFE/NcNzW577Gk+nVBKLWSF900HHDM8BwslYuQM+HMTM3IgH d7zg== X-Gm-Message-State: AOJu0YzZklhdLI1AdoMHEsfCFh2ir4iXKqyV0dmS+eiictXkcM2f/aNj lnWPSStfkxVKONzq822SWKIgbo07DCQ3gXUAaWjMTzo045voB3cmBFXWytePAdrwICMbCSqHbTm 9EYEWrLYo1+Wr2l1eyO4NH3qQdfesBr6sg7Ju+xIWRVcWBFtncK1PF7NcOvU= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:4b95:b0:679:a4fe:f01e with SMTP id 006d021491bc7-67b9bc686a4mr6760472eaf.1.1773042817453; Mon, 09 Mar 2026 00:53:37 -0700 (PDT) Date: Mon, 09 Mar 2026 00:53:37 -0700 In-Reply-To: <69ad7ccb.a00a0220.b130.0003.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69ae7c81.050a0220.310d8.001c.GAE@google.com> Subject: Forwarded: [PATCH] atm: lec: fix use-after-free in sock_def_readable() From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] atm: lec: fix use-after-free in sock_def_readable() Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master A race condition exists between lec_atm_close() setting priv->lecd =3D NULL and concurrent access to priv->lecd in send_to_lecd(), lec_handle_bridge(), and lec_atm_send(). When the socket is freed via RCU while another thread is still using it, a use-after-free occurs in sock_def_readable() when accessing the socket's wait queue. The root cause is that lec_atm_close() clears priv->lecd without holding lec_arp_lock, while callers dereference priv->lecd without any protection against concurrent teardown. Fix this by: - Protecting priv->lecd =3D NULL in lec_atm_close() with lec_arp_lock to synchronize with callers that already hold the lock (e.g. lec_arp_resolve) - Using sock_hold/sock_put in send_to_lecd() to pin the socket while in use. This is safe because send_to_lecd() is called under lec_arp_lock by lec_arp_resolve(), preventing concurrent NULL assignment of lecd. - Using lec_arp_lock + sock_hold/sock_put in lec_handle_bridge() and lec_atm_send() where the lock is not held by the caller, with proper skb cleanup on early exit to avoid memory leaks. Reported-by: syzbot+f50072212ab792c86925@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Df50072212ab792c86925 Signed-off-by: Deepanshu Kartikey --- net/atm/lec.c | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/net/atm/lec.c b/net/atm/lec.c index fb93c6e1c329..7e051174a92b 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c @@ -131,6 +131,7 @@ static void lec_handle_bridge(struct sk_buff *skb, stru= ct net_device *dev) { char *buff; struct lec_priv *priv; + unsigned long flags; =20 /* * Check if this is a BPDU. If so, ask zeppelin to send @@ -154,10 +155,19 @@ static void lec_handle_bridge(struct sk_buff *skb, st= ruct net_device *dev) /* 0x01 is topology change */ =20 priv =3D netdev_priv(dev); - atm_force_charge(priv->lecd, skb2->truesize); + spin_lock_irqsave(&priv->lec_arp_lock, flags); + if (!priv->lecd) { + spin_unlock_irqrestore(&priv->lec_arp_lock, flags); + kfree_skb(skb2); + return; + } sk =3D sk_atm(priv->lecd); + sock_hold(sk); + spin_unlock_irqrestore(&priv->lec_arp_lock, flags); + atm_force_charge(priv->lecd, skb2->truesize); skb_queue_tail(&sk->sk_receive_queue, skb2); sk->sk_data_ready(sk); + sock_put(sk); } } #endif /* IS_ENABLED(CONFIG_BRIDGE) */ @@ -441,7 +451,7 @@ static int lec_atm_send(struct atm_vcc *vcc, struct sk_= buff *skb) /* hit from bridge table, send LE_ARP_RESPONSE */ struct sk_buff *skb2; struct sock *sk; - + unsigned long flags; pr_debug("%s: entry found, responding to zeppelin\n", dev->name); skb2 =3D alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC); @@ -449,10 +459,19 @@ static int lec_atm_send(struct atm_vcc *vcc, struct s= k_buff *skb) break; skb2->len =3D sizeof(struct atmlec_msg); skb_copy_to_linear_data(skb2, mesg, sizeof(*mesg)); - atm_force_charge(priv->lecd, skb2->truesize); + spin_lock_irqsave(&priv->lec_arp_lock, flags); + if (!priv->lecd) { + spin_unlock_irqrestore(&priv->lec_arp_lock, flags); + kfree_skb(skb2); + break; + } sk =3D sk_atm(priv->lecd); + sock_hold(sk); + spin_unlock_irqrestore(&priv->lec_arp_lock, flags); + atm_force_charge(priv->lecd, skb2->truesize); skb_queue_tail(&sk->sk_receive_queue, skb2); sk->sk_data_ready(sk); + sock_put(sk); } } #endif /* IS_ENABLED(CONFIG_BRIDGE) */ @@ -471,8 +490,11 @@ static void lec_atm_close(struct atm_vcc *vcc) struct sk_buff *skb; struct net_device *dev =3D (struct net_device *)vcc->proto_data; struct lec_priv *priv =3D netdev_priv(dev); + unsigned long flags; =20 + spin_lock_irqsave(&priv->lec_arp_lock, flags); priv->lecd =3D NULL; + spin_unlock_irqrestore(&priv->lec_arp_lock, flags); /* Do something needful? */ =20 netif_stop_queue(dev); @@ -534,6 +556,7 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type typ= e, =20 atm_force_charge(priv->lecd, skb->truesize); sk =3D sk_atm(priv->lecd); + sock_hold(sk); skb_queue_tail(&sk->sk_receive_queue, skb); sk->sk_data_ready(sk); =20 @@ -543,7 +566,7 @@ send_to_lecd(struct lec_priv *priv, atmlec_msg_type typ= e, skb_queue_tail(&sk->sk_receive_queue, data); sk->sk_data_ready(sk); } - + sock_put(sk); return 0; } =20 --=20 2.43.0