* [PATCH] erofs: ensure m_llen is reset to 0 if metadata is invalid
@ 2024-06-29 18:57 Gao Xiang
2024-06-30 2:51 ` Gao Xiang
0 siblings, 1 reply; 2+ messages in thread
From: Gao Xiang @ 2024-06-29 18:57 UTC (permalink / raw)
To: linux-erofs, Chao Yu; +Cc: LKML, Gao Xiang
Sometimes, the on-disk metadata might be invalid due to storage
failure or other unknown issues.
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.
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/zmap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
index 9b248ee5fef2..74d3d7bffcf3 100644
--- a/fs/erofs/zmap.c
+++ b/fs/erofs/zmap.c
@@ -711,6 +711,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);
return err;
}
--
2.43.5
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] erofs: ensure m_llen is reset to 0 if metadata is invalid
2024-06-29 18:57 [PATCH] erofs: ensure m_llen is reset to 0 if metadata is invalid Gao Xiang
@ 2024-06-30 2:51 ` Gao Xiang
0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2024-06-30 2:51 UTC (permalink / raw)
To: linux-erofs, Chao Yu; +Cc: LKML
On 2024/6/30 02:57, Gao Xiang wrote:
> Sometimes, the on-disk metadata might be invalid due to storage
> failure or other unknown issues.
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.
>
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> ---
> fs/erofs/zmap.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
> index 9b248ee5fef2..74d3d7bffcf3 100644
> --- a/fs/erofs/zmap.c
> +++ b/fs/erofs/zmap.c
> @@ -711,6 +711,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);
> return err;
> }
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-06-30 2:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-29 18:57 [PATCH] erofs: ensure m_llen is reset to 0 if metadata is invalid Gao Xiang
2024-06-30 2:51 ` Gao Xiang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®