]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
fs: require CAP_SYS_ADMIN in target namespace for idmapped mounts
authorSeth Forshee <sforshee@digitalocean.com>
Tue, 16 Aug 2022 16:47:52 +0000 (11:47 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 31 Aug 2022 15:18:01 +0000 (17:18 +0200)
commit9a852bcf90fbe631f87d1d17fa99c58ee53bb92e
tree05467b05555c9a9aa022c29a3af7d337929fb4cc
parente26d676c1f9f335510780b566a10475c47ce03d0
fs: require CAP_SYS_ADMIN in target namespace for idmapped mounts

[ Upstream commit bf1ac16edf6770a92bc75cf2373f1f9feea398a4 ]

Idmapped mounts should not allow a user to map file ownsership into a
range of ids which is not under the control of that user. However, we
currently don't check whether the mounter is privileged wrt to the
target user namespace.

Currently no FS_USERNS_MOUNT filesystems support idmapped mounts, thus
this is not a problem as only CAP_SYS_ADMIN in init_user_ns is allowed
to set up idmapped mounts. But this could change in the future, so add a
check to refuse to create idmapped mounts when the mounter does not have
CAP_SYS_ADMIN in the target user namespace.

Fixes: bd303368b776 ("fs: support mapped mounts of mapped filesystems")
Signed-off-by: Seth Forshee <sforshee@digitalocean.com>
Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Link: https://lore.kernel.org/r/20220816164752.2595240-1-sforshee@digitalocean.com
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/namespace.c