[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ckqrcag2cnsrwjccxyzd76vne7epsei7swjulpkfkzwjalk2lj@5iweq3oucsab>
Date: Sun, 29 Jun 2025 23:40:10 -0400
From: Ivan Pravdin <ipravdin.official@...il.com>
To: Heming Zhao <heming.zhao@...e.com>,
Joseph Qi <joseph.qi@...ux.alibaba.com>, mark@...heh.com, jlbec@...lplan.org, ocfs2-devel@...ts.linux.dev,
linux-kernel@...r.kernel.org
Cc: syzbot+20282c1b2184a857ac4c@...kaller.appspotmail.com
Subject: Re: [PATCH] ocfs2: Avoid NULL pointer dereference in
dx_dir_lookup_rec()
On Sun, Jun 29, 2025 at 10:45:15PM GMT, Ivan Pravdin wrote:
> On Mon, Jun 30, 2025 at 10:32:35AM GMT, 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.
> > 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.
>
> Thanks, I will include it in v2.
I have realized that ret is already set to EROFS that acts as a general
FS errno. Unless there are any other objectives this is the latest
version.
Ivan Pravdin
Powered by blists - more mailing lists