[lvc-project] [PATCH] ocfs2: add extent record check in ocfs2_commit_truncate()
Joseph Qi
joseph.qi at linux.alibaba.com
Mon Dec 30 05:26:40 MSK 2024
On 2024/12/30 10:05, Glass Su wrote:
>
>
>> On Dec 29, 2024, at 18:49, Matthew Wilcox <willy at infradead.org> wrote:
>>
>> On Sun, Dec 29, 2024 at 10:05:17AM +0800, Glass Su wrote:
>>>> +++ b/fs/ocfs2/alloc.c
>>>> @@ -7219,12 +7219,20 @@ int ocfs2_commit_truncate(struct ocfs2_super *osb,
>>>> struct ocfs2_extent_rec *rec;
>>>> struct ocfs2_path *path = NULL;
>>>> struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
>>>> + u16 tree_depth = le16_to_cpu(di->id2.i_list.l_tree_depth);
>>>
>>> No need of tree_depth. Just call
>>> If (unlikely(le16_to_cpu(di->id2.i_list.l_tree_depth) >= OCFS2_MAX_PATH_DEPTH)) {
>>
>> That seems more complicated to me. I find the original easier to read.
>>
>>>> + if (unlikely(tree_depth >= OCFS2_MAX_PATH_DEPTH)) {
>>>> + ocfs2_error(inode->i_sb,
>>>> + "dinode %llu has invalid extent record depth %u\n",
>>>> + (u64)di_bh->b_blocknr, tree_depth);
>>>> + return -EINVAL;
>>>
>>> -EIO is better.
>>
>> -EFSCORRUPTED is surely the right errno here?
>
> Indeed. -EIO is an old school errno. -EFSCORRUPTED is more accurate.
>
Yes, EFSCORRUPTED is more proper.
It seems that it is caused by a crafted ocfs2 image. And I think there will
be more bugs for those similar crafted images.
Thanks,
Joseph
More information about the lvc-project
mailing list