From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03BE71DF726; Wed, 6 Nov 2024 12:22:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730895739; cv=none; b=TsDS19YRWc8VyD7SpNFRdm0aqkXqT5ASTuRO3Cxe45BOcH4zUHtq9XxN59HzbqwAC3FviTuRhqiZdRbD/4tUnoqnm6YQ8EbiAXkIASzhQ1gySPLyPO1M7/V1G+uAj9aAZP1cx/TJ/0lCGJICSf58myXn3LFKrtsG1R03gq38KMI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730895739; c=relaxed/simple; bh=8Tx9NcET2LIiMN8Qn9Wra/0f/VlGK67VmlVrFhf+VtY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S0BBNA8P2d6kyT7rQEX1YW2EBazS6zsxOtNcKy732v7LrfGbsVuxz7IJeJriu+W+kMLYqxrJ27dhRGR8bjRkAg0E1Wppa3M9LqOU8Jneo5qr1GRbw+ZSV1iL3nJRG5G2caHdH+q2eCLu/9uInLR9Vp3lGteq+7BupMLzPID1Lno= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BRmiEw+W; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="BRmiEw+W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81FF2C4CECD; Wed, 6 Nov 2024 12:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730895738; bh=8Tx9NcET2LIiMN8Qn9Wra/0f/VlGK67VmlVrFhf+VtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BRmiEw+WwnrdyK4JM/hW4d49/plpwfQKPMuHKH7fz3Pui1wu5QVt0tw9FmAG01LGf Opsnf2YZJCj9uYngW5pJJC/K7p0+5MvfPAcIpbMfxHRoKM5DDcvuaVmtzXiMig2NhT 6J+MogeWRdn0/fbHPkTjhbhN/aWNfaLlvbj39CiY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ryusuke Konishi , syzbot+985ada84bf055a575c07@syzkaller.appspotmail.com, Christian Brauner Subject: [PATCH 4.19 318/350] nilfs2: fix kernel bug due to missing clearing of buffer delay flag Date: Wed, 6 Nov 2024 13:04:06 +0100 Message-ID: <20241106120328.610101242@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120320.865793091@linuxfoundation.org> References: <20241106120320.865793091@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ryusuke Konishi commit 6ed469df0bfbef3e4b44fca954a781919db9f7ab upstream. Syzbot reported that after nilfs2 reads a corrupted file system image and degrades to read-only, the BUG_ON check for the buffer delay flag in submit_bh_wbc() may fail, causing a kernel bug. This is because the buffer delay flag is not cleared when clearing the buffer state flags to discard a page/folio or a buffer head. So, fix this. This became necessary when the use of nilfs2's own page clear routine was expanded. This state inconsistency does not occur if the buffer is written normally by log writing. Signed-off-by: Ryusuke Konishi Link: https://lore.kernel.org/r/20241015213300.7114-1-konishi.ryusuke@gmail.com Fixes: 8c26c4e2694a ("nilfs2: fix issue with flush kernel thread after remount in RO mode because of driver's internal error or metadata corruption") Reported-by: syzbot+985ada84bf055a575c07@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=985ada84bf055a575c07 Cc: stable@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Greg Kroah-Hartman --- fs/nilfs2/page.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/fs/nilfs2/page.c +++ b/fs/nilfs2/page.c @@ -78,7 +78,8 @@ void nilfs_forget_buffer(struct buffer_h const unsigned long clear_bits = (BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) | BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) | - BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected)); + BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected) | + BIT(BH_Delay)); lock_buffer(bh); set_mask_bits(&bh->b_state, clear_bits, 0); @@ -412,7 +413,8 @@ void nilfs_clear_dirty_page(struct page const unsigned long clear_bits = (BIT(BH_Uptodate) | BIT(BH_Dirty) | BIT(BH_Mapped) | BIT(BH_Async_Write) | BIT(BH_NILFS_Volatile) | - BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected)); + BIT(BH_NILFS_Checked) | BIT(BH_NILFS_Redirected) | + BIT(BH_Delay)); bh = head = page_buffers(page); do {