From: Stefan Hajnoczi <stefanha@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [PATCH] fuse: fix NULL dereference when new_inode() fails
Date: Thu, 24 May 2018 21:20:04 +0100 [thread overview]
Message-ID: <20180524202004.7813-1-stefanha@redhat.com> (raw)
fuse_ctl_remove_conn() dereferences d_inode(fc->ctl_dentry[i]). If
fuse_ctl_add_dentry() failed to allocate the inode then this field is
NULL and it's not safe to call fuse_ctl_remove_conn().
This patch frees partially initialized dentries in the
fuse_ctl_add_dentry() error case to solve the NULL dereference.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
I spotted this when reading the code. Compile-tested only.
fs/fuse/control.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/fs/fuse/control.c b/fs/fuse/control.c
index b9ea99c5b5b3..ef3af9c32147 100644
--- a/fs/fuse/control.c
+++ b/fs/fuse/control.c
@@ -211,10 +211,13 @@ static struct dentry *fuse_ctl_add_dentry(struct dentry *parent,
if (!dentry)
return NULL;
- fc->ctl_dentry[fc->ctl_ndents++] = dentry;
inode = new_inode(fuse_control_sb);
- if (!inode)
+ if (!inode) {
+ dput(dentry);
return NULL;
+ }
+
+ fc->ctl_dentry[fc->ctl_ndents++] = dentry;
inode->i_ino = get_next_ino();
inode->i_mode = mode;
--
2.17.0
next reply other threads:[~2018-05-24 20:20 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-24 20:20 Stefan Hajnoczi [this message]
2018-06-01 9:24 ` [PATCH] fuse: fix NULL dereference when new_inode() fails Stefan Hajnoczi
2018-06-01 9:28 ` Miklos Szeredi
2018-06-01 13:52 ` Stefan Hajnoczi
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=20180524202004.7813-1-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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 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).