fs/f2fs/extent_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
KMSAN reported a use of uninitialized value in `__is_extent_mergeable()`
and `__is_back_mergeable()` via the read extent tree path.
The root cause is that `get_read_extent_info()` only initializes three
fields (`fofs`, `blk`, `len`) of `struct extent_info`, leaving the
remaining fields uninitialized. This leads to undefined behavior
when those fields are accessed later, especially during
extent merging.
Fix it by zero-initializing the `extent_info` struct before population.
Reported-by: syzbot+b8c1d60e95df65e827d4@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b8c1d60e95df65e827d4
Fixes: a28ef1f5aebe ("f2fs: maintain extent cache in separated file")
Signed-off-by: Abinash Singh <abinashsinghlalotra@gmail.com>
---
v3 : Added Fixes and Closes tags
---
fs/f2fs/extent_cache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index cfe925a3d555..4ce19a310f38 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -414,7 +414,7 @@ void f2fs_init_read_extent_tree(struct inode *inode, struct folio *ifolio)
struct f2fs_extent *i_ext = &F2FS_INODE(&ifolio->page)->i_ext;
struct extent_tree *et;
struct extent_node *en;
- struct extent_info ei;
+ struct extent_info ei = {0};
if (!__may_extent_tree(inode, EX_READ)) {
/* drop largest read extent */
--
2.43.0
On 6/25/25 01:09, Abinash Singh wrote: > KMSAN reported a use of uninitialized value in `__is_extent_mergeable()` > and `__is_back_mergeable()` via the read extent tree path. > > The root cause is that `get_read_extent_info()` only initializes three > fields (`fofs`, `blk`, `len`) of `struct extent_info`, leaving the > remaining fields uninitialized. This leads to undefined behavior > when those fields are accessed later, especially during > extent merging. > > Fix it by zero-initializing the `extent_info` struct before population. > > Reported-by: syzbot+b8c1d60e95df65e827d4@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=b8c1d60e95df65e827d4 > Fixes: a28ef1f5aebe ("f2fs: maintain extent cache in separated file") Should use this instead? Fixes: 94afd6d6e525 ("f2fs: extent cache: support unaligned extent") Reviewed-by: Chao Yu <chao@kernel.org> Thanks, > Signed-off-by: Abinash Singh <abinashsinghlalotra@gmail.com> > --- > v3 : Added Fixes and Closes tags > --- > fs/f2fs/extent_cache.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c > index cfe925a3d555..4ce19a310f38 100644 > --- a/fs/f2fs/extent_cache.c > +++ b/fs/f2fs/extent_cache.c > @@ -414,7 +414,7 @@ void f2fs_init_read_extent_tree(struct inode *inode, struct folio *ifolio) > struct f2fs_extent *i_ext = &F2FS_INODE(&ifolio->page)->i_ext; > struct extent_tree *et; > struct extent_node *en; > - struct extent_info ei; > + struct extent_info ei = {0}; > > if (!__may_extent_tree(inode, EX_READ)) { > /* drop largest read extent */
KMSAN reported a use of uninitialized value in `__is_extent_mergeable()`
and `__is_back_mergeable()` via the read extent tree path.
The root cause is that `get_read_extent_info()` only initializes three
fields (`fofs`, `blk`, `len`) of `struct extent_info`, leaving the
remaining fields uninitialized. This leads to undefined behavior
when those fields are accessed later, especially during
extent merging.
Fix it by zero-initializing the `extent_info` struct before population.
Reported-by: syzbot+b8c1d60e95df65e827d4@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=b8c1d60e95df65e827d4
Fixes: 94afd6d6e525 ("f2fs: extent cache: support unaligned extent")
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Abinash Singh <abinashsinghlalotra@gmail.com>
---
v4 : Added Reviewed-by and Corrected Fixes
---
fs/f2fs/extent_cache.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/extent_cache.c b/fs/f2fs/extent_cache.c
index cfe925a3d555..4ce19a310f38 100644
--- a/fs/f2fs/extent_cache.c
+++ b/fs/f2fs/extent_cache.c
@@ -414,7 +414,7 @@ void f2fs_init_read_extent_tree(struct inode *inode, struct folio *ifolio)
struct f2fs_extent *i_ext = &F2FS_INODE(&ifolio->page)->i_ext;
struct extent_tree *et;
struct extent_node *en;
- struct extent_info ei;
+ struct extent_info ei = {0};
if (!__may_extent_tree(inode, EX_READ)) {
/* drop largest read extent */
--
2.43.0
© 2016 - 2025 Red Hat, Inc.