Skip to contentSkip to conversation

devcgroup: fix permission check when adding entry to child cgroup

PATCH In review Li Zefan 2 participants 2 messages Jul 5, 2008 – Jul 7, 2008 Security (LSM)

lore
Share & tools
lore

Li Zefan

author
#0 lore raw

PATCH 2/2 devcgroup: fix permission check when adding entry to child cgroup

 # cat devices.list
 c 1:3 r
 # echo 'c 1:3 w' > sub/devices.allow
 # cat sub/devices.list
 c 1:3 w

As illustrated, the parent group has no write permission to /dev/null, so its child should not be allowed to add this write permission, which is documented in Documentation/controllers/devices.txt.

---
 security/device_cgroup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
security/device_cgroup.c +1 -1
index 1e2e28a..ddd92ce 100644
@@ -300,7 +300,7 @@ static int may_access_whitelist(struct dev_cgroup *c,
 			continue;
 		if (whitem->minor != ~0 && whitem->minor != refwh->minor)
 			continue;
-		if (refwh->access & (~(whitem->access | ACC_MASK)))
+		if (refwh->access & (~whitem->access))
 			continue;
 		return 1;
 	}
Signature · 1 line
1.5.4.rc3
Acked-by on v1 2/2
#1 lore raw
Quoted 11 lines · Li Zefan
 # cat devices.list
 c 1:3 r
 # echo 'c 1:3 w' > sub/devices.allow
 # cat sub/devices.list
 c 1:3 w

As illustrated, the parent group has no write permission to /dev/null, so its child should not be allowed to add this write permission, which is documented in Documentation/controllers/devices.txt.

I have no idea where that came from (but see that it was in my original submission). Maybe I meant to do &, but that still isn't necessary.

thanks,
-serge

Quoted 19 lines
---
 security/device_cgroup.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
security/device_cgroup.c +1 -1
index 1e2e28a..ddd92ce 100644
@@ -300,7 +300,7 @@ static int may_access_whitelist(struct dev_cgroup *c,
 			continue;
 		if (whitem->minor != ~0 && whitem->minor != refwh->minor)
 			continue;
-		if (refwh->access & (~(whitem->access | ACC_MASK)))
+		if (refwh->access & (~whitem->access))
 			continue;
 		return 1;
 	}
Signature · 1 line
1.5.4.rc3