]> git.baikalelectronics.ru Git - kernel.git/commit
inode: make init and permission helpers idmapped mount aware
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 21 Jan 2021 13:19:25 +0000 (14:19 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 24 Jan 2021 13:27:16 +0000 (14:27 +0100)
commitbc47f7b71021c03720ab5887c996b677662af1ed
tree986aa824a8b3aa45487b26364dbde88dbc853ff4
parent70a08194562d9dc12a4d8ea81dc6b99ff92ea947
inode: make init and permission helpers idmapped mount aware

The inode_owner_or_capable() helper determines whether the caller is the
owner of the inode or is capable with respect to that inode. Allow it to
handle idmapped mounts. If the inode is accessed through an idmapped
mount it according to the mount's user namespace. Afterwards the checks
are identical to non-idmapped mounts. If the initial user namespace is
passed nothing changes so non-idmapped mounts will see identical
behavior as before.

Similarly, allow the inode_init_owner() helper to handle idmapped
mounts. It initializes a new inode on idmapped mounts by mapping the
fsuid and fsgid of the caller from the mount's user namespace. 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-7-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>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
54 files changed:
fs/9p/acl.c
fs/9p/vfs_inode.c
fs/attr.c
fs/bfs/dir.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/tests/btrfs-tests.c
fs/crypto/policy.c
fs/efivarfs/file.c
fs/ext2/ialloc.c
fs/ext2/ioctl.c
fs/ext4/ialloc.c
fs/ext4/ioctl.c
fs/f2fs/file.c
fs/f2fs/namei.c
fs/f2fs/xattr.c
fs/fcntl.c
fs/gfs2/file.c
fs/hfsplus/inode.c
fs/hfsplus/ioctl.c
fs/hugetlbfs/inode.c
fs/inode.c
fs/jfs/ioctl.c
fs/jfs/jfs_inode.c
fs/minix/bitmap.c
fs/namei.c
fs/nilfs2/inode.c
fs/nilfs2/ioctl.c
fs/ocfs2/dlmfs/dlmfs.c
fs/ocfs2/ioctl.c
fs/ocfs2/namei.c
fs/omfs/inode.c
fs/overlayfs/dir.c
fs/overlayfs/file.c
fs/overlayfs/super.c
fs/overlayfs/util.c
fs/posix_acl.c
fs/ramfs/inode.c
fs/reiserfs/ioctl.c
fs/reiserfs/namei.c
fs/sysv/ialloc.c
fs/ubifs/dir.c
fs/ubifs/ioctl.c
fs/udf/ialloc.c
fs/ufs/ialloc.c
fs/xattr.c
fs/xfs/xfs_ioctl.c
fs/zonefs/super.c
include/linux/fs.h
kernel/bpf/inode.c
mm/madvise.c
mm/mincore.c
mm/shmem.c
security/selinux/hooks.c