From nobody Sat Feb 7 19:08:33 2026 Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.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 12619345CC7 for ; Tue, 16 Dec 2025 08:02:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765872147; cv=none; b=A8+mjPMl9EZtmIjVPcAphFMgsykywJJZItIyg12nVua03MMkyQBNHHD9uJID5RJCXanSw9IoZugWDaVNqESaQgRVCqUJ/PA0bsCCH9q5DB8dJKCteeotU4N/pVpwbsSp50qPlX+zXhFtps/Nf98y1gORSY/W7D3oiDvBm30POmA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765872147; c=relaxed/simple; bh=VlZ6obthxDkxcHbDxdHDFpgT6Q48+lP9I9XCK2AShPs=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=ByfaaUT3p6FCykHAYyVS1adzofd++5EkWLvtHLTj5L+zlk/WBvlOEXMnAykjLJE91TtECNa1vw5MnhgXhlEdSJLcuP6CWFmPqtTA5OH6xqErHz6qFGy5TzqLMhXbMxEG77/3ioJXDc/m6V02nG9d3Yn3RadXTxO8SpCYZ5GNcfs= 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.210.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-ot1-f69.google.com with SMTP id 46e09a7af769-7c75290862cso9143526a34.2 for ; Tue, 16 Dec 2025 00:02:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765872141; x=1766476941; 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=QZKk1H2pB3Mj4sAh5e7XPICDJqe3wrl4RKz/fMzkNWA=; b=YutuXcETvYsOXSEk+j3LobIZYVGr/L9FrHrwuyIiSXwgdwLBEh7NxxPOR/pc9vV1HP rYpWfnWduwA7y/Ga3zIYv7hWhvL9+3+Yk1jfXMKtd2BdO+V9EyxJJ5aA9ht7+vyu9UxA Xqs5niM3z9Nj/i6weLknmiFmeZRov22eYExLeFYFJzWa5eA8Z43HxVa3DavRjlOz1KFL zIE/ahMOLNL6kMdwP1jICpgHmib0qySml8DoKe7fvkyUG5ITS7JNdpr2KRx+XflEOejM 3XsGsviQ+c5/rqmEOjxYxbVpTeFn19A9vCH6JOEm0LTXN6n06WWwCvcjl4njRadWx1+p FDfw== X-Gm-Message-State: AOJu0YzfnxaLAoMVgDhwOFbhkWsV0MTSB0xzIIZuvpXgEy8r7kunlYTu Aowy5+aN4lgkBLwtILOaegIzAkVRrtB47SQF9lrj1lPmvdS5BHxie4QvjmFN+2XNkbBa7o1ALBY JXVbD/xCRtdk3yLiopZwFtFKWlw8jsD8VRhavmHz0GHKZx9HT04FpZlzoIDc= X-Google-Smtp-Source: AGHT+IGGmnyp7i3PRw7bfJ5VWfqQB2nkhrZet53vqq8DHZGpqIJ/p8ftxoeDDy6xwO4PhX37qnCzgg3jvaiHHWRKCC3VSTo5V7fE 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:4c14:b0:659:9a49:8ece with SMTP id 006d021491bc7-65b4529d737mr5235634eaf.82.1765872141492; Tue, 16 Dec 2025 00:02:21 -0800 (PST) Date: Tue, 16 Dec 2025 00:02:21 -0800 In-Reply-To: <69410b4b.a70a0220.104cf0.0347.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6941120d.a70a0220.104cf0.0348.GAE@google.com> Subject: Forwarded: [PATCH] nfsd: fix memory leak in nfsd_create_serv error paths 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] nfsd: fix memory leak in nfsd_create_serv error paths Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master When svc_create_pooled() or svc_bind() fails, nfsd_create_serv() returns an error without calling percpu_ref_exit() to clean up the percpu reference that was initialized earlier in the function. This causes two memory leaks per failed call: - 8 bytes of percpu memory (the reference counter) - 64 bytes of slab memory (the percpu_ref_data structure) Fix this by adding an error label that calls percpu_ref_exit() before returning. Reported-by: syzbot+6ee3b889bdeada0a6226@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D6ee3b889bdeada0a6226 Signed-off-by: Deepanshu Kartikey --- fs/nfsd/nfssvc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index b08ae85d53ef..49fd77c8f98d 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c @@ -615,13 +615,14 @@ int nfsd_create_serv(struct net *net) serv =3D svc_create_pooled(nfsd_programs, ARRAY_SIZE(nfsd_programs), &nn->nfsd_svcstats, nfsd_max_blksize, nfsd); - if (serv =3D=3D NULL) - return -ENOMEM; - + if (serv =3D=3D NULL) { + error =3D -ENOMEM; + goto err_percpu; + } error =3D svc_bind(serv, net); if (error < 0) { svc_destroy(&serv); - return error; + goto err_percpu; } spin_lock(&nfsd_notifier_lock); nn->nfsd_serv =3D serv; @@ -636,6 +637,9 @@ int nfsd_create_serv(struct net *net) } nfsd_reset_write_verifier(nn); return 0; +err_percpu: + percpu_ref_exit(&nn->nfsd_net_ref); + return error; } =20 int nfsd_nrpools(struct net *net) --=20 2.43.0