FAILED: Patch "nilfs2: fix kernel bug due to missing clearing of checked flag" failed to apply to v6.6-stable tree

Sasha Levin posted 1 patch 2 weeks, 4 days ago
fs/nilfs2/page.c | 1 +
1 file changed, 1 insertion(+)
FAILED: Patch "nilfs2: fix kernel bug due to missing clearing of checked flag" failed to apply to v6.6-stable tree
Posted by Sasha Levin 2 weeks, 4 days ago
The patch below does not apply to the v6.6-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 <stable@vger.kernel.org>.

Thanks,
Sasha

------------------ original commit in Linus's tree ------------------

From 41e192ad2779cae0102879612dfe46726e4396aa Mon Sep 17 00:00:00 2001
From: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Date: Fri, 18 Oct 2024 04:33:10 +0900
Subject: [PATCH] nilfs2: fix kernel bug due to missing clearing of checked
 flag

Syzbot reported that in directory operations after nilfs2 detects
filesystem corruption and degrades to read-only,
__block_write_begin_int(), which is called to prepare block writes, may
fail the BUG_ON check for accesses exceeding the folio/page size,
triggering a kernel bug.

This was found to be because the "checked" flag of a page/folio was not
cleared when it was discarded by nilfs2's own routine, which causes the
sanity check of directory entries to be skipped when the directory
page/folio is reloaded.  So, fix that.

This was necessary when the use of nilfs2's own page discard routine was
applied to more than just metadata files.

Link: https://lkml.kernel.org/r/20241017193359.5051-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")
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: syzbot+d6ca2daf692c7a82f959@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d6ca2daf692c7a82f959
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
 fs/nilfs2/page.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
index 5436eb0424bd1..10def4b559956 100644
--- a/fs/nilfs2/page.c
+++ b/fs/nilfs2/page.c
@@ -401,6 +401,7 @@ void nilfs_clear_folio_dirty(struct folio *folio)
 
 	folio_clear_uptodate(folio);
 	folio_clear_mappedtodisk(folio);
+	folio_clear_checked(folio);
 
 	head = folio_buffers(folio);
 	if (head) {
-- 
2.43.0
Re: FAILED: Patch "nilfs2: fix kernel bug due to missing clearing of checked flag" failed to apply to v6.6-stable tree
Posted by Ryusuke Konishi 2 weeks, 4 days ago
Hi Sasha

About 6 hours ago, I posted an adjusted patch to the list (and to
Greg) that allows for backporting of this patch to 6.6-stable and
earlier.

The patch is titled  "[PATCH 4.19 5.4 5.10 5.15 6.1 6.6] nilfs2: fix
kernel bug due to missing clearing of checked flag".

(or https://lkml.kernel.org/r/20241105235654.15044-1-konishi.ryusuke@gmail.com )

Normally, Greg would pick up the adjusted patch and apply it, and it
would be backported without any problems, but if the backport of the
adjusted patch I requested has been rejected, I would like to ask for
your confirmation.

If it is a misunderstanding, I will wait for Greg's work, but is the
process different from usual?

Thank you in advance.

Ryusuke Konishi

On Wed, Nov 6, 2024 at 11:09 AM Sasha Levin <sashal@kernel.org> wrote:
>
> The patch below does not apply to the v6.6-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 <stable@vger.kernel.org>.
>
> Thanks,
> Sasha
>
> ------------------ original commit in Linus's tree ------------------
>
> From 41e192ad2779cae0102879612dfe46726e4396aa Mon Sep 17 00:00:00 2001
> From: Ryusuke Konishi <konishi.ryusuke@gmail.com>
> Date: Fri, 18 Oct 2024 04:33:10 +0900
> Subject: [PATCH] nilfs2: fix kernel bug due to missing clearing of checked
>  flag
>
> Syzbot reported that in directory operations after nilfs2 detects
> filesystem corruption and degrades to read-only,
> __block_write_begin_int(), which is called to prepare block writes, may
> fail the BUG_ON check for accesses exceeding the folio/page size,
> triggering a kernel bug.
>
> This was found to be because the "checked" flag of a page/folio was not
> cleared when it was discarded by nilfs2's own routine, which causes the
> sanity check of directory entries to be skipped when the directory
> page/folio is reloaded.  So, fix that.
>
> This was necessary when the use of nilfs2's own page discard routine was
> applied to more than just metadata files.
>
> Link: https://lkml.kernel.org/r/20241017193359.5051-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")
> Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
> Reported-by: syzbot+d6ca2daf692c7a82f959@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=d6ca2daf692c7a82f959
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
>  fs/nilfs2/page.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fs/nilfs2/page.c b/fs/nilfs2/page.c
> index 5436eb0424bd1..10def4b559956 100644
> --- a/fs/nilfs2/page.c
> +++ b/fs/nilfs2/page.c
> @@ -401,6 +401,7 @@ void nilfs_clear_folio_dirty(struct folio *folio)
>
>         folio_clear_uptodate(folio);
>         folio_clear_mappedtodisk(folio);
> +       folio_clear_checked(folio);
>
>         head = folio_buffers(folio);
>         if (head) {
> --
> 2.43.0
>
>
>
>
Re: FAILED: Patch "nilfs2: fix kernel bug due to missing clearing of checked flag" failed to apply to v6.6-stable tree
Posted by Greg Kroah-Hartman 2 weeks, 4 days ago
On Wed, Nov 06, 2024 at 03:21:39PM +0900, Ryusuke Konishi wrote:
> Hi Sasha
> 
> About 6 hours ago, I posted an adjusted patch to the list (and to
> Greg) that allows for backporting of this patch to 6.6-stable and
> earlier.
> 
> The patch is titled  "[PATCH 4.19 5.4 5.10 5.15 6.1 6.6] nilfs2: fix
> kernel bug due to missing clearing of checked flag".
> 
> (or https://lkml.kernel.org/r/20241105235654.15044-1-konishi.ryusuke@gmail.com )
> 
> Normally, Greg would pick up the adjusted patch and apply it, and it
> would be backported without any problems, but if the backport of the
> adjusted patch I requested has been rejected, I would like to ask for
> your confirmation.
> 
> If it is a misunderstanding, I will wait for Greg's work, but is the
> process different from usual?

I got it now, thanks!

greg k-h