All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yang Yingliang <yangyingliang@huawei.com>
To: <linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<slava@dubeyko.com>
Cc: <yangyingliang@huawei.com>
Subject: [PATCH] hfsplus: fix null-ptr-deref in hfs_find_init()
Date: Wed, 10 Jun 2020 21:43:35 +0800	[thread overview]
Message-ID: <1591796615-96336-1-git-send-email-yangyingliang@huawei.com> (raw)

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


                 reply	other threads:[~2020-06-10 13:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1591796615-96336-1-git-send-email-yangyingliang@huawei.com \
    --to=yangyingliang@huawei.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=slava@dubeyko.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.