* [PATCH] erofs: fix uninitialized page cache reported by KMSAN
[not found] <ab2a337d-c2dd-437d-9ab8-e3b837f1ff1a@I-love.SAKURA.ne.jp>
@ 2024-03-04 3:53 ` Gao Xiang
2024-03-04 17:51 ` Sandeep Dhavale
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Gao Xiang @ 2024-03-04 3:53 UTC (permalink / raw)
To: linux-erofs
Cc: LKML, linux-fsdevel, Tetsuo Handa, Roberto Sassu, syzkaller-bugs,
Gao Xiang, syzbot+7bc44a489f0ef0670bd5
syzbot reports a KMSAN reproducer [1] which generates a crafted
filesystem image and causes IMA to read uninitialized page cache.
Later, (rq->outputsize > rq->inputsize) will be formally supported
after either large uncompressed pclusters (> block size) or big
lclusters are landed. However, currently there is no way to generate
such filesystems by using mkfs.erofs.
Thus, let's mark this condition as unsupported for now.
[1] https://lore.kernel.org/r/0000000000002be12a0611ca7ff8@google.com
Reported-by: syzbot+7bc44a489f0ef0670bd5@syzkaller.appspotmail.com
Fixes: 1ca01520148a ("erofs: refine z_erofs_transform_plain() for sub-page block support")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
fs/erofs/decompressor.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
index d4cee95af14c..2ec9b2bb628d 100644
--- a/fs/erofs/decompressor.c
+++ b/fs/erofs/decompressor.c
@@ -323,7 +323,8 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
unsigned int cur = 0, ni = 0, no, pi, po, insz, cnt;
u8 *kin;
- DBG_BUGON(rq->outputsize > rq->inputsize);
+ if (rq->outputsize > rq->inputsize)
+ return -EOPNOTSUPP;
if (rq->alg == Z_EROFS_COMPRESSION_INTERLACED) {
cur = bs - (rq->pageofs_out & (bs - 1));
pi = (rq->pageofs_in + rq->inputsize - cur) & ~PAGE_MASK;
--
2.39.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs: fix uninitialized page cache reported by KMSAN
2024-03-04 3:53 ` [PATCH] erofs: fix uninitialized page cache reported by KMSAN Gao Xiang
@ 2024-03-04 17:51 ` Sandeep Dhavale
2024-03-05 2:17 ` Yue Hu
2024-03-07 1:04 ` Chao Yu
2 siblings, 0 replies; 4+ messages in thread
From: Sandeep Dhavale @ 2024-03-04 17:51 UTC (permalink / raw)
To: Gao Xiang
Cc: linux-erofs, syzbot+7bc44a489f0ef0670bd5, Tetsuo Handa,
syzkaller-bugs, LKML, Roberto Sassu, linux-fsdevel
On Sun, Mar 3, 2024 at 7:54 PM Gao Xiang <hsiangkao@linux.alibaba.com> wrote:
>
> syzbot reports a KMSAN reproducer [1] which generates a crafted
> filesystem image and causes IMA to read uninitialized page cache.
>
> Later, (rq->outputsize > rq->inputsize) will be formally supported
> after either large uncompressed pclusters (> block size) or big
> lclusters are landed. However, currently there is no way to generate
> such filesystems by using mkfs.erofs.
>
> Thus, let's mark this condition as unsupported for now.
>
> [1] https://lore.kernel.org/r/0000000000002be12a0611ca7ff8@google.com
>
> Reported-by: syzbot+7bc44a489f0ef0670bd5@syzkaller.appspotmail.com
> Fixes: 1ca01520148a ("erofs: refine z_erofs_transform_plain() for sub-page block support")
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> ---
> fs/erofs/decompressor.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> index d4cee95af14c..2ec9b2bb628d 100644
> --- a/fs/erofs/decompressor.c
> +++ b/fs/erofs/decompressor.c
> @@ -323,7 +323,8 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
> unsigned int cur = 0, ni = 0, no, pi, po, insz, cnt;
> u8 *kin;
>
> - DBG_BUGON(rq->outputsize > rq->inputsize);
> + if (rq->outputsize > rq->inputsize)
> + return -EOPNOTSUPP;
> if (rq->alg == Z_EROFS_COMPRESSION_INTERLACED) {
> cur = bs - (rq->pageofs_out & (bs - 1));
> pi = (rq->pageofs_in + rq->inputsize - cur) & ~PAGE_MASK;
> --
> 2.39.3
>
LGTM.
Reviewed-by: Sandeep Dhavale <dhavale@google.com>
Thanks,
Sandeep.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs: fix uninitialized page cache reported by KMSAN
2024-03-04 3:53 ` [PATCH] erofs: fix uninitialized page cache reported by KMSAN Gao Xiang
2024-03-04 17:51 ` Sandeep Dhavale
@ 2024-03-05 2:17 ` Yue Hu
2024-03-07 1:04 ` Chao Yu
2 siblings, 0 replies; 4+ messages in thread
From: Yue Hu @ 2024-03-05 2:17 UTC (permalink / raw)
To: Gao Xiang
Cc: linux-erofs, syzbot+7bc44a489f0ef0670bd5, Tetsuo Handa,
syzkaller-bugs, LKML, Roberto Sassu, linux-fsdevel
On Mon, 4 Mar 2024 11:53:39 +0800
Gao Xiang <hsiangkao@linux.alibaba.com> wrote:
> syzbot reports a KMSAN reproducer [1] which generates a crafted
> filesystem image and causes IMA to read uninitialized page cache.
>
> Later, (rq->outputsize > rq->inputsize) will be formally supported
> after either large uncompressed pclusters (> block size) or big
> lclusters are landed. However, currently there is no way to generate
> such filesystems by using mkfs.erofs.
>
> Thus, let's mark this condition as unsupported for now.
>
> [1] https://lore.kernel.org/r/0000000000002be12a0611ca7ff8@google.com
>
> Reported-by: syzbot+7bc44a489f0ef0670bd5@syzkaller.appspotmail.com
> Fixes: 1ca01520148a ("erofs: refine z_erofs_transform_plain() for sub-page block support")
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
> ---
> fs/erofs/decompressor.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/erofs/decompressor.c b/fs/erofs/decompressor.c
> index d4cee95af14c..2ec9b2bb628d 100644
> --- a/fs/erofs/decompressor.c
> +++ b/fs/erofs/decompressor.c
> @@ -323,7 +323,8 @@ static int z_erofs_transform_plain(struct z_erofs_decompress_req *rq,
> unsigned int cur = 0, ni = 0, no, pi, po, insz, cnt;
> u8 *kin;
>
> - DBG_BUGON(rq->outputsize > rq->inputsize);
> + if (rq->outputsize > rq->inputsize)
> + return -EOPNOTSUPP;
> if (rq->alg == Z_EROFS_COMPRESSION_INTERLACED) {
> cur = bs - (rq->pageofs_out & (bs - 1));
> pi = (rq->pageofs_in + rq->inputsize - cur) & ~PAGE_MASK;
Reviewed-by: Yue Hu <huyue2@coolpad.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] erofs: fix uninitialized page cache reported by KMSAN
2024-03-04 3:53 ` [PATCH] erofs: fix uninitialized page cache reported by KMSAN Gao Xiang
2024-03-04 17:51 ` Sandeep Dhavale
2024-03-05 2:17 ` Yue Hu
@ 2024-03-07 1:04 ` Chao Yu
2 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2024-03-07 1:04 UTC (permalink / raw)
To: Gao Xiang, linux-erofs
Cc: syzbot+7bc44a489f0ef0670bd5, Tetsuo Handa, syzkaller-bugs, LKML,
Roberto Sassu, linux-fsdevel
On 2024/3/4 11:53, Gao Xiang wrote:
> syzbot reports a KMSAN reproducer [1] which generates a crafted
> filesystem image and causes IMA to read uninitialized page cache.
>
> Later, (rq->outputsize > rq->inputsize) will be formally supported
> after either large uncompressed pclusters (> block size) or big
> lclusters are landed. However, currently there is no way to generate
> such filesystems by using mkfs.erofs.
>
> Thus, let's mark this condition as unsupported for now.
>
> [1] https://lore.kernel.org/r/0000000000002be12a0611ca7ff8@google.com
>
> Reported-by: syzbot+7bc44a489f0ef0670bd5@syzkaller.appspotmail.com
> Fixes: 1ca01520148a ("erofs: refine z_erofs_transform_plain() for sub-page block support")
> Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-03-07 1:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <ab2a337d-c2dd-437d-9ab8-e3b837f1ff1a@I-love.SAKURA.ne.jp>
2024-03-04 3:53 ` [PATCH] erofs: fix uninitialized page cache reported by KMSAN Gao Xiang
2024-03-04 17:51 ` Sandeep Dhavale
2024-03-05 2:17 ` Yue Hu
2024-03-07 1:04 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).