diff options
| author | Gao Xiang <hsiangkao@linux.alibaba.com> | 2024-06-30 02:57:43 +0800 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-07-25 09:49:18 +0200 |
| commit | e424638474f8560308e314539dd831620a881035 (patch) | |
| tree | b6963341b08760d9f5f184fd0b12c03e7e4bc8c7 /fs/erofs | |
| parent | 605572e64cd9cebb05ed609d96cff05b50d18cdf (diff) | |
| download | linux-e424638474f8560308e314539dd831620a881035.tar.gz linux-e424638474f8560308e314539dd831620a881035.tar.bz2 linux-e424638474f8560308e314539dd831620a881035.zip | |
erofs: ensure m_llen is reset to 0 if metadata is invalid
[ Upstream commit 9b32b063be1001e322c5f6e01f2a649636947851 ]
Sometimes, the on-disk metadata might be invalid due to user
interrupts, storage failures, or other unknown causes.
In that case, z_erofs_map_blocks_iter() may still return a valid
m_llen while other fields remain invalid (e.g., m_plen can be 0).
Due to the return value of z_erofs_scan_folio() in some path will
be ignored on purpose, the following z_erofs_scan_folio() could
then use the invalid value by accident.
Let's reset m_llen to 0 to prevent this.
Link: https://lore.kernel.org/r/20240629185743.2819229-1-hsiangkao@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/erofs')
| -rw-r--r-- | fs/erofs/zmap.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c index abcded1acd19..4864863cd129 100644 --- a/fs/erofs/zmap.c +++ b/fs/erofs/zmap.c @@ -763,6 +763,8 @@ int z_erofs_map_blocks_iter(struct inode *inode, struct erofs_map_blocks *map, err = z_erofs_do_map_blocks(inode, map, flags); out: + if (err) + map->m_llen = 0; trace_z_erofs_map_blocks_iter_exit(inode, map, flags, err); /* aggressively BUG_ON iff CONFIG_EROFS_FS_DEBUG is on */ |
