From nobody Sun Feb 8 15:59:25 2026 Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.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 913E630B52E for ; Fri, 16 Jan 2026 07:42:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768549357; cv=none; b=ZdyARqLi36fWBtAS9xzlTAz1raVde4jdcdIGP26zIMrl1qymwU45tXHEhTxAlaygMS7EgP2upkJTUj17g2uHT5q937BezPLjI4xaCOUzh0YWe2T6ifoatrJ0xGFKGqBtVhMLEqOEq/U+XScd73o9A3FzhvsinUveuAR95vew+YM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768549357; c=relaxed/simple; bh=HuatoKiIBMzWypLoHGE1so8v5iyJb/D2teczeraUDVM=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=H4DhDdnAApbiIw5GB0XPRlKLDTV//kDQhvvtrI8O79+KC01uOxGhD7Qipy+sBzKUSk1Kwx7Lsp/AGmGga8xdnJyz5rD/003ibWni5NlkoeNFvojUSTh02UmMmbu9LfoBVxJDX3c1dX6XvsD5rm3Ev3oLBX016r86kY0MKzl2hDA= 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.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-oo1-f69.google.com with SMTP id 006d021491bc7-6611ad61ce9so440393eaf.0 for ; Thu, 15 Jan 2026 23:42:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768549354; x=1769154154; 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=EJGcvUKJerLr0n/A2TGB0PzMMlrQe4QBLJyozrE80Tb1IhTlDsB21nO0oIFkKG4WGT E+wlyGEjX2GeYA3X/eZfgDN+5cy04MSiOOHIAoReXCVnjbkHCE/WK3wkaZyEsOdyOwbk CXKkc1S67BQsUXUO2vLan45kp0NRKttHtQKMI0p1WEkifVGLFT2MfaOYp/e980zmpPZc gp3m78ae72a5DK0Dk86CefLhZbZ5HU9kUWKOEttKk/Y9A2A4cJmxnAWehFMiyI0/73zl q1veEiby7/D3iaqQJR8m6epyXOuW9Jfa9tQ69fJr9A/1PwlcfYQitUcVQAA9dPM0fCzp KXVQ== X-Gm-Message-State: AOJu0YwXFZuWuqqx0Bpg56+E8H5W1yGmg2y8PTiLCpHLnxgcXfyGZXFn fiA84iKmo1+RYUljWxXaEnQzS1pp76AJ/Ln/ZgwFoxwAywrE5+bQmeqqMwVg2aBTXlBJ35DqWCq Z6E/1dCAfdJ/qHBLTL60lp3l/0PezXeVUEVyfq7ymjg1cEPel2OsOq5Il6S8= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a4a:a544:0:b0:661:8a3:ad19 with SMTP id 006d021491bc7-6610e65399fmr3028016eaf.30.1768549354587; Thu, 15 Jan 2026 23:42:34 -0800 (PST) Date: Thu, 15 Jan 2026 23:42:34 -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: <6969ebea.050a0220.58bed.0040.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