From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Pavel Emelyanov <xemul@openvz.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Serge Hallyn <serue@us.ibm.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] devscgroup: check for device permissions at mount time
Date: Thu, 5 Jun 2008 10:49:57 -0500 [thread overview]
Message-ID: <20080605154956.GC11919@us.ibm.com> (raw)
In-Reply-To: <4847A67D.9060006@openvz.org>
Quoting Pavel Emelyanov (xemul@openvz.org):
> Currently even if a task sits in an all-denied cgroup it can still
> mount any block device in any mode it wants.
>
> Put a proper check in do_open for block device to prevent this.
>
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Crud. Tested and confirmed, and this patches fixes it.
Acked-by: Serge Hallyn <serue@us.ibm.com>
Tested-by: Serge Hallyn <serue@us.ibm.com>
thanks,
-serge
> ---
> fs/block_dev.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index a0e9596..7e1c7a3 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -24,6 +24,7 @@
> #include <linux/namei.h>
> #include <linux/log2.h>
> #include <linux/hardirq.h>
> +#include <linux/device_cgroup.h>
>
> #include <asm/uaccess.h>
> #include "internal.h"
> @@ -933,9 +934,14 @@ static int do_open(struct block_device *bdev, struct file *file, int for_part)
> {
> struct module *owner = NULL;
> struct gendisk *disk;
> - int ret = -ENXIO;
> + int ret;
> int part;
>
> + ret = devcgroup_inode_permission(bdev->bd_inode, file->f_mode);
> + if (ret != 0)
> + return ret;
> +
> + ret = -ENXIO;
> file->f_mapping = bdev->bd_inode->i_mapping;
> lock_kernel();
> disk = get_gendisk(bdev->bd_dev, &part);
> --
> 1.5.3.4
prev parent reply other threads:[~2008-06-05 17:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-05 8:40 [PATCH 1/2] devscgroup: check for device permissions at mount time Pavel Emelyanov
2008-06-05 15:49 ` Serge E. Hallyn [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080605154956.GC11919@us.ibm.com \
--to=serue@us.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=xemul@openvz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox