mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Heming Zhao <heming.zhao@suse.com>,
	Ivan Pravdin <ipravdin.official@gmail.com>,
	mark@fasheh.com, jlbec@evilplan.org, ocfs2-devel@lists.linux.dev,
	linux-kernel@vger.kernel.org
Cc: syzbot+20282c1b2184a857ac4c@syzkaller.appspotmail.com
Subject: Re: [PATCH] ocfs2: Avoid NULL pointer dereference in dx_dir_lookup_rec()
Date: Mon, 30 Jun 2025 14:58:01 +0800	[thread overview]
Message-ID: <a259f224-a471-45e3-84de-7071ec6595e9@linux.alibaba.com> (raw)
In-Reply-To: <d6a11613-9763-4d9a-b4ad-5f451f770b70@suse.com>



On 2025/6/30 10:32, Heming Zhao wrote:
> On 6/30/25 09:26, Joseph Qi wrote:
>> Hi,
>>
>>
>> On 2025/6/27 10:38, Ivan Pravdin wrote:
>>> When a directory entry is not found, ocfs2_dx_dir_lookup_rec() prints an
>>> error message that unconditionally dereferences the 'rec' pointer.
>>> However, if 'rec' is NULL, this leads to a NULL pointer dereference and
>>> a kernel panic.
>>>
>>
>> This looks possible, but syzbot reports slab-out-of-bounds Read in
>> ocfs2_dx_dir_lookup_rec(), not NULL pointer dereference.
>>
>> So I think it is because it construct a malicious image and set a wrong
>> l_recs, then access this damaged l_recs.
>>
>> Thanks,
>> Joseph
> 
> I think this proposed fix (at least the fix method) is acceptable.

But this seems different from the issue syzbot reports, right?
https://lore.kernel.org/all/67483b75.050a0220.253251.007c.GAE@google.com/T/

Thanks,
Joseph

> the crash occurs at ocfs2_error(), where the pointer 'rec' must be incorrect.
> look back at the previous code lines:
>         for (i = le16_to_cpu(el->l_next_free_rec) - 1; i >= 0; i--) {
>                 rec = &el->l_recs[i];
> 
>                 if (le32_to_cpu(rec->e_cpos) <= major_hash) {
>                         found = 1;
>                         break;
>                 }
>         }
> 
> either 'el->l_next_free_rec' or 'el->l_recs[i]' has an incorrect value.
> we can do nothing about this kind of error, simply returning errno to caller is sufficient.
> 
> btw, ocfs2-tools has a similar function "static errcode_t ocfs2_dx_dir_lookup_rec()"@libocfs2/dir_indexed.c, which sets ret with OCFS2_ET_CORRUPT_EXTENT_BLOCK and return.
> 




  parent reply	other threads:[~2025-06-30  6:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-27  2:38 Ivan Pravdin
2025-06-30  1:26 ` Joseph Qi
2025-06-30  2:32   ` Heming Zhao
2025-06-30  2:45     ` Ivan Pravdin
2025-06-30  3:40       ` Ivan Pravdin
2025-06-30  6:58     ` Joseph Qi [this message]
2025-06-30  7:23       ` Heming Zhao

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=a259f224-a471-45e3-84de-7071ec6595e9@linux.alibaba.com \
    --to=joseph.qi@linux.alibaba.com \
    --cc=heming.zhao@suse.com \
    --cc=ipravdin.official@gmail.com \
    --cc=jlbec@evilplan.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark@fasheh.com \
    --cc=ocfs2-devel@lists.linux.dev \
    --cc=syzbot+20282c1b2184a857ac4c@syzkaller.appspotmail.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 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®