From: Chao Yu <chao@kernel.org>
To: Gao Xiang <hsiangkao@linux.alibaba.com>,
Hongbo Li <lihongbo22@huawei.com>,
xiang@kernel.org
Cc: chao@kernel.org, linux-erofs@lists.ozlabs.org,
linux-kernel@vger.kernel.org, Yue Hu <zbestahu@gmail.com>,
Jeffle Xu <jefflexu@linux.alibaba.com>,
Sandeep Dhavale <dhavale@google.com>
Subject: Re: [PATCH] erofs: do sanity check on m->type in z_erofs_load_compact_lcluster()
Date: Tue, 8 Jul 2025 15:10:19 +0800 [thread overview]
Message-ID: <6edacba6-a97e-460f-af06-96e8acf5546a@kernel.org> (raw)
In-Reply-To: <1a27683d-580b-4fa9-bd86-902ea78afe46@linux.alibaba.com>
On 7/8/25 10:35, Gao Xiang wrote:
>
>
> On 2025/7/8 10:30, Hongbo Li wrote:
>>
>>
>> On 2025/7/7 16:47, Chao Yu wrote:
>>> All below functions will do sanity check on m->type, let's move sanity
>>> check to z_erofs_load_compact_lcluster() for cleanup.
>>> - z_erofs_map_blocks_fo
>>> - z_erofs_get_extent_compressedlen
>>> - z_erofs_get_extent_decompressedlen
>>> - z_erofs_extent_lookback
>>>
>>> Signed-off-by: Chao Yu <chao@kernel.org>
>>> ---
>>> fs/erofs/zmap.c | 60 ++++++++++++++++++-------------------------------
>>> 1 file changed, 22 insertions(+), 38 deletions(-)
>>>
>>> diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c
>>> index 0bebc6e3a4d7..e530b152e14e 100644
>>> --- a/fs/erofs/zmap.c
>>> +++ b/fs/erofs/zmap.c
>>> @@ -240,6 +240,13 @@ static int z_erofs_load_compact_lcluster(struct z_erofs_maprecorder *m,
>>> static int z_erofs_load_lcluster_from_disk(struct z_erofs_maprecorder *m,
>>> unsigned int lcn, bool lookahead)
>>> {
>>> + if (m->type >= Z_EROFS_LCLUSTER_TYPE_MAX) {
>>> + erofs_err(m->inode->i_sb, "unknown type %u @ lcn %u of nid %llu",
>>> + m->type, lcn, EROFS_I(m->inode)->nid);
>>> + DBG_BUGON(1);
>>> + return -EOPNOTSUPP;
>>> + }
>>> +
>>
>> Hi, Chao,
>>
>> After moving the condition in here, there is no need to check in z_erofs_extent_lookback, z_erofs_get_extent_compressedlen and z_erofs_get_extent_decompressedlen. Because in z_erofs_map_blocks_fo,
>> the condition has been checked in before. Right?
>
> I've replied some similar question.
>
> Because z_erofs_get_extent_compressedlen and z_erofs_get_extent_decompressedlen()
> use the different lcn (lcluster) against z_erofs_map_blocks_fo().
>
> So if a new lcn(lcluster number) is loaded, we'd check if the type is valid.
Yeah, Xiang has noticed that previously [1], the case is as below, so we'd better check the
condition in z_erofs_load_compact_lcluster() rather than z_erofs_map_blocks_fo():
- z_erofs_extent_lookback
- z_erofs_load_lcluster_from_disk
- z_erofs_load_full_lcluster
: m->type = advise & Z_EROFS_LI_LCLUSTER_TYPE_MASK;
- z_erofs_load_compact_lcluster
: m->type = type;
[1] https://lore.kernel.org/linux-erofs/04050888-7abf-40fa-98d6-6215b8ba989e@kernel.org/
Thanks,
>
> Thanks,
> Gao Xiang
>
>
next prev parent reply other threads:[~2025-07-08 7:10 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-07 8:47 [PATCH] erofs: do sanity check on m->type in z_erofs_load_compact_lcluster() Chao Yu
2025-07-08 2:30 ` Hongbo Li
2025-07-08 2:34 ` Hongbo Li
2025-07-08 2:35 ` Gao Xiang
2025-07-08 2:45 ` Hongbo Li
2025-07-08 7:10 ` Chao Yu [this message]
2025-07-08 2:58 ` Gao Xiang
2025-07-08 10:51 ` Chao Yu
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=6edacba6-a97e-460f-af06-96e8acf5546a@kernel.org \
--to=chao@kernel.org \
--cc=dhavale@google.com \
--cc=hsiangkao@linux.alibaba.com \
--cc=jefflexu@linux.alibaba.com \
--cc=lihongbo22@huawei.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xiang@kernel.org \
--cc=zbestahu@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.