All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroups: fix a serious bug in cgroupstats
@ 2008-11-19  8:14 Li Zefan
  2008-11-19  8:25 ` Andrew Morton
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Li Zefan @ 2008-11-19  8:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Paul Menage, Balbir Singh, LKML, Linux Containers

Try this, and you'll get oops immediately:
 # cd Documentation/accounting/
 # gcc -o getdelays getdelays.c
 # mount -t cgroup -o debug xxx /mnt
 # ./getdelays -C /mnt/tasks

Because a normal file's dentry->d_fsdata is a pointer to struct cftype,
not struct cgroup.

After the patch, it returns EINVAL if we try to get cgroupstats
from a normal file.

CC: Balbir Singh <balbir@linux.vnet.ibm.com>
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
 kernel/cgroup.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 358e775..f6f5219 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2039,10 +2039,13 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
 	struct cgroup *cgrp;
 	struct cgroup_iter it;
 	struct task_struct *tsk;
+
 	/*
-	 * Validate dentry by checking the superblock operations
+	 * Validate dentry by checking the superblock operations,
+	 * and make sure it's a directory.
 	 */
-	if (dentry->d_sb->s_op != &cgroup_ops)
+	if (dentry->d_sb->s_op != &cgroup_ops ||
+	    !S_ISDIR(dentry->d_inode->i_mode))
 		 goto err;
 
 	ret = 0;
-- 
1.5.4.rc3

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH] cgroups: fix a serious bug in cgroupstats
@ 2008-11-19  8:14 Li Zefan
  0 siblings, 0 replies; 10+ messages in thread
From: Li Zefan @ 2008-11-19  8:14 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linux Containers, Paul Menage, LKML, Balbir Singh

Try this, and you'll get oops immediately:
 # cd Documentation/accounting/
 # gcc -o getdelays getdelays.c
 # mount -t cgroup -o debug xxx /mnt
 # ./getdelays -C /mnt/tasks

Because a normal file's dentry->d_fsdata is a pointer to struct cftype,
not struct cgroup.

After the patch, it returns EINVAL if we try to get cgroupstats
from a normal file.

CC: Balbir Singh <balbir-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Signed-off-by: Li Zefan <lizf-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
---
 kernel/cgroup.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 358e775..f6f5219 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -2039,10 +2039,13 @@ int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry)
 	struct cgroup *cgrp;
 	struct cgroup_iter it;
 	struct task_struct *tsk;
+
 	/*
-	 * Validate dentry by checking the superblock operations
+	 * Validate dentry by checking the superblock operations,
+	 * and make sure it's a directory.
 	 */
-	if (dentry->d_sb->s_op != &cgroup_ops)
+	if (dentry->d_sb->s_op != &cgroup_ops ||
+	    !S_ISDIR(dentry->d_inode->i_mode))
 		 goto err;
 
 	ret = 0;
-- 
1.5.4.rc3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-11-19 22:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-19  8:14 [PATCH] cgroups: fix a serious bug in cgroupstats Li Zefan
2008-11-19  8:25 ` Andrew Morton
2008-11-19  8:29   ` Li Zefan
     [not found]   ` <20081119002552.3840e3d2.akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2008-11-19  8:29     ` Li Zefan
2008-11-19  8:30     ` Balbir Singh
2008-11-19  8:30   ` Balbir Singh
     [not found] ` <4923CAF1.1020404-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2008-11-19  8:25   ` Andrew Morton
2008-11-19 22:31   ` Paul Menage
2008-11-19 22:31 ` Paul Menage
  -- strict thread matches above, loose matches on Subject: below --
2008-11-19  8:14 Li Zefan

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.