Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 6.5.y] erofs: ensure that the post-EOF tails are all zeroed
@ 2023-08-31 11:29 Gao Xiang
  2023-08-31 11:29 ` [PATCH 6.4.y] " Gao Xiang
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Gao Xiang @ 2023-08-31 11:29 UTC (permalink / raw)
  To: stable, Greg Kroah-Hartman; +Cc: linux-erofs, Gao Xiang, keltargw

commit e4c1cf523d820730a86cae2c6d55924833b6f7ac upstream.

This was accidentally fixed up in commit e4c1cf523d82 but we can't
take the full change due to other dependancy issues, so here is just
the actual bugfix that is needed.

[Background]

keltargw reported an issue [1] that with mmaped I/Os, sometimes the
tail of the last page (after file ends) is not filled with zeroes.

The root cause is that such tail page could be wrongly selected for
inplace I/Os so the zeroed part will then be filled with compressed
data instead of zeroes.

A simple fix is to avoid doing inplace I/Os for such tail parts,
actually that was already fixed upstream in commit e4c1cf523d82
("erofs: tidy up z_erofs_do_read_page()") by accident.

[1] https://lore.kernel.org/r/3ad8b469-25db-a297-21f9-75db2d6ad224@linux.alibaba.com

Reported-by: keltargw <keltar.gw@gmail.com>
Fixes: 3883a79abd02 ("staging: erofs: introduce VLE decompression support")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
 fs/erofs/zdata.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/erofs/zdata.c b/fs/erofs/zdata.c
index de4f12152b62..9c9350eb1704 100644
--- a/fs/erofs/zdata.c
+++ b/fs/erofs/zdata.c
@@ -1038,6 +1038,8 @@ static int z_erofs_do_read_page(struct z_erofs_decompress_frontend *fe,
 	cur = end - min_t(erofs_off_t, offset + end - map->m_la, end);
 	if (!(map->m_flags & EROFS_MAP_MAPPED)) {
 		zero_user_segment(page, cur, end);
+		++spiltted;
+		tight = false;
 		goto next_part;
 	}
 	if (map->m_flags & EROFS_MAP_FRAGMENT) {
-- 
2.24.4


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-09-02  8:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-31 11:29 [PATCH 6.5.y] erofs: ensure that the post-EOF tails are all zeroed Gao Xiang
2023-08-31 11:29 ` [PATCH 6.4.y] " Gao Xiang
2023-08-31 11:29 ` [PATCH 6.1.y] " Gao Xiang
2023-08-31 11:29 ` [PATCH 5.15.y] " Gao Xiang
2023-08-31 11:29 ` [PATCH 5.10.y] " Gao Xiang
2023-08-31 11:29 ` [PATCH 5.4.y] " Gao Xiang
2023-08-31 11:29 ` [PATCH 4.19.y] " Gao Xiang
2023-09-02  8:19 ` [PATCH 6.5.y] " Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox