Skip to contentSkip to conversation

hfsplus: fix null-ptr-deref in hfs_find_init()

PATCH New Yang Yingliang 1 participant 1 message Jun 10, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hfsplus: fix null-ptr-deref in hfs_find_init()

It may lead a null-ptr-deref in hfs_find_init() by mounting a crafted hfs filesystem. So We need check tree in hfs_find_init().

---
 fs/hfsplus/bfind.c | 3 +++
 1 file changed, 3 insertions(+)
fs/hfsplus/bfind.c +3 -0
index ca2ba8c..85bef3e 100644
@@ -16,6 +16,9 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd)
 {
 	void *ptr;
 
+	if (!tree)
+		return -EINVAL;
+
 	fd->tree = tree;
 	fd->bnode = NULL;
 	ptr = kmalloc(tree->max_key_len * 2 + 4, GFP_KERNEL);
Signature · 1 line
1.8.3