namei: make permission helpers idmapped mount aware
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 21 Jan 2021 13:19:24 +0000 (14:19 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 24 Jan 2021 13:27:16 +0000 (14:27 +0100)
commit47291baa8ddfdae10663624ff0a15ab165952708
tree132a9486b82c5eada1c4b375f693522f0a04d629
parent0558c1bf5a0811bf5e3753eed911a15b9bd08271
namei: make permission helpers idmapped mount aware

The two helpers inode_permission() and generic_permission() are used by
the vfs to perform basic permission checking by verifying that the
caller is privileged over an inode. In order to handle idmapped mounts
we extend the two helpers with an additional user namespace argument.
On idmapped mounts the two helpers will make sure to map the inode
according to the mount's user namespace and then peform identical
permission checks to inode_permission() and generic_permission(). If the
initial user namespace is passed nothing changes so non-idmapped mounts
will see identical behavior as before.

Link: https://lore.kernel.org/r/20210121131959.646623-6-christian.brauner@ubuntu.com
Cc: Christoph Hellwig <hch@lst.de>
Cc: David Howells <dhowells@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: James Morris <jamorris@linux.microsoft.com>
Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
36 files changed:
fs/attr.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/ceph/inode.c
fs/cifs/cifsfs.c
fs/configfs/symlink.c
fs/ecryptfs/inode.c
fs/exec.c
fs/fuse/dir.c
fs/gfs2/inode.c
fs/hostfs/hostfs_kern.c
fs/kernfs/inode.c
fs/libfs.c
fs/namei.c
fs/nfs/dir.c
fs/nfsd/nfsfh.c
fs/nfsd/vfs.c
fs/nilfs2/inode.c
fs/ocfs2/file.c
fs/ocfs2/refcounttree.c
fs/open.c
fs/orangefs/inode.c
fs/overlayfs/file.c
fs/overlayfs/inode.c
fs/overlayfs/util.c
fs/posix_acl.c
fs/proc/base.c
fs/proc/fd.c
fs/reiserfs/xattr.c
fs/remap_range.c
fs/xattr.c
include/linux/fs.h
include/linux/posix_acl.h
ipc/mqueue.c
kernel/bpf/inode.c
kernel/cgroup/cgroup.c