From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (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 402D733D6EE for ; Wed, 6 May 2026 11:50:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778068220; cv=none; b=Iv7O8Ad995QldgmY17XdwTmt7OyHbpEtpe5qu+LLbLVm4oi1EpjWPmiD4QzelrqMOqGzMTlbOrR/8xCd7sqoiOzvfz39PRJsj1QSZ0cP7ApWcrOafpdvA835uRP7r2ka5CowyWGUcYTkUPTsnDZDKrCEUcDMbkxLb1bzg7j8UP0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778068220; c=relaxed/simple; bh=eFRtHnjqwVbXoSYkNIrnYISzOgRex6tD2edjPmn6n3g=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=axE8eV6PSN7gqxWquCQ5C27IPe0MqFZlvSOO3z1ScB8N2Pm3AO6FCUL5qlSET3x9WxMhOVPlqxszrhbFlWWIp42j+uZ33zVBPs2MT2fbjmW/wrY/VyqA2qZ74Qab8EEviopmrICWSeTHneo5GfCv07gApI0g+V2QIHGZzGeEFLs= 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.210.71 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-ot1-f71.google.com with SMTP id 46e09a7af769-7e1f3a293aeso14302a34.2 for ; Wed, 06 May 2026 04:50:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778068218; x=1778673018; 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=A31N1JqOSvz9JGPjSqnUv2p1YCXxkmqruAuZx26sjEg=; b=puyYkcHCuuORgfNPx1Ew5+7hEjXbBX650dLuI3pk9/ZjFLbrpjLao5Ru/QL4vYOUdx 8/fPecOpSJlmbnEFDX2pWpxStYwVxCp9Jz8pcO7K0gG6kxLCyREbaZtRihQSwgOgrsUJ 6ND1ICDWJGKM3O/OMTYBIIFUMOLur2e6YWUnahl/IC+EufP5nTVck3gALP9GtDO/EG7V ufGm5ZNJh+ButvruAhWgPYNKLDLrwvzhCSkONktPtg8idy0riGBgHP/NwmJv3m+y/9Xh dRlPSfufoeshUlM+kS40R5dWCPa6d4OLtCZ8mrNN2k7lY1GoWizqkI2juz/jdJ9PtYAv 4iIw== X-Gm-Message-State: AOJu0Yw8IucFodoC85NlpNTCv/5sjvi4+xKIQT0Hy5RBM8CuIrudFA1/ rtb2Zi9HpC7kkJpy7vvQrVQMdqVqmwnRk1adgPNjhzeLqZZ7MeBgexa+Yxlc6q+7I1JNhwpqlUL sw2GpuJ1b+byKqBVAJJd4wPxlLtVVVDwkNa8C2MUfR3zZtSxJ8hP8DBZWgmU= 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:3101:b0:68e:3f3b:8690 with SMTP id 006d021491bc7-69998ccb6ebmr1181051eaf.21.1778068218304; Wed, 06 May 2026 04:50:18 -0700 (PDT) Date: Wed, 06 May 2026 04:50:18 -0700 In-Reply-To: <00000000000034ae0f05e9f94c79@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69fb2afa.050a0220.e8b39.000f.GAE@google.com> Subject: Forwarded: Re: [PATCH v2 2/2] jfs: wait for in-flight log I/O before freeing lbufs in lbmLogShutdown 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: [PATCH v2 2/2] jfs: wait for in-flight log I/O before freeing lbufs in lbmLogShutdown Author: tristmd@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master >>From f8c2cc086d8f3f38d3a30402d093d7be05fb7397 Mon Sep 17 00:00:00 2001 From: Tristan Madani Date: Wed, 6 May 2026 08:27:02 +0000 Subject: [PATCH] jfs: fix lbmLogShutdown race with redriven log buffers lbmRedrive() adds a log buffer to the global log_redrive_list and wakes jfsIOthread, but does not increment the log io_count. This creates a window where io_count reaches zero while redriven buffers are still pending on the list. If lbmLogShutdown() observes io_count == 0 in this window, it proceeds to free all lbufs while jfsIOWait() later dequeues and dereferences them, causing a use-after-free: lbmIODone(bp) lbmRedrive(nextbp) <-- nextbp added to list, io_count not bumped atomic_dec(io_count) <-- io_count drops to 0 lbmLogShutdown() wait_event(io_count==0) <-- satisfied, frees all lbufs jfsIOWait() bp = log_redrive_list <-- UAF: bp already freed Fix this by incrementing io_count in lbmRedrive() before adding the buffer to the redrive list, and cancelling the reference in jfsIOWait() after lbmStartIO() has taken its own. This keeps io_count elevated for the entire time a buffer sits on the redrive list. Fixes: 69cbc1419b1a ("jfs: wait for in-flight log I/O before freeing lbufs in lbmLogShutdown") Signed-off-by: Tristan Madani --- fs/jfs/jfs_logmgr.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/jfs/jfs_logmgr.c b/fs/jfs/jfs_logmgr.c index 95e95f71ec0fa..fa3de31d9c682 100644 --- a/fs/jfs/jfs_logmgr.c +++ b/fs/jfs/jfs_logmgr.c @@ -1949,6 +1949,9 @@ static inline void lbmRedrive(struct lbuf *bp) { unsigned long flags; + /* keep io_count elevated while bp is on the redrive list */ + atomic_inc(&bp->l_log->io_count); + spin_lock_irqsave(&log_redrive_lock, flags); bp->l_redrive_next = log_redrive_list; log_redrive_list = bp; @@ -2324,7 +2327,14 @@ int jfsIOWait(void *arg) log_redrive_list = bp->l_redrive_next; bp->l_redrive_next = NULL; spin_unlock_irq(&log_redrive_lock); - lbmStartIO(bp); + { + struct jfs_log *log = bp->l_log; + + lbmStartIO(bp); + /* cancel redrive ref; lbmStartIO took its own */ + if (atomic_dec_and_test(&log->io_count)) + wake_up(&log->io_done_wait); + } spin_lock_irq(&log_redrive_lock); } -- 2.47.3