[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b80ed611-7844-5cb8-255e-b41e78901942@kernel.org>
Date: Tue, 11 Jul 2023 22:13:06 +0800
From: Chao Yu <chao@...nel.org>
To: Chunhai Guo <guochunhai@...o.com>, xiang@...nel.org
Cc: huyue2@...lpad.com, jefflexu@...ux.alibaba.com,
linux-erofs@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] erofs: fix to avoid infinite loop in
z_erofs_do_read_page() when read page beyond EOF
On 2023/7/10 17:34, Chunhai Guo wrote:
> z_erofs_do_read_page() may loop infinitely due to the inappropriate
> truncation in the below statement. Since the offset is 64 bits and min_t()
> truncates the result to 32 bits. The solution is to replace unsigned int
> with a 64-bit type, such as erofs_off_t.
> cur = end - min_t(unsigned int, offset + end - map->m_la, end);
>
> - For example:
> - offset = 0x400160000
> - end = 0x370
> - map->m_la = 0x160370
> - offset + end - map->m_la = 0x400000000
> - offset + end - map->m_la = 0x00000000 (truncated as unsigned int)
> - Expected result:
> - cur = 0
> - Actual result:
> - cur = 0x370
>
> Signed-off-by: Chunhai Guo <guochunhai@...o.com>
Reviewed-by: Chao Yu <chao@...nel.org>
Thanks,
Powered by blists - more mailing lists