Skip to content

Commit 44acc46

Browse files
ivpravdinakpm00
authored andcommitted
ocfs2: avoid NULL pointer dereference in dx_dir_lookup_rec()
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. Add an explicit check empty extent list to avoid dereferencing NULL 'rec' pointer. Link: https://lkml.kernel.org/r/20250708001009.372263-1-ipravdin.official@gmail.com Reported-by: syzbot+20282c1b2184a857ac4c@syzkaller.appspotmail.com Closes: https://lore.kernel.org/all/67cd7e29.050a0220.e1a89.0007.GAE@google.com/ Signed-off-by: Ivan Pravdin <ipravdin.official@gmail.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Jun Piao <piaojun@huawei.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 988f451 commit 44acc46

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

fs/ocfs2/dir.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,14 @@ static int ocfs2_dx_dir_lookup_rec(struct inode *inode,
798798
}
799799
}
800800

801+
if (le16_to_cpu(el->l_next_free_rec) == 0) {
802+
ret = ocfs2_error(inode->i_sb,
803+
"Inode %lu has empty extent list at depth %u\n",
804+
inode->i_ino,
805+
le16_to_cpu(el->l_tree_depth));
806+
goto out;
807+
}
808+
801809
found = 0;
802810
for (i = le16_to_cpu(el->l_next_free_rec) - 1; i >= 0; i--) {
803811
rec = &el->l_recs[i];

0 commit comments

Comments
 (0)