Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cgroups: fix a serious bug in cgroupstats

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>
Acked-by: Paul Menage <menage@google.com>
Cc: <stable@kernel.org> [2.6.25.x, 2.6.26.x, 2.6.27.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Li Zefan and committed by
Linus Torvalds
33d283be ea7e743e

+5 -2
+5 -2
kernel/cgroup.c
··· 2039 2039 struct cgroup *cgrp; 2040 2040 struct cgroup_iter it; 2041 2041 struct task_struct *tsk; 2042 + 2042 2043 /* 2043 - * Validate dentry by checking the superblock operations 2044 + * Validate dentry by checking the superblock operations, 2045 + * and make sure it's a directory. 2044 2046 */ 2045 - if (dentry->d_sb->s_op != &cgroup_ops) 2047 + if (dentry->d_sb->s_op != &cgroup_ops || 2048 + !S_ISDIR(dentry->d_inode->i_mode)) 2046 2049 goto err; 2047 2050 2048 2051 ret = 0;