From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) (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 530743168EE for ; Sat, 9 May 2026 12:36:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.193 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778330170; cv=none; b=guAb2EuKqT7IH6iH7vPFxkGcrJnAv9NUni069xHmHqY/tVq144j0fLXIzChfCYhhdFC8Cb5fZ7M+jyLKPvBM0wXti9hIiRATTR7r7HM0e/hR4RvpJ4Ig+QwOo/urlM4l/sp9YAoFu2/6C/H3sYqUwTPwUXe0d6BGFZVxSSxW8Ao= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778330170; c=relaxed/simple; bh=KlZmsPTkB0n0u0fKmWXR8kjnuoFqZfpLYwrSeWK3vnU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ebw1P6nUOchqrB53LWIEmbYCjfIF1KemAi+EHksrNczVhySxtQkwN9tIEp1PoTjXAbYnyKUtv9NSlhhtFLG9hXRKDgc8vYNklhnyxToJJMq+O/C+5HffAJ3/DL24alL/MpfELr98TRN6dFecdbF9FjR20RXLN9yXGs1hcMruZ4k= 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=W4jWY55l; arc=none smtp.client-ip=209.85.210.193 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="W4jWY55l" Received: by mail-pf1-f193.google.com with SMTP id d2e1a72fcca58-82fbdd60b64so2144130b3a.3 for ; Sat, 09 May 2026 05:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1778330169; x=1778934969; 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=W4jWY55lDzXw8KgPGJ4k2h3s3Dr2S4yFgrbV62cEWJK6w7nlm1m97x1wse9MzT694Q VrIXElQM5WDeypMCPUaG7h/o+pdWAdS5ZZwxbvgPOQoRUYShATNkbD6jwci+DmKs+HqH 1hRQSXCakLAzWZ/bn4J6u1nfTwasSknu0Vl6RXfS0877lnhysKLQpWnBeNW8LPPryI+m puSL7VrDPUGX9OvtyRm1u90FFSwxr4FMR2KjpR8EYX6cWB6XclZ9Ycb8G7P1AdjTHEzM kxOjMWCa0t83MLxu5AFUpg/Jz3KPZ2IMd8SWw4g29qEfIdyH6t2OqJauu8YR9okc3Y+n JpIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778330169; x=1778934969; 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=Qt1UZmCpp/Z1y+0fZxhvzxfJ1Bykc4jvnPUe6RwoPQRS4IuS7tYTZaRqE6DIeZwPzJ lPoex+ygJc2a0sdB0cgPpKb14vcEyBJTZV0D6+cUOWeSLwdNVnDPGYIP+0FtJtPnVy70 fEicSpz5BQoVk8nWKwVZNhB/dYoCLWudb2P/LXxee58IWeu+GIeVxGBCAmUNRxT6lrqa EbjUkKTwBItQ8MzFzhGU1kM2lekTSflIHRLyNBkZh6Q5gAT3405O0wgmFE5UBHGXeibu rDmr0liKPbjrRcGCDs7lS0G74ZLlenE1iQFAlYnCxRs45U67b6ghe1jLl3PHs7KxRxtT xr1w== X-Forwarded-Encrypted: i=1; AFNElJ9iT393Ju1GIomONphEFqOF+Qqm1NztQR88/afcZWXh0Qb+HlbwpSj7u/8ovsJsfFxNNnOm7y/tGwtccJg=@vger.kernel.org X-Gm-Message-State: AOJu0YwnUiGRjJMbKTwWVKw/yRL0niBDixzavMKVKXEIE33YQnM+pSb3 /UNnMpS30QvdQvwslezyt4Pjqlb6Q/3Oks2fnCxhaJ2yM2fQJPU0Ond/ X-Gm-Gg: Acq92OFcIr/s+m0GRuyi/E6rSGYm2PNA35HYX6/2DENM41vXP103ytIHcsfLkqKUhgh mW2TGf1LaIKmD5eBbAXY657Z2ZZ08ydeimjnVBDR557p4q9tqHSSIcehtSAgWpPqMpq+JRcm3P+ ApaT1YXkNmkNyiwMXE6Gs9itsMamdDm2fsY915TWUVmr+2hncW1fhBa+2KDru+vazbhqwfer7FE ptGBq77thS2jF/AlqAcqHGO9n2zMrDCmquCYcUJ4CRd+raDsqxDgRl5rZFLcn6VFNQf+Hp3G+b+ qUUzCyzFv947bd7jOOJX0AczoHIaUTE6lLkhbP/ugvEj5kwP1wy2ut7chazowHlo8Ub3Nj/ra0t VrKcMHT9Y++tgZa11351xWq7VSdPish3R9Dp6HhKdau9r+/svCDE3ixanvL8M03MEOTIz0cidIv RJptqxgN1g86gqcXNg57IwhGHJDLpubs7F8/uXouUv26YrSA== X-Received: by 2002:a05:6a00:2d24:b0:81f:31c3:2e34 with SMTP id d2e1a72fcca58-83e3afd78f8mr2218327b3a.25.1778330168517; Sat, 09 May 2026 05:36:08 -0700 (PDT) Received: from LAPTOP-1HUHJV8R.localdomain ([2408:8642:893:d2da:5918:a945:3871:250c]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-83965a3e3ecsm15487033b3a.19.2026.05.09.05.36.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 09 May 2026 05:36:08 -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: Sat, 9 May 2026 20:35:54 +0800 Message-ID: <20260509123554.40654-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