From: Chao Yu <chao@kernel.org>
To: Chunhai Guo <guochunhai@vivo.com>, xiang@kernel.org
Cc: huyue2@coolpad.com, jefflexu@linux.alibaba.com,
linux-erofs@lists.ozlabs.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] erofs: fix to avoid infinite loop in z_erofs_do_read_page() when read page beyond EOF
Date: Tue, 11 Jul 2023 22:13:06 +0800 [thread overview]
Message-ID: <b80ed611-7844-5cb8-255e-b41e78901942@kernel.org> (raw)
In-Reply-To: <20230710093410.44071-1-guochunhai@vivo.com>
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@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
prev parent reply other threads:[~2023-07-11 14:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-10 9:34 Chunhai Guo
2023-07-10 9:56 ` Gao Xiang
2023-07-11 14:13 ` Chao Yu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b80ed611-7844-5cb8-255e-b41e78901942@kernel.org \
--to=chao@kernel.org \
--cc=guochunhai@vivo.com \
--cc=huyue2@coolpad.com \
--cc=jefflexu@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®