All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blkdev: cgroup whitelist permission fix
@ 2010-05-14  7:40 Chris Wright
  2010-05-18  4:45 ` Serge E. Hallyn
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Wright @ 2010-05-14  7:40 UTC (permalink / raw)
  To: Serge E. Hallyn, Christoph Hellwig; +Cc: Daniel P. Berrange, linux-kernel

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.  This simply
avoids the cgroup check for the whole disk case when opening a
partition.

https://bugzilla.redhat.com/show_bug.cgi?id=589662

Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
 fs/block_dev.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 6dcee88..d4d19ac 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1192,10 +1192,12 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
 	/*
 	 * hooks: /n/, see "layering violations".
 	 */
-	ret = devcgroup_inode_permission(bdev->bd_inode, perm);
-	if (ret != 0) {
-		bdput(bdev);
-		return ret;
+	if (!for_part) {
+		ret = devcgroup_inode_permission(bdev->bd_inode, perm);
+		if (ret != 0) {
+			bdput(bdev);
+			return ret;
+		}
 	}
 
 	lock_kernel();

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] blkdev: cgroup whitelist permission fix
  2010-05-14  7:40 Chris Wright
@ 2010-05-18  4:45 ` Serge E. Hallyn
  0 siblings, 0 replies; 5+ messages in thread
From: Serge E. Hallyn @ 2010-05-18  4:45 UTC (permalink / raw)
  To: Chris Wright; +Cc: Christoph Hellwig, Daniel P. Berrange, linux-kernel

Quoting Chris Wright (chrisw@sous-sol.org):
> 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.  This simply
> avoids the cgroup check for the whole disk case when opening a
> partition.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=589662
> 
> Signed-off-by: Chris Wright <chrisw@sous-sol.org>

Thanks, Chris, sorry for the delay.

Acked-by: Serge E. Hallyn <serue@us.ibm.com>
Tested-by: Serge E. Hallyn <serue@us.ibm.com>

> ---
>  fs/block_dev.c |   10 ++++++----
>  1 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 6dcee88..d4d19ac 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -1192,10 +1192,12 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
>  	/*
>  	 * hooks: /n/, see "layering violations".
>  	 */
> -	ret = devcgroup_inode_permission(bdev->bd_inode, perm);
> -	if (ret != 0) {
> -		bdput(bdev);
> -		return ret;
> +	if (!for_part) {
> +		ret = devcgroup_inode_permission(bdev->bd_inode, perm);
> +		if (ret != 0) {
> +			bdput(bdev);
> +			return ret;
> +		}
>  	}
> 
>  	lock_kernel();

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] blkdev: cgroup whitelist permission fix
@ 2010-06-04 20:15 Chris Wright
  2010-07-15 15:54 ` Chris Wright
  0 siblings, 1 reply; 5+ messages in thread
From: Chris Wright @ 2010-06-04 20:15 UTC (permalink / raw)
  To: Al Viro, Serge E. Hallyn, Christoph Hellwig
  Cc: Daniel P. Berrange, linux-kernel

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.  This simply
avoids the cgroup check for the whole disk case when opening a
partition.

https://bugzilla.redhat.com/show_bug.cgi?id=589662

Acked-by: Serge E. Hallyn <serue@us.ibm.com>
Tested-by: Serge E. Hallyn <serue@us.ibm.com>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
 fs/block_dev.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 7346c96..09b107e 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1315,10 +1315,12 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
 	/*
 	 * hooks: /n/, see "layering violations".
 	 */
-	ret = devcgroup_inode_permission(bdev->bd_inode, perm);
-	if (ret != 0) {
-		bdput(bdev);
-		return ret;
+	if (!for_part) {
+		ret = devcgroup_inode_permission(bdev->bd_inode, perm);
+		if (ret != 0) {
+			bdput(bdev);
+			return ret;
+		}
 	}
 
 	lock_kernel();

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] blkdev: cgroup whitelist permission fix
  2010-06-04 20:15 Chris Wright
@ 2010-07-15 15:54 ` Chris Wright
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Wright @ 2010-07-15 15:54 UTC (permalink / raw)
  To: Chris Wright
  Cc: Andrew Morton, Al Viro, Serge E. Hallyn, Christoph Hellwig,
	Daniel P. Berrange, linux-kernel

* Chris Wright (chrisw@sous-sol.org) wrote:
> 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.  This simply
> avoids the cgroup check for the whole disk case when opening a
> partition.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=589662
> 
> Acked-by: Serge E. Hallyn <serue@us.ibm.com>
> Tested-by: Serge E. Hallyn <serue@us.ibm.com>
> Signed-off-by: Chris Wright <chrisw@sous-sol.org>

Andrew, plans to push this on?  Christoph doesn't like the whole of
blockdev whitelisting for good reason, but it's currently in use and
has this bug.

thanks,
-chris

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] blkdev: cgroup whitelist permission fix
@ 2010-07-23  0:03 Chris Wright
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Wright @ 2010-07-23  0:03 UTC (permalink / raw)
  To: Andrew Morton, Al Viro, Serge E. Hallyn, Christoph Hellwig
  Cc: Daniel P. Berrange, linux-kernel

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.  This simply
avoids the cgroup check for the whole disk case when opening a
partition.  This bug describes the details.  

https://bugzilla.redhat.com/show_bug.cgi?id=589662

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.

Seems valid for 2.6.35 and -stable to me, as it's currently broken and
causes libvirt's container support to fail.

Acked-by: Serge E. Hallyn <serue@us.ibm.com>
Tested-by: Serge E. Hallyn <serue@us.ibm.com>
Cc: stable@kernel.org
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---
 fs/block_dev.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/block_dev.c b/fs/block_dev.c
index 7346c96..09b107e 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1315,10 +1315,12 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
 	/*
 	 * hooks: /n/, see "layering violations".
 	 */
-	ret = devcgroup_inode_permission(bdev->bd_inode, perm);
-	if (ret != 0) {
-		bdput(bdev);
-		return ret;
+	if (!for_part) {
+		ret = devcgroup_inode_permission(bdev->bd_inode, perm);
+		if (ret != 0) {
+			bdput(bdev);
+			return ret;
+		}
 	}
 
 	lock_kernel();

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-07-23  0:04 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-23  0:03 [PATCH] blkdev: cgroup whitelist permission fix Chris Wright
  -- strict thread matches above, loose matches on Subject: below --
2010-06-04 20:15 Chris Wright
2010-07-15 15:54 ` Chris Wright
2010-05-14  7:40 Chris Wright
2010-05-18  4:45 ` Serge E. Hallyn

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.