Skip to contentSkip to conversation

ocfs2-avoid-null-pointer-dereference-in-dx_dir_lookup_rec.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Jul 20, 2025

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: ocfs2: avoid NULL pointer dereference in dx_dir_lookup_rec()
has been removed from the -mm tree. Its filename was
ocfs2-avoid-null-pointer-dereference-in-dx_dir_lookup_rec.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Ivan Pravdin <[email protected]>
Subject: ocfs2: avoid NULL pointer dereference in dx_dir_lookup_rec()
Date: Mon, 7 Jul 2025 20:10:09 -0400

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.

---

 fs/ocfs2/dir.c |    8 ++++++++
 1 file changed, 8 insertions(+)
fs/ocfs2/dir.c renamed from fs/ocfs2/dir.c~ocfs2-avoid-null-pointer-dereference-in-dx_dir_lookup_rec +8 -0
@@ -798,6 +798,14 @@ static int ocfs2_dx_dir_lookup_rec(struc
 		}
 	}
 
+	if (le16_to_cpu(el->l_next_free_rec) == 0) {
+		ret = ocfs2_error(inode->i_sb,
+				  "Inode %lu has empty extent list at depth %u\n",
+				  inode->i_ino,
+				  le16_to_cpu(el->l_tree_depth));
+		goto out;
+	}
+
 	found = 0;
 	for (i = le16_to_cpu(el->l_next_free_rec) - 1; i >= 0; i--) {
 		rec = &el->l_recs[i];

_

Patches currently in -mm which might be from [email protected] are