]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
UBUNTU: SAUCE: (namespace) block_dev: Check permissions towards block device inode...
authorSeth Forshee <seth.forshee@canonical.com>
Wed, 7 Oct 2015 19:49:47 +0000 (14:49 -0500)
committerPaolo Pisati <paolo.pisati@canonical.com>
Mon, 16 Sep 2019 13:06:34 +0000 (15:06 +0200)
Unprivileged users should not be able to mount block devices when
they lack sufficient privileges towards the block device inode.
Update blkdev_get_by_path() to validate that the user has the
required access to the inode at the specified path. The check
will be skipped for CAP_SYS_ADMIN, so privileged mounts will
continue working as before.

Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
fs/block_dev.c

index cb85e1a84663e19349a3a9a97719a7ea39448cf5..563038dd53a487c1769a33dcbe04b44afa90ec57 100644 (file)
@@ -1757,9 +1757,14 @@ struct block_device *blkdev_get_by_path(const char *path, fmode_t mode,
                                        void *holder)
 {
        struct block_device *bdev;
+       int perm = 0;
        int err;
 
-       bdev = lookup_bdev(path, 0);
+       if (mode & FMODE_READ)
+               perm |= MAY_READ;
+       if (mode & FMODE_WRITE)
+               perm |= MAY_WRITE;
+       bdev = lookup_bdev(path, perm);
        if (IS_ERR(bdev))
                return bdev;