]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commit
UBUNTU: SAUCE: (namespace) block_dev: Forbid unprivileged mounting when device is...
authorSeth Forshee <seth.forshee@canonical.com>
Mon, 19 Sep 2016 20:46:26 +0000 (15:46 -0500)
committerTim Gardner <tim.gardner@canonical.com>
Mon, 20 Feb 2017 03:57:58 +0000 (20:57 -0700)
commitd87f617d3b96fc6adfe9871270cbc3869fd1e4fe
treea8f3e143cac7797b1f2d71cccf43ade61e2c3173
parent73eb7eae956c8cb190960e13e5cf07354f4e5031
UBUNTU: SAUCE: (namespace) block_dev: Forbid unprivileged mounting when device is opened for writing

For unprivileged mounts to be safe the user must not be able to
make changes to the backing store while it is mounted. This patch
takes a step towards preventing this by refusing to mount in a
user namepspace if the block device is open for writing and
refusing attempts to open the block device for writing by non-
root while it is mounted in a user namespace.

To prevent this from happening we use i_writecount in the inodes
of the bdev filesystem similarly to how it is used for regular
files. Whenever the device is opened for writing i_writecount
is checked; if it is negative the open returns -EBUSY, otherwise
i_writecount is incremented. On mount, a positive i_writecount
results in mount_bdev returning -EBUSY, otherwise i_writecount
is decremented. Opens by root and mounts from init_user_ns do not
check nor modify i_writecount.

Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
fs/block_dev.c
fs/super.c