Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] hfsplus: fix null-ptr-deref in hfs_find_init()
@ 2020-06-10 13:43 Yang Yingliang
  0 siblings, 0 replies; only message in thread
From: Yang Yingliang @ 2020-06-10 13:43 UTC (permalink / raw)
  To: linux-fsdevel, linux-kernel, slava; +Cc: yangyingliang

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().

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 fs/hfsplus/bfind.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c
index ca2ba8c..85bef3e 100644
--- a/fs/hfsplus/bfind.c
+++ b/fs/hfsplus/bfind.c
@@ -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);
-- 
1.8.3


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-10 13:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 13:43 [PATCH] hfsplus: fix null-ptr-deref in hfs_find_init() Yang Yingliang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).