Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 139659
b: refs/heads/master
c: b4046f0
h: refs/heads/master
i:
  139657: b327cf9
  139655: dded368
v: v3
  • Loading branch information
Li Zefan authored and Linus Torvalds committed Apr 3, 2009
1 parent a1e9174 commit 9e3c017
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d969fbe69e07fcceb0558b35d4c75eb046041c5e
refs/heads/master: b4046f00ee7c1e5615261b496cf7309683275b29
21 changes: 13 additions & 8 deletions trunk/security/device_cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <linux/uaccess.h>
#include <linux/seq_file.h>
#include <linux/rcupdate.h>
#include <linux/mutex.h>

#define ACC_MKNOD 1
#define ACC_READ 2
Expand All @@ -21,9 +22,11 @@
#define DEV_CHAR 2
#define DEV_ALL 4 /* this represents all devices */

static DEFINE_MUTEX(devcgroup_mutex);

/*
* whitelist locking rules:
* hold cgroup_lock() for update/read.
* hold devcgroup_mutex for update/read.
* hold rcu_read_lock() for read.
*/

Expand Down Expand Up @@ -67,7 +70,7 @@ static int devcgroup_can_attach(struct cgroup_subsys *ss,
}

/*
* called under cgroup_lock()
* called under devcgroup_mutex
*/
static int dev_whitelist_copy(struct list_head *dest, struct list_head *orig)
{
Expand All @@ -92,7 +95,7 @@ static int dev_whitelist_copy(struct list_head *dest, struct list_head *orig)

/* Stupid prototype - don't bother combining existing entries */
/*
* called under cgroup_lock()
* called under devcgroup_mutex
*/
static int dev_whitelist_add(struct dev_cgroup *dev_cgroup,
struct dev_whitelist_item *wh)
Expand Down Expand Up @@ -130,7 +133,7 @@ static void whitelist_item_free(struct rcu_head *rcu)
}

/*
* called under cgroup_lock()
* called under devcgroup_mutex
*/
static void dev_whitelist_rm(struct dev_cgroup *dev_cgroup,
struct dev_whitelist_item *wh)
Expand Down Expand Up @@ -185,8 +188,10 @@ static struct cgroup_subsys_state *devcgroup_create(struct cgroup_subsys *ss,
list_add(&wh->list, &dev_cgroup->whitelist);
} else {
parent_dev_cgroup = cgroup_to_devcgroup(parent_cgroup);
mutex_lock(&devcgroup_mutex);
ret = dev_whitelist_copy(&dev_cgroup->whitelist,
&parent_dev_cgroup->whitelist);
mutex_unlock(&devcgroup_mutex);
if (ret) {
kfree(dev_cgroup);
return ERR_PTR(ret);
Expand Down Expand Up @@ -273,7 +278,7 @@ static int devcgroup_seq_read(struct cgroup *cgroup, struct cftype *cft,
* does the access granted to dev_cgroup c contain the access
* requested in whitelist item refwh.
* return 1 if yes, 0 if no.
* call with c->lock held
* call with devcgroup_mutex held
*/
static int may_access_whitelist(struct dev_cgroup *c,
struct dev_whitelist_item *refwh)
Expand Down Expand Up @@ -426,11 +431,11 @@ static int devcgroup_access_write(struct cgroup *cgrp, struct cftype *cft,
const char *buffer)
{
int retval;
if (!cgroup_lock_live_group(cgrp))
return -ENODEV;

mutex_lock(&devcgroup_mutex);
retval = devcgroup_update_access(cgroup_to_devcgroup(cgrp),
cft->private, buffer);
cgroup_unlock();
mutex_unlock(&devcgroup_mutex);
return retval;
}

Expand Down

0 comments on commit 9e3c017

Please sign in to comment.