diff options
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 2731d115d725..1d2b6ceea95d 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
@@ -27,9 +27,11 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include <linux/cgroup.h> | 29 | #include <linux/cgroup.h> |
30 | #include <linux/cred.h> | ||
30 | #include <linux/ctype.h> | 31 | #include <linux/ctype.h> |
31 | #include <linux/errno.h> | 32 | #include <linux/errno.h> |
32 | #include <linux/fs.h> | 33 | #include <linux/fs.h> |
34 | #include <linux/init_task.h> | ||
33 | #include <linux/kernel.h> | 35 | #include <linux/kernel.h> |
34 | #include <linux/list.h> | 36 | #include <linux/list.h> |
35 | #include <linux/mm.h> | 37 | #include <linux/mm.h> |
@@ -59,7 +61,7 @@ | |||
59 | #include <linux/poll.h> | 61 | #include <linux/poll.h> |
60 | #include <linux/flex_array.h> /* used in cgroup_attach_proc */ | 62 | #include <linux/flex_array.h> /* used in cgroup_attach_proc */ |
61 | 63 | ||
62 | #include <asm/atomic.h> | 64 | #include <linux/atomic.h> |
63 | 65 | ||
64 | static DEFINE_MUTEX(cgroup_mutex); | 66 | static DEFINE_MUTEX(cgroup_mutex); |
65 | 67 | ||
@@ -1514,6 +1516,7 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, | |||
1514 | struct cgroup *root_cgrp = &root->top_cgroup; | 1516 | struct cgroup *root_cgrp = &root->top_cgroup; |
1515 | struct inode *inode; | 1517 | struct inode *inode; |
1516 | struct cgroupfs_root *existing_root; | 1518 | struct cgroupfs_root *existing_root; |
1519 | const struct cred *cred; | ||
1517 | int i; | 1520 | int i; |
1518 | 1521 | ||
1519 | BUG_ON(sb->s_root != NULL); | 1522 | BUG_ON(sb->s_root != NULL); |
@@ -1593,7 +1596,9 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, | |||
1593 | BUG_ON(!list_empty(&root_cgrp->children)); | 1596 | BUG_ON(!list_empty(&root_cgrp->children)); |
1594 | BUG_ON(root->number_of_cgroups != 1); | 1597 | BUG_ON(root->number_of_cgroups != 1); |
1595 | 1598 | ||
1599 | cred = override_creds(&init_cred); | ||
1596 | cgroup_populate_dir(root_cgrp); | 1600 | cgroup_populate_dir(root_cgrp); |
1601 | revert_creds(cred); | ||
1597 | mutex_unlock(&cgroup_mutex); | 1602 | mutex_unlock(&cgroup_mutex); |
1598 | mutex_unlock(&inode->i_mutex); | 1603 | mutex_unlock(&inode->i_mutex); |
1599 | } else { | 1604 | } else { |
@@ -1697,7 +1702,6 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen) | |||
1697 | { | 1702 | { |
1698 | char *start; | 1703 | char *start; |
1699 | struct dentry *dentry = rcu_dereference_check(cgrp->dentry, | 1704 | struct dentry *dentry = rcu_dereference_check(cgrp->dentry, |
1700 | rcu_read_lock_held() || | ||
1701 | cgroup_lock_is_held()); | 1705 | cgroup_lock_is_held()); |
1702 | 1706 | ||
1703 | if (!dentry || cgrp == dummytop) { | 1707 | if (!dentry || cgrp == dummytop) { |
@@ -1723,7 +1727,6 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen) | |||
1723 | break; | 1727 | break; |
1724 | 1728 | ||
1725 | dentry = rcu_dereference_check(cgrp->dentry, | 1729 | dentry = rcu_dereference_check(cgrp->dentry, |
1726 | rcu_read_lock_held() || | ||
1727 | cgroup_lock_is_held()); | 1730 | cgroup_lock_is_held()); |
1728 | if (!cgrp->parent) | 1731 | if (!cgrp->parent) |
1729 | continue; | 1732 | continue; |
@@ -3542,7 +3545,8 @@ static int cgroup_write_event_control(struct cgroup *cgrp, struct cftype *cft, | |||
3542 | } | 3545 | } |
3543 | 3546 | ||
3544 | /* the process need read permission on control file */ | 3547 | /* the process need read permission on control file */ |
3545 | ret = file_permission(cfile, MAY_READ); | 3548 | /* AV: shouldn't we check that it's been opened for read instead? */ |
3549 | ret = inode_permission(cfile->f_path.dentry->d_inode, MAY_READ); | ||
3546 | if (ret < 0) | 3550 | if (ret < 0) |
3547 | goto fail; | 3551 | goto fail; |
3548 | 3552 | ||
@@ -4813,8 +4817,7 @@ unsigned short css_id(struct cgroup_subsys_state *css) | |||
4813 | * on this or this is under rcu_read_lock(). Once css->id is allocated, | 4817 | * on this or this is under rcu_read_lock(). Once css->id is allocated, |
4814 | * it's unchanged until freed. | 4818 | * it's unchanged until freed. |
4815 | */ | 4819 | */ |
4816 | cssid = rcu_dereference_check(css->id, | 4820 | cssid = rcu_dereference_check(css->id, atomic_read(&css->refcnt)); |
4817 | rcu_read_lock_held() || atomic_read(&css->refcnt)); | ||
4818 | 4821 | ||
4819 | if (cssid) | 4822 | if (cssid) |
4820 | return cssid->id; | 4823 | return cssid->id; |
@@ -4826,8 +4829,7 @@ unsigned short css_depth(struct cgroup_subsys_state *css) | |||
4826 | { | 4829 | { |
4827 | struct css_id *cssid; | 4830 | struct css_id *cssid; |
4828 | 4831 | ||
4829 | cssid = rcu_dereference_check(css->id, | 4832 | cssid = rcu_dereference_check(css->id, atomic_read(&css->refcnt)); |
4830 | rcu_read_lock_held() || atomic_read(&css->refcnt)); | ||
4831 | 4833 | ||
4832 | if (cssid) | 4834 | if (cssid) |
4833 | return cssid->depth; | 4835 | return cssid->depth; |