]> git.proxmox.com Git - mirror_ubuntu-eoan-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)
committerPaolo Pisati <paolo.pisati@canonical.com>
Mon, 16 Sep 2019 13:06:34 +0000 (15:06 +0200)
commit4bc428fdf5500b7366313f166b7c9c50ee43f2c4
treea632a45dae4c48ae3844886a17f2c1c48e4162f1
parent0c3fded3f844e2ff2eee6f504812796fd671377d
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