From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) (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 6A1FD1FC8 for ; Tue, 30 Jun 2026 00:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.200 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782777977; cv=none; b=SDHGqSEnIf2mefvA0/5QgH0xxsz9qa8wUV4VgjnQ/jbXEYAOvVN3l/GYeclI9cdX9y/QgLzxELXCVrN8aDaa6dpMB6ftuiIdxNBPgVpKqP0vVvIdAv7JVMs/r142Pa6YTGkfPexdQJS+8BizSbk6c3XD7NQnpJRjn2Nz3GKpJtA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782777977; c=relaxed/simple; bh=q1U5KHVOPO1A50felywvEHrtoOo0bvnYcc7N0diEHn4=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=IQc7dH21xaz5z9JdFxJCm6vEsBCjlEl1o+6swa9lcnZJn+J1xs5AimDU7gRfrgwM3++AeCWg1FTKNavsVqpjkLIXZvI6Vm68gKmJe5HmmcXm9W57cbaP78ywEtmPR7tozgoTQqf9KbT/gmFx+/8rzJ3hyl7UJ/xnC/InuOCoxm8= 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.167.200 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-oi1-f200.google.com with SMTP id 5614622812f47-495b8b30310so3121138b6e.1 for ; Mon, 29 Jun 2026 17:06:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782777975; x=1783382775; h=content-type:to:from:subject:message-id:in-reply-to:date :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=ZMwkJ8GdmfxCvuedWzqTexJwFoOrSU+AOCXlTMf8QN4=; b=hum095xgWri04E7uruy19Aj/gD81bGN7EXf0h1Q1rzJWj1YbvW/EWKP2Y+vpYwxG5e UeENdcrNJ0ZhheOOtDvBAqIfw8Z+Rx9ne1XEcHEZVl8lmswxyOFIE42z2HxnwKSVXMWO Whbal1sg4+8I0mSxNQ++IBzYVBn4ewRv0lwPzdCpQ/Ty1dTgeZhWBXP55rCL/FOlhQgX t82RSadZOUrLcqrs9d05nYsHAuxyTadEk/WmMNd2GIhYY+pAHX2/xDqPi3f1Tebs76SP Houj+HO/Vl9gtfsn5Z/+rUBhNR8aCNPAHZJa7aWLbapVe/D4g9mIe6bdaIrRa1EmVn+5 lwaA== X-Gm-Message-State: AOJu0YxAv3M2nU/3bpx2uhg+xpS3LcICC4ciG1X1qFZZeH3WOGqFBIo7 Xu9z/dbz4B0kBWKAagM1HuzLFVgQ70tzy3B70GwWkrKt2wnmhhsh93HYKVXgBJuoa5uQWx8ZsEF 2NAbnlukfER8W735KnnDrL858OIA4Z7ZZZB4TpN6GXBOpl1tLXJpJAOzpIuk= 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:6808:1a22:b0:487:4f76:d404 with SMTP id 5614622812f47-495eadebe35mr1277774b6e.2.1782777975507; Mon, 29 Jun 2026 17:06:15 -0700 (PDT) Date: Mon, 29 Jun 2026 17:06:15 -0700 In-Reply-To: <6a42da14.b42ede87.8e801.0000.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a430877.854d4ab9.360e1d.000f.GAE@google.com> Subject: Forwarded: [PATCH] gfs2: fix null-ptr-deref in gfs2_quota_hold during unmount From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com 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] gfs2: fix null-ptr-deref in gfs2_quota_hold during unmount Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master gfs2_quota_cleanup() frees sd_quota_bitmap early in gfs2_put_super() before the iput() calls that can trigger inode eviction. When an unlinked inode is evicted during unmount, it goes through: gfs2_evict_inode() -> gfs2_dinode_dealloc() -> gfs2_quota_hold() -> qdsb_get() -> slot_get() -> find_first_zero_bit(sd_quota_bitmap) If sd_quota_bitmap has already been freed by gfs2_quota_cleanup(), this results in a null pointer dereference: KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] _find_first_zero_bit+0x29/0xb0 lib/find_bit.c:149 slot_get fs/gfs2/quota.c:355 qdsb_get+0x133/0x340 fs/gfs2/quota.c:522 gfs2_quota_hold+0x191/0x5c0 fs/gfs2/quota.c:606 gfs2_dinode_dealloc+0x176/0x3f0 fs/gfs2/inode.c:488 gfs2_evict_inode+0x11cd/0x1400 fs/gfs2/super.c:1479 gfs2_put_super+0x300/0x860 fs/gfs2/super.c:618 The same problem exists in both paths through gfs2_put_super(): the direct gfs2_quota_cleanup() call in the read-only branch, and indirectly via gfs2_make_fs_ro() in the read-write branch. Fix this by removing gfs2_quota_cleanup() from gfs2_make_fs_ro() and moving it to after all the iput() calls in gfs2_put_super(), ensuring sd_quota_bitmap remains valid for the entire duration of inode eviction. Restore an explicit gfs2_quota_cleanup() call in gfs2_reconfigure() after gfs2_make_fs_ro() to preserve the remount-ro cleanup behaviour. Reported-by: syzbot+cb79de2cc8b76fbf474f@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=cb79de2cc8b76fbf474f Signed-off-by: Deepanshu Kartikey --- fs/gfs2/ops_fstype.c | 1 + fs/gfs2/super.c | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 9b9e70f14d25..56bc966531f2 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c @@ -1592,6 +1592,7 @@ static int gfs2_reconfigure(struct fs_context *fc) if ((sb->s_flags ^ fc->sb_flags) & SB_RDONLY) { if (fc->sb_flags & SB_RDONLY) { gfs2_make_fs_ro(sdp); + gfs2_quota_cleanup(sdp); } else { error = gfs2_make_fs_rw(sdp); if (error) diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 4d854556b529..e13c9f9efe6c 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -565,7 +565,6 @@ void gfs2_make_fs_ro(struct gfs2_sbd *sdp) HZ * 5); gfs2_assert_warn(sdp, gfs2_log_is_empty(sdp)); } - gfs2_quota_cleanup(sdp); } /** @@ -604,8 +603,6 @@ static void gfs2_put_super(struct super_block *sb) else { if (gfs2_withdrawn(sdp)) gfs2_destroy_threads(sdp); - - gfs2_quota_cleanup(sdp); } /* At this point, we're through modifying the disk */ @@ -637,6 +634,8 @@ static void gfs2_put_super(struct super_block *sb) gfs2_glock_dq_uninit(&sdp->sd_live_gh); gfs2_clear_rgrpd(sdp); gfs2_jindex_free(sdp); + + gfs2_quota_cleanup(sdp); /* Take apart glock structures and buffer lists */ gfs2_gl_hash_clear(sdp); iput(sdp->sd_inode); -- 2.43.0