public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] devscgroup: check for device permissions at mount time
@ 2008-06-05  8:40 Pavel Emelyanov
  2008-06-05 15:49 ` Serge E. Hallyn
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Emelyanov @ 2008-06-05  8:40 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Serge Hallyn, Linux Kernel Mailing List

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>

---
 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


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

end of thread, other threads:[~2008-06-05 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox