erofs: Fix the slab-out-of-bounds in drop_buffers()
Subsystems (2)
PATCH v2 1/1 erofs: Fix the slab-out-of-bounds in drop_buffers()
commit ce529cc25b184e93397b94a8a322128fc0095cbb upstream.
This was accidentally fixed in commit ce529cc25b18, but it's not possible to accept all the changes, due to the lack of large folios support for Linux 6.1 kernels, so this is only the actual bug fix that's needed.
[Background]
Syzbot reported that a KASAN slab-out-of-bounds bug was discovered in the drop_buffers() function [1].
The root cause is that erofs_raw_access_aops does not define .release_folio and .invalidate_folio. When using iomap-based operations, folio->private may contain iomap-specific data rather than buffer_heads. Without special handlers, the kernel may fall back to generic functions (such as drop_buffers), which incorrectly treat folio->private as a list of buffer_head structures, leading to incorrect memory interpretation and out-of-bounds access.
Fix this by explicitly setting .release_folio and .invalidate_folio to the values of iomap_release_folio and iomap_invalidate_folio, respectively.
[1] https://syzkaller.appspot.com/x/report.txt?x=12e5a142580000
--- fs/erofs/data.c | 2 ++ 1 file changed, 2 insertions(+)
fs/erofs/data.c +2 -0
@@ -406,6 +406,8 @@ const struct address_space_operations erofs_raw_access_aops = { .readahead = erofs_readahead, .bmap = erofs_bmap, .direct_IO = noop_direct_IO, + .release_folio = iomap_release_folio, + .invalidate_folio = iomap_invalidate_folio, };#ifdef CONFIG_FS_DAX
Signature · 1 line
2.43.0
Quoted 22 lines · Denis Arefev
commit
ce529cc25b184e93397b94a8a322128fc0095cbbupstream.This was accidentally fixed in commit
ce529cc25b18, but it's not possible to accept all the changes, due to the lack of large folios support for Linux 6.1 kernels, so this is only the actual bug fix that's needed.[Background]
Syzbot reported that a KASAN slab-out-of-bounds bug was discovered in the
drop_buffers()function [1].The root cause is that
erofs_raw_access_aopsdoes not define .release_folio and .invalidate_folio. When using iomap-based operations,folio->privatemay contain iomap-specific data rather thanbuffer_heads. Without special handlers, the kernel may fall back to generic functions (such asdrop_buffers), which incorrectly treatfolio->privateas a list ofbuffer_headstructures, leading to incorrect memory interpretation and out-of-bounds access.Fix this by explicitly setting .release_folio and .invalidate_folio to the values of
iomap_release_folioandiomap_invalidate_folio, respectively.
Quoted 6 lines
[1] https://syzkaller.appspot.com/x/report.txt?x=12e5a142580000
Fixes 7479c505b4ab ("fs: Convert iomap_readpage to iomap_read_folio")Reported-by [email protected]Signed-off-by Denis Arefev <[email protected]>
Thanks,
Gao Xiang
Patch "erofs: Fix the slab-out-of-bounds in drop_buffers()" has been added to the 6.1-stable tree
In reply to Denis ArefevThis is a note to let you know that I've just added the patch titled
erofs: Fix the slab-out-of-bounds in drop_buffers()
to the 6.1-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
erofs-fix-the-slab-out-of-bounds-in-drop_buffers.patch
and it can be found in the queue-6.1 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
From [email protected] Mon Mar 23 14:59:38 2026
From: Denis Arefev <[email protected]>
Date: Mon, 23 Mar 2026 16:59:35 +0300
Subject: erofs: Fix the slab-out-of-bounds in drop_buffers()
To: [email protected], Greg Kroah-Hartman <[email protected]>
Cc: Gao Xiang <[email protected]>, Chao Yu <[email protected]>, Jeffle Xu <[email protected]>, [email protected], [email protected], [email protected], [email protected]
Message-ID: <[email protected]>
From: Denis Arefev <[email protected]>
commit ce529cc25b184e93397b94a8a322128fc0095cbb upstream.
This was accidentally fixed in commit ce529cc25b18, but it's not possible to accept all the changes, due to the lack of large folios support for Linux 6.1 kernels, so this is only the actual bug fix that's needed.
[Background]
Syzbot reported that a KASAN slab-out-of-bounds bug was discovered in the drop_buffers() function [1].
The root cause is that erofs_raw_access_aops does not define .release_folio and .invalidate_folio. When using iomap-based operations, folio->private may contain iomap-specific data rather than buffer_heads. Without special handlers, the kernel may fall back to generic functions (such as drop_buffers), which incorrectly treat folio->private as a list of buffer_head structures, leading to incorrect memory interpretation and out-of-bounds access.
Fix this by explicitly setting .release_folio and .invalidate_folio to the values of iomap_release_folio and iomap_invalidate_folio, respectively.
[1] https://syzkaller.appspot.com/x/report.txt?x=12e5a142580000
--- fs/erofs/data.c | 2 ++ 1 file changed, 2 insertions(+)
fs/erofs/data.c +2 -0
@@ -406,6 +406,8 @@ const struct address_space_operations er .readahead = erofs_readahead, .bmap = erofs_bmap, .direct_IO = noop_direct_IO, + .release_folio = iomap_release_folio, + .invalidate_folio = iomap_invalidate_folio, };#ifdef CONFIG_FS_DAX
Patches currently in stable-queue which might be from [email protected] are
queue-6.1/erofs-fix-the-slab-out-of-bounds-in-drop_buffers.patch