summaryrefslogtreecommitdiff
path: root/net/9p
diff options
context:
space:
mode:
authorDominique Martinet <dominique.martinet@cea.fr>2018-08-28 01:32:35 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-11-22 09:32:46 +0300
commit78a2d6e9a025931a1fdc0663fc693ebf5fe77026 (patch)
tree6c96e9e1d8e3c61696c79e63cce3930f592f23ea /net/9p
parentb29137a4c89bc8ca3c9ea2e2ded7077858b0715c (diff)
downloadlinux-78a2d6e9a025931a1fdc0663fc693ebf5fe77026.tar.xz
9p: clear dangling pointers in p9stat_free
[ Upstream commit 62e3941776fea8678bb8120607039410b1b61a65 ] p9stat_free is more of a cleanup function than a 'free' function as it only frees the content of the struct; there are chances of use-after-free if it is improperly used (e.g. p9stat_free called twice as it used to be possible to) Clearing dangling pointers makes the function idempotent and safer to use. Link: http://lkml.kernel.org/r/1535410108-20650-2-git-send-email-asmadeus@codewreck.org Signed-off-by: Dominique Martinet <dominique.martinet@cea.fr> Reported-by: syzbot+d4252148d198410b864f@syzkaller.appspotmail.com Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/9p')
-rw-r--r--net/9p/protocol.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/9p/protocol.c b/net/9p/protocol.c
index ab9127ec5b7a..bceb6999614f 100644
--- a/net/9p/protocol.c
+++ b/net/9p/protocol.c
@@ -45,10 +45,15 @@ p9pdu_writef(struct p9_fcall *pdu, int proto_version, const char *fmt, ...);
void p9stat_free(struct p9_wstat *stbuf)
{
kfree(stbuf->name);
+ stbuf->name = NULL;
kfree(stbuf->uid);
+ stbuf->uid = NULL;
kfree(stbuf->gid);
+ stbuf->gid = NULL;
kfree(stbuf->muid);
+ stbuf->muid = NULL;
kfree(stbuf->extension);
+ stbuf->extension = NULL;
}
EXPORT_SYMBOL(p9stat_free);