[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Y3MGf3TzgKpAz4IP@B-P7TQMD6M-0146.local>
Date: Tue, 15 Nov 2022 11:24:47 +0800
From: Gao Xiang <hsiangkao@...ux.alibaba.com>
To: Siddh Raman Pant <code@...dh.me>
Cc: Gao Xiang <xiang@...nel.org>, Chao Yu <chao@...nel.org>,
Yue Hu <huyue2@...lpad.com>,
Jeffle Xu <jefflexu@...ux.alibaba.com>,
linux-erofs <linux-erofs@...ts.ozlabs.org>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH] erofs/zmap.c: Bail out when no further region remains
On Mon, Nov 14, 2022 at 05:33:49PM +0530, Siddh Raman Pant wrote:
> The following calculation of iomap->length on line 798 in
> z_erofs_iomap_begin_report() can yield 0:
> if (iomap->offset >= inode->i_size)
> iomap->length = length + map.m_la - offset;
>
> This triggers a WARN_ON in iomap_iter_done() (see line 34 of
> fs/iomap/iter.c).
>
> Hence, return error when this scenario is encountered.
>
> ============================================================
>
> This was reported as a crash by syzbot under an issue about
> warning encountered in iomap_iter_done(), but unrelated to
> erofs. Hence, not adding issue hash in Reported-by line.
>
> C reproducer: https://syzkaller.appspot.com/text?tag=ReproC&x=1037a6b2880000
> Kernel config: https://syzkaller.appspot.com/text?tag=KernelConfig&x=e2021a61197ebe02
> Dashboard link: https://syzkaller.appspot.com/bug?extid=a8e049cd3abd342936b6
>
> Reported-by: syzbot@...kaller.appspotmail.com
> Signed-off-by: Siddh Raman Pant <code@...dh.me>
> ---
> fs/erofs/zmap.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
> index 0bb66927e3d0..bad852983eb9 100644
> --- a/fs/erofs/zmap.c
> +++ b/fs/erofs/zmap.c
> @@ -796,6 +796,9 @@ static int z_erofs_iomap_begin_report(struct inode *inode, loff_t offset,
> */
> if (iomap->offset >= inode->i_size)
> iomap->length = length + map.m_la - offset;
> +
> + if (iomap->length == 0)
I just wonder if we should return -EINVAL for post-EOF cases or
IOMAP_HOLE with arbitrary length?
Thanks,
Gao Xiang
> + return -EINVAL;
> }
> iomap->flags = 0;
> return 0;
> --
> 2.35.1
>
Powered by blists - more mailing lists