From nobody Sat Feb 7 17:09:30 2026 Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) (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 3348F2F6193 for ; Tue, 3 Feb 2026 02:20:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770085253; cv=none; b=gO+TW32zN0cnAM7NIwhrJebvGN7AH1nhWPgnxHf8rBc4UYQIOHyNt+DeORcn46b7Y6/vXsyoqxWGzkDBySsi6B5rFTqRb3o1G2txGAciR64MofDq9oP9Wqyh78qaohlJyWkyHH03Q6fRqWYzdoE42GRgn+w3HGPKHchvv/nW4iM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770085253; c=relaxed/simple; bh=XzXGxAY3+hvOBubuRFnwt32d8yDz9HfIbvbLddXh1QQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=s4Dlg/w3sayLg5RYQJwnQ/qjshU9yrnO+thEfNWYz0Bj0hPgwGV6E1zCSwluLMRjavJBCwG+EK4Xtf3z0CZ8rAOhAAbPZZ3Pne7fmCX5navs08YXlHV0xL3bgyz5v46voEz4zUvhX/bLyGIGDlNOfFFUDidDpDh6hYBZXayFfIM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=AeblHinS; arc=none smtp.client-ip=209.85.215.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AeblHinS" Received: by mail-pg1-f173.google.com with SMTP id 41be03b00d2f7-c075ec1a58aso2112223a12.0 for ; Mon, 02 Feb 2026 18:20:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770085241; x=1770690041; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=iz/BewUOL5mTCy3HXx+oHUtEMSk6DW46tY5mVHCh/Oo=; b=AeblHinSIk8il0+BVmHiUQrzo1pt8GOI91OkwZ78DVzwRypxfzzg58ZAUxLc01uM5V waCOl3IMvoL7Fd7tVkBLjTX+J+bFpQi++rCyXjd2E1oT3GtSQ7ILqjTEdxTiJA/T0yb/ SmDvRLwqnnGfUR5V8Bm2F7aCsTK9uHEV9hyDrFIUb4eWqgRMbIdynXjQ7D2La+FsSYuh JbwJMjudVniQRXaPNRFmpIkPKKEl90OMVriWSYCprdO7IxDyQM2rIjj/+DOL4pn4vvw0 p/S14ITMpzk0hdhBA6mpR7OA6G2bBvpqRsHRfbjgTuGBQsdbOISXA4v/S4NB7PEUMcFV lvcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770085241; x=1770690041; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=iz/BewUOL5mTCy3HXx+oHUtEMSk6DW46tY5mVHCh/Oo=; b=tSAE1TC/ix6SpoYe66CD+FKIXcZFrmuQ0TkF+nmT6sf3QW5O6QuYcDFKMMpjJSdk4x 7wzjCR3kVRKSCgvyTyFF//cHzApprStYivF8teoTdj4MHtFHOyCPAEFhME0YSbCJql7C 4OnKhvdNaZ5M5+9MXO0RdWFapQvSAM7Relx9ATz65o6zvbPzs7whhVKcnrIgCRNIIBHA P81BWEQ5y9nX6u/UCGBt4iyeL4/15YPRc/1YhTx2mU/WZzahR453eu5U1x2exJJ2ACIC 35xdzPmxEP/xPyuV1B/RcOnOKjfYrcduYDdUxoBgM5NWBBf2N30L/sPXBghiNpmJzBTK j08w== X-Forwarded-Encrypted: i=1; AJvYcCWe74TMb+EPIt+0Gvo9Yf5uIvUcz4sRbQ/8IFidMvytJmZGou62tkxcwRj8rLrPxKE0X3PmoATPmVkSuU4=@vger.kernel.org X-Gm-Message-State: AOJu0YzMQJn4HFlhfxmBFXoWYiRD6KzrikyxS28arf/knBnMSh5kFHV9 Qn1yZ78YvFYXlxM9eJo+36T6s1Eiv2wRSiwV1KmrfycRPxH7KOXUSuO+ X-Gm-Gg: AZuq6aLzCydua3DJtrZ9mP+XnACayDA+diCpUE1rpOmf+GVqgxVyn1Y4D6O5qDz7GSt nLMt0eErjx6enjs9+eg64EXrrP/z0kX8sjTaoGkSL3sb3ytR2kSdWAe6pA1P2s2MK7JsSNR7Pn5 ixcuBbWO+bcdkfN55o3KfMtqjDr0kDauKy7AmP4JHW1CE0TpoX30y6kwHWwJ1JA77pD8dQNqTlw yJTSfgyO+4UJTwvtTXF//ueaCMDJD08cl7MBOmUtoGjOKNezaiRDoe8f/X1yLoxiLcK8MmmXdMP SEAcjer9BUsgC8O2KAJkhzgzqBu3G+IlqbJoq6hweTgzR9jMdO6knE03fhsbRnm7gvQbqEBHQtQ SA2Ox0WR6VRkfBGKo7ANv4If2qBYlP5OOu6HlxND6jtSFXDu7InRGOvfGfDnZXzVf+4veGEv1zv CKLwb4uDfDxVshTAXePhydujlwCC/rUu9dp/gS1psMSSIN//5o1rZMQ4bcZyaOmfqj3C0= X-Received: by 2002:a17:902:ccc7:b0:2a1:3cd8:d2dc with SMTP id d9443c01a7336-2a8d9951c06mr131932585ad.57.1770085241336; Mon, 02 Feb 2026 18:20:41 -0800 (PST) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:210f:e92c:6af6:77e9]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a8ec56da8esm83828205ad.13.2026.02.02.18.20.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Feb 2026 18:20:40 -0800 (PST) From: Deepanshu Kartikey To: agruenba@redhat.com Cc: gfs2@lists.linux.dev, linux-kernel@vger.kernel.org, Deepanshu Kartikey , syzbot+aac438d7a1c44071e04b@syzkaller.appspotmail.com Subject: [PATCH v2] gfs2: fix memory leaks in gfs2_fill_super error path Date: Tue, 3 Feb 2026 07:50:33 +0530 Message-ID: <20260203022033.101652-1-kartikey406@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Fix two memory leaks in the gfs2_fill_super() error handling path when transitioning a filesystem to read-write mode fails. First leak: kthread objects (thread_struct, task_struct, etc.) When gfs2_freeze_lock_shared() fails after init_threads() succeeds, the created kernel threads (logd and quotad) are never destroyed. This occurs because the fail_per_node label doesn't call gfs2_destroy_threads(). Second leak: quota bitmap buffer (8192 bytes) When gfs2_make_fs_rw() fails after gfs2_quota_init() succeeds but before other operations complete, the allocated quota bitmap is never freed. The fix moves thread cleanup to the fail_per_node label to handle all error paths uniformly. gfs2_destroy_threads() is safe to call unconditionally as it checks for NULL pointers. Quota cleanup is added in gfs2_make_fs_rw() to properly handle the withdrawal case where quota initialization succeeds but the filesystem is then withdrawn. Thread leak backtrace (gfs2_freeze_lock_shared failure): unreferenced object 0xffff88801d7bca80 (size 4480): copy_process+0x3a1/0x4670 kernel/fork.c:2422 kernel_clone+0xf3/0x6e0 kernel/fork.c:2779 kthread_create_on_node+0x100/0x150 kernel/kthread.c:478 init_threads+0xab/0x350 fs/gfs2/ops_fstype.c:611 gfs2_fill_super+0xe5c/0x1240 fs/gfs2/ops_fstype.c:1265 Quota leak backtrace (gfs2_make_fs_rw failure): unreferenced object 0xffff88812de7c000 (size 8192): gfs2_quota_init+0xe5/0x820 fs/gfs2/quota.c:1409 gfs2_make_fs_rw+0x7a/0xe0 fs/gfs2/super.c:149 gfs2_fill_super+0xfbb/0x1240 fs/gfs2/ops_fstype.c:1275 Reported-by: syzbot+aac438d7a1c44071e04b@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Daac438d7a1c44071e04b Fixes: 6c7410f44961 ("gfs2: gfs2_freeze_lock_shared cleanup") Fixes: b66f723bb552 ("gfs2: Improve gfs2_make_fs_rw error handling") Link: https://lore.kernel.org/all/20260131062509.77974-1-kartikey406@gmail.= com/T/ [v1] Signed-off-by: Deepanshu Kartikey --- Changes in v2: - Moved quota cleanup to gfs2_make_fs_rw() as suggested by Andreas Gruenbacher - Removed conditional check for gfs2_destroy_threads() as it's safe to call unconditionally --- fs/gfs2/ops_fstype.c | 2 +- fs/gfs2/super.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index e7a88b717991..c7d57de7c8f0 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -1276,7 +1276,6 @@ static int gfs2_fill_super(struct super_block *sb, st= ruct fs_context *fc) =20 if (error) { gfs2_freeze_unlock(sdp); - gfs2_destroy_threads(sdp); fs_err(sdp, "can't make FS RW: %d\n", error); goto fail_per_node; } @@ -1286,6 +1285,7 @@ static int gfs2_fill_super(struct super_block *sb, st= ruct fs_context *fc) =20 fail_per_node: init_per_node(sdp, UNDO); + gfs2_destroy_threads(sdp); fail_inodes: init_inodes(sdp, UNDO); fail_sb: diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index f6cd907b3ec6..d96160636161 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -147,8 +147,10 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp) } =20 error =3D gfs2_quota_init(sdp); - if (!error && gfs2_withdrawn(sdp)) + if (!error && gfs2_withdrawn(sdp)) { + gfs2_quota_cleanup(sdp); error =3D -EIO; + } if (!error) set_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags); return error; --=20 2.43.0