From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pz2-f1.google.com (mail-pz2-f1.google.com [74.125.228.1]) (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 BF2AB21257F for ; Wed, 1 Jul 2026 02:40:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.228.1 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782873628; cv=none; b=ULW2nXQZYs6kUW1SjLRLDHGm6sTXrWPvO6JdYo165govnLPb2zTfaZhZ1wiKmDYtqonka5G3sw3Xzg4oKgzjX78qg9IWH00Us7OdO+gAdMP34nDzz8QuhOFgYoiyMRtwUCcdXMbY93ux9ZMSfAkGZObLDySTBjqY74cti8nAKJg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782873628; c=relaxed/simple; bh=KlZmsPTkB0n0u0fKmWXR8kjnuoFqZfpLYwrSeWK3vnU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Q+UGjDxcps3VMVEdALLBSpaikRE2TJ9oz0Z50C5IXeHcfxR12wDGfVFx/hcTrRVCpGEN4bH9GyaLdz1Mm8mGiBfq6BSHyzisUjuNWT4ZVBfbF9UdRSWysLD60I3Mp0OGspUVs1tQcaen3WFIeWvkRHPM0/NeeTbsMpYp0BukQsI= 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=nYnDkSJS; arc=none smtp.client-ip=74.125.228.1 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="nYnDkSJS" Received: by mail-pz2-f1.google.com with SMTP id 41be03b00d2f7-c888c19b877so16836a12.1 for ; Tue, 30 Jun 2026 19:40:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782873626; x=1783478426; 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=1M12G1o5AjfK0yFtv/jTc552L2lTlPkEf7G2w5ynxwU=; b=nYnDkSJS0ODLTRu6vOqql4t8XUgi2g4rbiPNtK60Q7D2S5CxUEjO+CCjKvGhecHGkJ Qd1PMvBefhwS0M4NmzXm/yVQ2EKLOfE5Z6PLP7RbejCFh9ICNHWVgf4f7j1hDuGwN16L uH9FimuKmp5fuZtdFSQHAJ9/LmusdQ2FBAe0hvpE+NheX52gkvP2JU/130IraIN/y2P9 z/X4fWYS3IZ8Xcyexo+SA1WQ4PeGzMJ3kFEgr4KbMIpHIO+8WAA45M6UBsNnPnNxm349 +nbjIwiD1EV3y39OJnu+Y46tURPlU5EoJSSytcPQQpWtFJ3VqoF9H9NJzrVW8Krspi6D IxyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782873626; x=1783478426; 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=1M12G1o5AjfK0yFtv/jTc552L2lTlPkEf7G2w5ynxwU=; b=psRfspoEigwwjnEKZVKAa0E7MSq8mKcf7r2+h02hlv5/P2HiT4iZVtPYJC2wGKXZzv TBSlxnawvZD3TEQF6e3rCtIdNGjYyXT9qEmEamyCptBWm52UJH2tQeWAannTZahiv9vT 4NTWR8qBMU8I/ld5xjd2oE2u29GdqSgJvNxZZu7+3MJMq4CTjC8r3qQbAdZhwdqswinu IWb4BNi4zlVcxq1XemhzUMrdQg+Z1bPIprUm5/AwI3EPsJXL5Dw+dANT648yLKYl5OTT 2NwCabva2mN9XvdkIgfXG0IsFhVskEfmoYjWoKF4mu4+EZBXpLpDsjnGpy1ZHwzlzRhM iaXw== X-Forwarded-Encrypted: i=1; AHgh+Rq8Ig5T0wZXrKk7Xw6tNw9rbGm7x7nb9shPgy9CQrPjWkTU2abFEeC8KJHHCZmZ5LXhtFPF2ptRupr8uRk=@vger.kernel.org X-Gm-Message-State: AOJu0Yx1whR3aenFuakpB2X56RdpFwToo2OwPoAxDlhatGXt/omj4G/p fDHkSIHRgw2zv8rLNVmcq6WMYiWQztL2fgGAOpwl3S3tErX/BEfiFXS7 X-Gm-Gg: AfdE7ckDsVkksIDFnK1La+wPUERqEC2zHlyloM+FifPp8x5fmGa6kLlYZRuhqCPjDtN B4ui89UkUscRuLzsvaQcsvEwEvQztKzJ2GrmPtqrHUIJ2b/JuLTh+E7YuwlgV6wMX5dlBfj5mHJ so7zXBTpoL0Wm7V83KVzNs57g///sR1Jwo0/UCLiXkh7e76o1dOrwbmEakjJzW3UYkSZIQfijQM 46iJec6ksMa1mUtkY7O2lm4u0RUMubtQVccnwb+XYryclq1UjgavIyh8XigWZkQlPm85hJfNJ4n T9M27GXziGdCpGDLki+pjIeYv03z85WL5xwzt7VsOH+Vea3n+avYTnt+wFte0CwmIUDmF+dR5kq ez5it4wWngtDagBxtWCi2lzooEioYRTtjTihpvQ70ZYUMAncgrcHiH/jqhSGowLFELkELnmzE0S luaxECEDj7T6HgjmYa0Hbji83SwBHCtIpj X-Received: by 2002:a05:6a00:4c86:b0:845:d286:1fb8 with SMTP id d2e1a72fcca58-847adf22b13mr2798754b3a.54.1782873625945; Tue, 30 Jun 2026 19:40:25 -0700 (PDT) Received: from LAPTOP-1HUHJV8R.lan ([122.230.221.89]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8479fff4c7csm3107037b3a.16.2026.06.30.19.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2026 19:40:25 -0700 (PDT) From: l1za0.sec@gmail.com To: shaggy@kernel.org Cc: brauner@kernel.org, mjguzik@gmail.com, ssrane_b23@ee.vjti.ac.in, yun.zhou@windriver.com, koike@igalia.com, jfs-discussion@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] jfs: fix use-after-free in jfs_lazycommit Date: Wed, 1 Jul 2026 10:40:18 +0800 Message-ID: <20260701024018.14427-1-l1za0.sec@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Haocheng Yu A KASAN: slab-use-after-free Read in jfs_lazycommit is found by a modified Syzkaller-based kernel fuzzing tool that we developed. This issue is caused by a race condition between fs/jfs/jfs_txnmgr.c:jfs_lazycommit() and fs/jfs/super.c:jfs_put_super(). In jfs_lazycommit(), the commit thread reads struct jfs_sb_info from tblk->sb and accesses sbi->commit_state. At the same time, if another thread unmounts the file system and frees the corresponding sbi, then jfs_lazycommit() might access a freed sbi and trigger a use-after-free read. To fix this vulnerability, call txQuiesce() and txDrain() in jfs_umount() and jfs_umount_rw() before freeing JFS state. Signed-off-by: Haocheng Yu --- fs/jfs/jfs_txnmgr.c | 29 +++++++++++++++++++++++++++++ fs/jfs/jfs_txnmgr.h | 1 + fs/jfs/jfs_umount.c | 9 +++++++++ 3 files changed, 39 insertions(+) diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c index 083dbbb0c326..3aa7f5787688 100644 --- a/fs/jfs/jfs_txnmgr.c +++ b/fs/jfs/jfs_txnmgr.c @@ -2874,6 +2874,35 @@ void txResume(struct super_block *sb) TXN_WAKEUP(&log->syncwait); } +void txDrain(struct super_block *sb) +{ + struct jfs_sb_info *sbi = JFS_SBI(sb); + struct tblock *tblk; + unsigned long flags; + bool pending; + + for (;;) { + pending = false; + LAZY_LOCK(flags); + if (sbi->commit_state & IN_LAZYCOMMIT) { + pending = true; + } else { + list_for_each_entry(tblk, &TxAnchor.unlock_queue, cqueue) { + if (tblk->sb == sb) { + pending = true; + break; + } + } + } + LAZY_UNLOCK(flags); + + if (!pending) + return; + + schedule_timeout_uninterruptible(1); + } +} + /* * jfs_sync(void) * diff --git a/fs/jfs/jfs_txnmgr.h b/fs/jfs/jfs_txnmgr.h index ba71eb5ced56..55cda4aa3691 100644 --- a/fs/jfs/jfs_txnmgr.h +++ b/fs/jfs/jfs_txnmgr.h @@ -293,6 +293,7 @@ extern int lmLog(struct jfs_log *, struct tblock *, struct lrd *, extern void txQuiesce(struct super_block *); extern void txResume(struct super_block *); extern void txLazyUnlock(struct tblock *); +extern void txDrain(struct super_block *sb); extern int jfs_lazycommit(void *); extern int jfs_sync(void *); #endif /* _H_JFS_TXNMGR */ diff --git a/fs/jfs/jfs_umount.c b/fs/jfs/jfs_umount.c index 18569f1eaabd..6d332c8b85be 100644 --- a/fs/jfs/jfs_umount.c +++ b/fs/jfs/jfs_umount.c @@ -23,6 +23,7 @@ #include "jfs_logmgr.h" #include "jfs_metapage.h" #include "jfs_debug.h" +#include "jfs_txnmgr.h" /* * NAME: jfs_umount(vfsp, flags, crp) @@ -52,11 +53,17 @@ int jfs_umount(struct super_block *sb) * * if mounted read-write and log based recovery was enabled */ + if ((log = sbi->log)) + txQuiesce(sb); + + if (log) /* * Wait for outstanding transactions to be written to log: */ jfs_flush_journal(log, 2); + + txDrain(sb); /* * Hold log lock so write_special_inodes (lmLogSync) cannot see @@ -141,7 +148,9 @@ int jfs_umount_rw(struct super_block *sb) * * remove file system from log active file system list. */ + txQuiesce(sb); jfs_flush_journal(log, 2); + txDrain(sb); /* * Make sure all metadata makes it to disk base-commit: f1a5e78a55ebf2b05777fd5eb738038ddae609d6 -- 2.51.0