From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f72.google.com (mail-oo1-f72.google.com [209.85.161.72]) (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 45F4C3A4F37 for ; Thu, 30 Apr 2026 23:13:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.72 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777590805; cv=none; b=ofneOMWjIo2dLWtG9DNHGg6/+g+sw5Nt4yCmN5xaJzzs7YwtZO2wfUa2LuWg2QoQ0p13Wnv1AOt3ilNJADzS0KED2r62xtz4GKGRiFwwq7spwPkDgGP5lLjCuF9hUzr3DwI/vMKrqoqkZWyLjgBCfbltq4NwfskcDI1CLnSogaI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777590805; c=relaxed/simple; bh=yHzfn6loPDsvcan8Gjl9WMsEBbnt2HPXCC6+MdoGzFs=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=cAXjCzWZ6AobZXO99u2th4GGRYgIvVxDKCinNnRk2gKqDya0rbwZKsZZL6hjooQP5RAIOSqgUD4RFjJfoxpiJi/C3TkhBbqPm9TXVgfzU+2s8oGY/DPB34plFQhFm4seRpvoPBwgd8F6wb4P2i2BZmvj0SLxmAVqW4ukMJCICIo= 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.161.72 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-oo1-f72.google.com with SMTP id 006d021491bc7-69649771a5aso3231883eaf.2 for ; Thu, 30 Apr 2026 16:13:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777590803; x=1778195603; 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=qqpzdnjsT2UNB5/9OsD+8wRm8jT/44X960ArClQuhkU=; b=MHpxc4fwio7TgrlHROKyPATJFmWFGZGSKqUB5l95Ed1rh3YZLf4oxUJTQnr/YlCEzD NeK0YoB7VZcO9tzPT243E3xwsmUidfHLmvvB9Hka9hJ25GZTMrh+iwYH2yfH0c0EE80y AhMioaPs1HmxGynYnNu13Sm00kpLBM5nFowCaDAByp7kT13rwxrHufAd08fGRIpS1WO1 IJjifdFe5EjYZb5OJQ1+k6NdM3vNBo9j/wzdocB816Uo25TuQ4dIz14eEEHwjIBLBsA+ q37zOpKJVi6L6M5gRXYgSCbT98QrPEnl3MhZaiTyKRDrqRH8IYhpMdOciKsK1z6SLcNJ WBFw== X-Gm-Message-State: AOJu0YyCrMtjWmODvuTqUbzZZ0XhlbmIQb5a9ah6fbyuzxoUFdIfEHXv w8gi0ycvpNO5uR0rzBc5ccmZ9WWEP0Sb+P0uEq5wFLjiqI9s11TUuhINWvzoZl4l7cclXfvHmp6 GD4vSIQ2qy5HrVaRkO6FO2qgvc9YVRvu7qNdbHWcZ9UNKA+4iLoxViB1QjCA= 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:4b0a:b0:696:7780:477a with SMTP id 006d021491bc7-6967a61ee73mr2733490eaf.46.1777590803209; Thu, 30 Apr 2026 16:13:23 -0700 (PDT) Date: Thu, 30 Apr 2026 16:13:23 -0700 In-Reply-To: <000000000000a7761e0610c754b2@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69f3e213.170a0220.5f1b.000c.GAE@google.com> Subject: Forwarded: Re: [syz] KASAN: slab-use-after-free Read in jfs_syncpt 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: Re: [syz] KASAN: slab-use-after-free Read in jfs_syncpt Author: tristmd@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master >>From a6c188149cf9056a8692aa45dfd0d429bd07d09f Mon Sep 17 00:00:00 2001 From: Tristan Madani Date: Thu, 30 Apr 2026 23:12:58 +0000 Subject: [PATCH] jfs: drain lazy commit queue during unmount to prevent use-after-free The jfsCommit kernel thread processes committed transactions from TxAnchor.unlock_queue via jfs_lazycommit(). During filesystem unmount, jfs_umount() calls jfs_flush_journal(log, 2) which waits for the log commit queue (log->cqueue) to drain. However, after log I/O completes, lazy transactions are moved to TxAnchor.unlock_queue for asynchronous processing by jfsCommit. If jfs_umount() proceeds to free the jfs_log (via lmLogClose) or jfs_sb_info (via kfree in jfs_put_super) while entries referencing this superblock remain on unlock_queue, the jfsCommit thread will access freed memory when it later processes these entries: - jfs_lazycommit reads sbi->commit_state (UAF of jfs_sb_info) - txLazyCommit accesses JFS_SBI(tblk->sb)->log and takes log->gclock (UAF of jfs_log) Add txLazyDrain() which waits for all entries in TxAnchor.unlock_queue belonging to the unmounting superblock to be processed, and also waits for any in-flight txLazyCommit (IN_LAZYCOMMIT) for this superblock to complete. Call it from both jfs_umount() and jfs_umount_rw() after jfs_flush_journal(). Reported-by: syzbot+c244f4a09ca85dd2ebc1@syzkaller.appspotmail.com Reported-by: syzbot+885a4f3281b8d99c48d8@syzkaller.appspotmail.com Fixes: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Signed-off-by: Tristan Madani --- fs/jfs/jfs_txnmgr.c | 34 ++++++++++++++++++++++++++++++++++ fs/jfs/jfs_txnmgr.h | 1 + fs/jfs/jfs_umount.c | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/fs/jfs/jfs_txnmgr.c b/fs/jfs/jfs_txnmgr.c index 083dbbb0c3268..e3b2cee416c19 100644 --- a/fs/jfs/jfs_txnmgr.c +++ b/fs/jfs/jfs_txnmgr.c @@ -2791,6 +2791,40 @@ void txLazyUnlock(struct tblock * tblk) LAZY_UNLOCK(flags); } + +/* + * txLazyDrain + * + * Wait for all pending lazy commit entries for this superblock + * to be processed by the jfsCommit thread. Must be called + * before freeing per-filesystem structures during unmount. + */ +void txLazyDrain(struct super_block *sb) +{ + struct jfs_sb_info *sbi = JFS_SBI(sb); + struct tblock *tblk; + unsigned long flags; + bool found; + + do { + found = false; + LAZY_LOCK(flags); + list_for_each_entry(tblk, &TxAnchor.unlock_queue, cqueue) { + if (tblk->sb == sb) { + found = true; + break; + } + } + if (!found && (sbi->commit_state & IN_LAZYCOMMIT)) + found = true; + LAZY_UNLOCK(flags); + + if (found) { + wake_up(&jfs_commit_thread_wait); + schedule_timeout_uninterruptible(1); + } + } while (found); +} static void LogSyncRelease(struct metapage * mp) { struct jfs_log *log = mp->log; diff --git a/fs/jfs/jfs_txnmgr.h b/fs/jfs/jfs_txnmgr.h index ba71eb5ced567..fbbaed26c52bd 100644 --- a/fs/jfs/jfs_txnmgr.h +++ b/fs/jfs/jfs_txnmgr.h @@ -291,6 +291,7 @@ extern void txFreelock(struct inode *); extern int lmLog(struct jfs_log *, struct tblock *, struct lrd *, struct tlock *); extern void txQuiesce(struct super_block *); +extern void txLazyDrain(struct super_block *); extern void txResume(struct super_block *); extern void txLazyUnlock(struct tblock *); extern int jfs_lazycommit(void *); diff --git a/fs/jfs/jfs_umount.c b/fs/jfs/jfs_umount.c index 18569f1eaabdb..657707361be2a 100644 --- a/fs/jfs/jfs_umount.c +++ b/fs/jfs/jfs_umount.c @@ -58,6 +58,13 @@ int jfs_umount(struct super_block *sb) */ jfs_flush_journal(log, 2); + /* + * Drain any pending lazy commit entries for this filesystem so + * the jfsCommit thread does not access freed structures. + */ + if (log) + txLazyDrain(sb); + /* * Hold log lock so write_special_inodes (lmLogSync) cannot see * this sbi with a NULL inode pointer while iterating log->sb_list. @@ -142,6 +149,7 @@ int jfs_umount_rw(struct super_block *sb) * remove file system from log active file system list. */ jfs_flush_journal(log, 2); + txLazyDrain(sb); /* * Make sure all metadata makes it to disk -- 2.47.3