From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796231367; b=K4+6fD3Ye1S14rNC6cRIvTWBhO0rIhK21jl6qp5UtwJ0V8EQuZBnZacnSRHdwmiiCk0z XlKSsOZBtFQER+rhnUYS4mdXQrqOrp2SdIEed9syTveiVuxQEI5OuIhGIq5fE0Y6EFKMF XYoDfsqrEr4kGPcgwfDY5p73Y9SshLqVMZp7z3E/0Ekm4ovVttA3Ll2UGA9ffZ4pLChSb ljJjAhnlCWWTeUB+oLLNQid8800PHPHTzFNjIyTUpjwH2F28Q+UVLbXJy3L5JT4N6bH3J pEtrJZA9IXHwooe7vEorv/6euoDeUE4/Nez5xre2mJ94Wx3lrHm+S4gD0XSQrlYDv2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796231367; h=Received:DKIM-Signature:Subject:To:Cc:From:Date:Message-ID: MIME-Version:Content-Type:Content-Transfer-Encoding; bh=/DHO3uYiFyF5Hk3aHfZ+746oU8Bn09It1dwqzURzW9U=; b=wr5TYpJt7xuhIkyLlf6nRwH3vwsHTiu3hGfZGiMQPBM3Fe3UcGEib15gkm06SET96lP/ uKWQSHyGzUiDiiZh3DIqRZsxYM4QGQ1Th8TBE7awnQqLw8dQM6doDye9E/oOIae/I4QZW FFgNSgTRPcpp4LHVLbO43r5W+Woo/2sfrt+mJjPt3pl+gmRvfxcpzGGpWeGbCb/BA7p2Y TiLta6L8J+XAhsql5a6DvUaXiuc3GvBLXg9wVFoTn5mpNqRHr1IYCG2Fo3ZcwYS/TkzT0 VoPgnMPNzKEZEjrOWsGofp1S4/145HobYULrUNYOcdhbHdk1Aq82Dghzh2JyRC4df3g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IXPPp76C; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BF3F606A322 for ; Wed, 2 Dec 2026 17:09:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=IXPPp76C Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E1471F000C1; Wed, 2 Dec 2026 17:09:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796231366; bh=/DHO3uYiFyF5Hk3aHfZ+746oU8Bn09It1dwqzURzW9U=; h=Subject:To:Cc:From:Date; b=IXPPp76Cz+R81l7PyHsX3p8sJB5aIzh9kvVZt2fEe8dmeATi9NwFw9/LpEkvh6FbG 2zodmBWe9bsc9Vs5OcabMXrSYbVLtwwQxAp5jD7GLHWW0XgPR6mjJ0hX90ThNjYaZx i7sePkMsdxnJR8mLtYjbtxlyF0doRTIN1OVRHSe8= Subject: FAILED: patch "[PATCH] ocfs2: fix kernel BUG in ocfs2_page_mkwrite() when write_end" failed to apply to 6.1-stable tree To: zhiyuanzhang912@gmail.com,akpm@linux-foundation.org,heming.zhao@suse.com,jlbec@evilplan.org,joseph.qi@linux.alibaba.com,mark@fasheh.com,stable@vger.kernel.org,syzbot+42984127d45ad96219de@syzkaller.appspotmail.com,vicky.yangwenfang@huawei.com Cc: From: Date: Wed, 02 Dec 2026 17:29:48 +0100 Message-ID: <2026120248-imaging-satisfied-0f11@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.1-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y git checkout FETCH_HEAD git cherry-pick -x 5158f371faceb185235ba42882e67a840cfd7f48 # git commit -s git send-email --to '' --in-reply-to '2026120248-imaging-satisfied-0f11@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..' Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 5158f371faceb185235ba42882e67a840cfd7f48 Mon Sep 17 00:00:00 2001 From: Zhiyuan Zhang Date: Wed, 11 Nov 2026 02:34:44 +0000 Subject: [PATCH] ocfs2: fix kernel BUG in ocfs2_page_mkwrite() when write_end fails syzbot reported a kernel BUG in the ocfs2 write fault path: (syz.0.17,5578,0):ocfs2_write_end_nolock:1945 ERROR: status = -30 kernel BUG at fs/ocfs2/mmap.c:106! Call Trace: do_page_mkwrite+0x147/0x310 mm/memory.c:3879 do_shared_fault mm/memory.c:6145 [inline] handle_mm_fault+0x1a53/0x3750 mm/memory.c:6943 __ocfs2_page_mkwrite() calls ocfs2_write_begin_nolock() and then ocfs2_write_end_nolock(), and uses BUG_ON() to assert that the latter returns the full length. But ocfs2_write_end_nolock() can fail: since commit 7f27ec978b0e ("ocfs2: call ocfs2_journal_access_di() before ocfs2_journal_dirty() in ocfs2_write_end_nolock()") it gets journal access to the inode buffer again, because the handle may have been restarted since ocfs2_write_begin_nolock(). That fails with -EROFS or -EIO once the journal has been aborted or jbd2 has seen write errors on the device. The syzbot reproducer gets there by shrinking the backing loop device to zero with LOOP_SET_STATUS while writing to a shared file mapping. Handle the failure instead of crashing. ocfs2_write_end_nolock() leaves the mmap folio locked, because ocfs2_unlock_folios() skips it when w_target_locked is set so that it can be returned with VM_FAULT_LOCKED, and do_page_mkwrite() does not unlock it either when ->page_mkwrite() returns an error. So unlock it and fail the fault; the faulting task gets SIGBUS, like for the other errors in this function. For an mmap write ocfs2_write_end_nolock() returns either len or a negative errno: inline data has already been converted to extents by ocfs2_write_begin_nolock(), and copied is equal to len. The BUG matters for local mounts, where the filesystem is expected to go read-only and keep running after a journal abort. On clustered mounts ocfs2_abort() panics the node anyway as soon as it notices the aborted journal. Link: https://lore.kernel.org/20261111023444.22688-1-zhiyuanzhang912@gmail.com Fixes: 7f27ec978b0e ("ocfs2: call ocfs2_journal_access_di() before ocfs2_journal_dirty() in ocfs2_write_end_nolock()") Signed-off-by: Zhiyuan Zhang Signed-off-by: Andrew Morton Reported-by: Closes: https://syzkaller.appspot.com/bug?extid=42984127d45ad96219de Reviewed-by: Joseph Qi Reviewed-by: Heming Zhao Cc: Mark Fasheh Cc: Joel Becker Cc: yangwenfang Cc: fs/ocfs2/mmap.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/ocfs2/mmap.c b/fs/ocfs2/mmap.c index 6c570157caf1..1c03f45e8965 100644 --- a/fs/ocfs2/mmap.c +++ b/fs/ocfs2/mmap.c @@ -103,7 +103,17 @@ static vm_fault_t __ocfs2_page_mkwrite(struct file *file, goto out; } err = ocfs2_write_end_nolock(mapping, pos, len, len, fsdata); - BUG_ON(err != len); + if (err != len) { + /* + * ocfs2_write_end_nolock() keeps the mmap folio locked so + * that it can be returned to the VM with VM_FAULT_LOCKED. + * On failure nobody else will unlock it, so do it here. + */ + folio_unlock(locked_folio); + mlog_errno(err); + ret = vmf_error(err); + goto out; + } ret = VM_FAULT_LOCKED; out: return ret;