From: Adrian Bunk <bunk@stusta.de>
To: linux-kernel@vger.kernel.org
Subject: fs/namespace.c:dup_namespace(): fix a use after free
Date: Wed, 15 Mar 2006 17:37:32 +0100 [thread overview]
Message-ID: <20060315163732.GY13973@stusta.de> (raw)
The Coverity checker spotted the following bug in dup_namespace():
<-- snip -->
if (!new_ns->root) {
up_write(&namespace_sem);
kfree(new_ns);
goto out;
}
...
out:
return new_ns;
<-- snip -->
Callers expect a non-NULL result to not be freed.
Signed-off-by: Adrian Bunk <bunk@stusta.de>
--- linux-2.6.16-rc6-mm1-full/fs/namespace.c.old 2006-03-14 03:22:30.000000000 +0100
+++ linux-2.6.16-rc6-mm1-full/fs/namespace.c 2006-03-14 03:23:14.000000000 +0100
@@ -1389,7 +1389,7 @@ struct namespace *dup_namespace(struct t
new_ns = kmalloc(sizeof(struct namespace), GFP_KERNEL);
if (!new_ns)
- goto out;
+ return NULL;
atomic_set(&new_ns->count, 1);
INIT_LIST_HEAD(&new_ns->list);
@@ -1403,7 +1403,7 @@ struct namespace *dup_namespace(struct t
if (!new_ns->root) {
up_write(&namespace_sem);
kfree(new_ns);
- goto out;
+ return NULL;
}
spin_lock(&vfsmount_lock);
list_add_tail(&new_ns->list, &new_ns->root->mnt_list);
@@ -1444,7 +1444,6 @@ struct namespace *dup_namespace(struct t
if (altrootmnt)
mntput(altrootmnt);
-out:
return new_ns;
}
reply other threads:[~2006-03-15 16:37 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=20060315163732.GY13973@stusta.de \
--to=bunk@stusta.de \
--cc=linux-kernel@vger.kernel.org \
/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.