mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-07 04:09:21 +00:00
devscgroup: check for device permissions at mount time
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> Acked-by: Serge Hallyn <serue@us.ibm.com> Tested-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
cc9cb219aa
commit
7db9cfd380
1 changed files with 7 additions and 1 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <linux/kmod.h>
|
||||
#include <linux/major.h>
|
||||
#include <linux/smp_lock.h>
|
||||
#include <linux/device_cgroup.h>
|
||||
#include <linux/highmem.h>
|
||||
#include <linux/blkdev.h>
|
||||
#include <linux/module.h>
|
||||
|
@ -928,9 +929,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);
|
||||
|
|
Loading…
Reference in a new issue