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 6D3C41FAEF9; Wed, 6 Nov 2024 12:38:25 +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=1730896705; cv=none; b=P2hvPa5A4DJWFaz9UlEatdbBMzorSmM+ijMh0WujI3ItelWeLb6jJcrRigWaaERsDhF5XBStG3xwSV0w59YvAn0TxwWHpxuLZqqpuULbMi76wNr22hnwzB2TTCIxEIP++CWwAR0kwRn+Iaor90pUWtkKt1syCRJ3y4U7wdjQfOE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730896705; c=relaxed/simple; bh=3zz6SYNG3td+q5uuu+rSZn8A2X/Ybza0p7RyOkveuCE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P4vS09vC3Z/Z4m83jRM+afB9LziWtZ1hlHC3SYn37fHoKOoWTaL0cdMj9W2f2NoBWLFDRYrV6oaRvnM3ZlChi9ke5cdswQI7RaGFNEueNUoUREC3+KX3mE+DZIem+o7ohF90O8JX2atQxbY4x4NjRJ9gAopKSACHS/rXyVBoQBc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=uz+35DCu; 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="uz+35DCu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1F74C4CED8; Wed, 6 Nov 2024 12:38:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1730896705; bh=3zz6SYNG3td+q5uuu+rSZn8A2X/Ybza0p7RyOkveuCE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uz+35DCuen7uPAN09i+ABm0sXsL9tL/692v6hyGdLiAQAHg10eXuJyAt5F8CfaGr1 i1EgDkND4YdQdDxSNGAnCKFhhqPFF7qIepjY0w1j6o5NmdNIEnln4NhI9zVbC+9OeM 5wPJOz1gOLiqcgz5AgX2drWajNK5ectSH4TPExJ8= 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 5.10 046/110] nilfs2: fix kernel bug due to missing clearing of buffer delay flag Date: Wed, 6 Nov 2024 13:04:12 +0100 Message-ID: <20241106120304.475196630@linuxfoundation.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241106120303.135636370@linuxfoundation.org> References: <20241106120303.135636370@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-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 @@ -77,7 +77,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); @@ -409,7 +410,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 {