* [PATCH] cgroup: initialize xattr before calling d_instantiate()
@ 2013-05-14 11:44 Li Zefan
[not found] ` <51922394.2020002-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Li Zefan @ 2013-05-14 11:44 UTC (permalink / raw)
To: Tejun Heo; +Cc: LSM, LKML, Cgroups, Containers, Casey Schaufler, Ivan Bulatovic
cgroup_create_file() calls d_instantiate(), which may decide to look
at the xattrs on the file. Smack always does this and SELinux can be
configured to do so.
But cgroup_add_file() didn't initialize xattrs before calling
cgroup_create_file(), which finally leads to dereferencing NULL
dentry->d_fsdata.
This bug has been there since cgroup xattr was introduced.
Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # 3.8.x
Reported-by: Ivan Bulatovic <combuster-fd97jBR+K/7gvPn8nOUGzA@public.gmane.org>
Reported-by: Casey Schaufler <casey-iSGtlc1asvQWG2LlvL+J4A@public.gmane.org>
Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
kernel/cgroup.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 2a99262..38b1365 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2699,13 +2699,14 @@ static int cgroup_add_file(struct cgroup *cgrp, struct cgroup_subsys *subsys,
goto out;
}
+ cfe->type = (void *)cft;
+ cfe->dentry = dentry;
+ dentry->d_fsdata = cfe;
+ simple_xattrs_init(&cfe->xattrs);
+
mode = cgroup_file_mode(cft);
error = cgroup_create_file(dentry, mode | S_IFREG, cgrp->root->sb);
if (!error) {
- cfe->type = (void *)cft;
- cfe->dentry = dentry;
- dentry->d_fsdata = cfe;
- simple_xattrs_init(&cfe->xattrs);
list_add_tail(&cfe->node, &parent->files);
cfe = NULL;
}
--
1.8.0.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] cgroup: initialize xattr before calling d_instantiate()
[not found] ` <51922394.2020002-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2013-05-14 15:38 ` Tejun Heo
0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2013-05-14 15:38 UTC (permalink / raw)
To: Li Zefan; +Cc: Containers, LKML, LSM, Casey Schaufler, Cgroups, Ivan Bulatovic
On Tue, May 14, 2013 at 07:44:20PM +0800, Li Zefan wrote:
> cgroup_create_file() calls d_instantiate(), which may decide to look
> at the xattrs on the file. Smack always does this and SELinux can be
> configured to do so.
>
> But cgroup_add_file() didn't initialize xattrs before calling
> cgroup_create_file(), which finally leads to dereferencing NULL
> dentry->d_fsdata.
>
> This bug has been there since cgroup xattr was introduced.
>
> Cc: <stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org> # 3.8.x
> Reported-by: Ivan Bulatovic <combuster-fd97jBR+K/7gvPn8nOUGzA@public.gmane.org>
> Reported-by: Casey Schaufler <casey-iSGtlc1asvQWG2LlvL+J4A@public.gmane.org>
> Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Applied to cgroup/for-3.10-fixes.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-14 15:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-14 11:44 [PATCH] cgroup: initialize xattr before calling d_instantiate() Li Zefan
[not found] ` <51922394.2020002-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-05-14 15:38 ` Tejun Heo
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).