aboutsummaryrefslogtreecommitdiffstats
path: root/fs/block_dev.c
diff options
context:
space:
mode:
authorChris Wright <chrisw@sous-sol.org>2010-08-10 21:02:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-11 11:59:18 -0400
commitb7300b78d1a87625975a799a109a2f98d77757c8 (patch)
tree8cf263c09daf725ee701b0acd7ad700c530a5f08 /fs/block_dev.c
parente400c28524af2d344b1663b27bf28984fa959a0e (diff)
blkdev: cgroup whitelist permission fix
The cgroup device whitelist code gets confused when trying to grant permission to a disk partition that is not currently open. Part of blkdev_open() includes __blkdev_get() on the whole disk. Basically, the only ways to reliably allow a cgroup access to a partition on a block device when using the whitelist are to 1) also give it access to the whole block device or 2) make sure the partition is already open in a different context. The patch avoids the cgroup check for the whole disk case when opening a partition. Addresses https://bugzilla.redhat.com/show_bug.cgi?id=589662 Signed-off-by: Chris Wright <chrisw@sous-sol.org> Acked-by: Serge E. Hallyn <serue@us.ibm.com> Tested-by: Serge E. Hallyn <serue@us.ibm.com> Reported-by: Vivek Goyal <vgoyal@redhat.com> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Christoph Hellwig <hch@infradead.org> Cc: "Daniel P. Berrange" <berrange@redhat.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/block_dev.c')
-rw-r--r--fs/block_dev.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 66411463b734..50e8c8582faa 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1340,10 +1340,12 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
1340 /* 1340 /*
1341 * hooks: /n/, see "layering violations". 1341 * hooks: /n/, see "layering violations".
1342 */ 1342 */
1343 ret = devcgroup_inode_permission(bdev->bd_inode, perm); 1343 if (!for_part) {
1344 if (ret != 0) { 1344 ret = devcgroup_inode_permission(bdev->bd_inode, perm);
1345 bdput(bdev); 1345 if (ret != 0) {
1346 return ret; 1346 bdput(bdev);
1347 return ret;
1348 }
1347 } 1349 }
1348 1350
1349 restart: 1351 restart: