Commit b7300b78 authored by Chris Wright's avatar Chris Wright Committed by Linus Torvalds

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=589662Signed-off-by: default avatarChris Wright <chrisw@sous-sol.org>
Acked-by: default avatarSerge E. Hallyn <serue@us.ibm.com>
Tested-by: default avatarSerge E. Hallyn <serue@us.ibm.com>
Reported-by: default avatarVivek 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: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e400c285
...@@ -1340,10 +1340,12 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) ...@@ -1340,10 +1340,12 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
/* /*
* hooks: /n/, see "layering violations". * hooks: /n/, see "layering violations".
*/ */
ret = devcgroup_inode_permission(bdev->bd_inode, perm); if (!for_part) {
if (ret != 0) { ret = devcgroup_inode_permission(bdev->bd_inode, perm);
bdput(bdev); if (ret != 0) {
return ret; bdput(bdev);
return ret;
}
} }
restart: restart:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment