From nobody Sun Feb 8 15:59:17 2026 Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) (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 DA6B1B67E for ; Fri, 16 Jan 2026 08:28:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768552111; cv=none; b=W3eJmCO8jK+W/Fdup7nEEFaah4rvS43JGBbvEarKBcNji3XKM/CBB+UOM4JX0DRDKm6Bv36r2+DVxlSCsMmczqc+ImMYufYkfjv26yknnvHOGuM03HgzFYH6ATSwLK0ZJ7+qeZtlzSAmzyMlFLHuXi58rHUl7Y7joczxrvrSwJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768552111; c=relaxed/simple; bh=HuatoKiIBMzWypLoHGE1so8v5iyJb/D2teczeraUDVM=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=uu4V5zCaVKAh6K/sEgtBr9S5EPh3LDPuzeCGnbIsBvbh0nvys/xcREdvxx2BJUBLrn2gwupHIPPV+pHBzqGXoEV1iv1UCofhJ+sAQSHyRUdf+mnoqov5sbBckG1uqlrjmUfNwAyrpcgV64aXm2Uu54vvLRUwQQWBe+CRYvWZb0s= 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.160.69 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-oa1-f69.google.com with SMTP id 586e51a60fabf-4041c362f15so4045082fac.0 for ; Fri, 16 Jan 2026 00:28:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768552109; x=1769156909; 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=zLXxA49r53z3lVq8Jis4FU3es+CvqpcO4v/rHCQ4tKY=; b=cip5N3O9D6mIlg3H+hptxisK1/0nwp7jnnM0EKlRo2QMR5s9+cRyJl/bVpaQshMm1m XiBULe2PUeB5ZE5U0gz7YkNzNrWQrK97TiUdbaRtYhk8g6GzEWu/kHA9qOPgQrqfF28C t64QGy+Bmxa3aS0X3uMclC138XMDo9oOzcdyKaE8YZcRbCkICXJe9inEf+p75Rwx1fPt xg3tsGRTxTi/9a7awUw5XT5P9QuGZx8jq0IGedswZnCGKzqM50GymFTDFOs0F9ENUPqG sDdQnU1wbshBAiHEnxvHQTN55XjF8AM34wuZHS07xegb1VLXzlfgHZfaGVOQQ+cRqeiW nRww== X-Gm-Message-State: AOJu0YwqeGf53TVEVOtTdmOGLj/jiMqnXSSlZ6+Tt0xtfMtG+SJFHGBO 3PmEMHRE+M7gg3atFCOiz28LivjZZLnUUOWyU6spdW7yrOOZRVnyQJzghaCIlcGmY02zKihCBrg M53AeHE3oUoRl//UwzG7j9KrtXZxe4TgymRp6AtI/FVHr2Tdxm8dst1pwOiI= 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:2017:b0:660:ff2c:d772 with SMTP id 006d021491bc7-66117a47547mr1035869eaf.80.1768552108874; Fri, 16 Jan 2026 00:28:28 -0800 (PST) Date: Fri, 16 Jan 2026 00:28:28 -0800 In-Reply-To: <69694849.050a0220.58bed.0025.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6969f6ac.050a0220.58bed.0042.GAE@google.com> Subject: Forwarded: [PATCH] netrom: fix memory leak in nr_add_node() 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] netrom: fix memory leak in nr_add_node() Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master When nr_add_node() creates a new neighbor but the route quality is too low to be added (node already has 3 routes with better quality), the newly allocated neighbor is never used but remains in the neighbor list with refcount=3D1, causing a memory leak. Also fix the same leak in the error path when nr_node allocation fails after creating a new neighbor. Fix by tracking whether a new neighbor was allocated and removing it from the list if it was not used (count =3D=3D 0) or on allocation failure. Add debug printk to trace the issue. Reported-by: syzbot+3f2d46b6e62b8dd546d3@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D3f2d46b6e62b8dd546d3 Signed-off-by: Deepanshu Kartikey --- net/netrom/nr_route.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index b94cb2ffbaf8..b5f6b41e34e5 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c @@ -100,9 +100,12 @@ static int __must_check nr_add_node(ax25_address *nr, = const char *mnemonic, { struct nr_node *nr_node; struct nr_neigh *nr_neigh; + bool new_neigh =3D false; int i, found; struct net_device *odev; =20 + printk(KERN_ERR "nr_add_node: PATCHED VERSION called\n"); + if ((odev=3Dnr_dev_get(nr)) !=3D NULL) { /* Can't add routes to ourself */ dev_put(odev); return -EINVAL; @@ -172,6 +175,7 @@ static int __must_check nr_add_node(ax25_address *nr, c= onst char *mnemonic, } } =20 + new_neigh =3D true; spin_lock_bh(&nr_neigh_list_lock); hlist_add_head(&nr_neigh->neigh_node, &nr_neigh_list); nr_neigh_hold(nr_neigh); @@ -183,8 +187,11 @@ static int __must_check nr_add_node(ax25_address *nr, = const char *mnemonic, =20 if (nr_node =3D=3D NULL) { if ((nr_node =3D kmalloc(sizeof(*nr_node), GFP_ATOMIC)) =3D=3D NULL) { - if (nr_neigh) + if (nr_neigh) { + if (new_neigh) + nr_remove_neigh(nr_neigh); nr_neigh_put(nr_neigh); + } return -ENOMEM; } =20 @@ -279,6 +286,13 @@ static int __must_check nr_add_node(ax25_address *nr, = const char *mnemonic, } } =20 + if (new_neigh && nr_neigh->count =3D=3D 0) { + printk(KERN_ERR "nr_add_node: cleaning up unused neighbor\n"); + nr_remove_neigh(nr_neigh); + } else if (new_neigh) { + printk(KERN_ERR "nr_add_node: new_neigh used, count=3D%d\n", nr_neigh->c= ount); + } + nr_neigh_put(nr_neigh); nr_node_unlock(nr_node); nr_node_put(nr_node); --=20 2.43.0