Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fs: port xattr to mnt_idmap

Convert to struct mnt_idmap.

Last cycle we merged the necessary infrastructure in
256c8aed2b42 ("fs: introduce dedicated idmap type for mounts").
This is just the conversion to struct mnt_idmap.

Currently we still pass around the plain namespace that was attached to a
mount. This is in general pretty convenient but it makes it easy to
conflate namespaces that are relevant on the filesystem with namespaces
that are relevent on the mount level. Especially for non-vfs developers
without detailed knowledge in this area this can be a potential source for
bugs.

Once the conversion to struct mnt_idmap is done all helpers down to the
really low-level helpers will take a struct mnt_idmap argument instead of
two namespace arguments. This way it becomes impossible to conflate the two
eliminating the possibility of any bugs. All of the vfs and all filesystems
only operate on struct mnt_idmap.

Acked-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>

+203 -204
+1 -1
Documentation/filesystems/locking.rst
··· 135 135 struct inode *inode, const char *name, void *buffer, 136 136 size_t size); 137 137 int (*set)(const struct xattr_handler *handler, 138 - struct user_namespace *mnt_userns, 138 + struct mnt_idmap *idmap, 139 139 struct dentry *dentry, struct inode *inode, const char *name, 140 140 const void *buffer, size_t size, int flags); 141 141
+1 -1
fs/9p/xattr.c
··· 150 150 } 151 151 152 152 static int v9fs_xattr_handler_set(const struct xattr_handler *handler, 153 - struct user_namespace *mnt_userns, 153 + struct mnt_idmap *idmap, 154 154 struct dentry *dentry, struct inode *inode, 155 155 const char *name, const void *value, 156 156 size_t size, int flags)
+2 -2
fs/afs/xattr.c
··· 97 97 * Set a file's AFS3 ACL. 98 98 */ 99 99 static int afs_xattr_set_acl(const struct xattr_handler *handler, 100 - struct user_namespace *mnt_userns, 100 + struct mnt_idmap *idmap, 101 101 struct dentry *dentry, 102 102 struct inode *inode, const char *name, 103 103 const void *buffer, size_t size, int flags) ··· 228 228 * Set a file's YFS ACL. 229 229 */ 230 230 static int afs_xattr_set_yfs(const struct xattr_handler *handler, 231 - struct user_namespace *mnt_userns, 231 + struct mnt_idmap *idmap, 232 232 struct dentry *dentry, 233 233 struct inode *inode, const char *name, 234 234 const void *buffer, size_t size, int flags)
+2 -2
fs/attr.c
··· 220 220 if (ia_valid & ATTR_KILL_PRIV) { 221 221 int error; 222 222 223 - error = security_inode_killpriv(mnt_userns, dentry); 223 + error = security_inode_killpriv(idmap, dentry); 224 224 if (error) 225 225 return error; 226 226 } ··· 489 489 490 490 if (!error) { 491 491 fsnotify_change(dentry, ia_valid); 492 - ima_inode_post_setattr(mnt_userns, dentry); 492 + ima_inode_post_setattr(idmap, dentry); 493 493 evm_inode_post_setattr(dentry, ia_valid); 494 494 } 495 495
+2 -2
fs/btrfs/xattr.c
··· 370 370 } 371 371 372 372 static int btrfs_xattr_handler_set(const struct xattr_handler *handler, 373 - struct user_namespace *mnt_userns, 373 + struct mnt_idmap *idmap, 374 374 struct dentry *unused, struct inode *inode, 375 375 const char *name, const void *buffer, 376 376 size_t size, int flags) ··· 383 383 } 384 384 385 385 static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler, 386 - struct user_namespace *mnt_userns, 386 + struct mnt_idmap *idmap, 387 387 struct dentry *unused, struct inode *inode, 388 388 const char *name, const void *value, 389 389 size_t size, int flags)
+1 -1
fs/ceph/xattr.c
··· 1285 1285 } 1286 1286 1287 1287 static int ceph_set_xattr_handler(const struct xattr_handler *handler, 1288 - struct user_namespace *mnt_userns, 1288 + struct mnt_idmap *idmap, 1289 1289 struct dentry *unused, struct inode *inode, 1290 1290 const char *name, const void *value, 1291 1291 size_t size, int flags)
+1 -1
fs/cifs/xattr.c
··· 89 89 } 90 90 91 91 static int cifs_xattr_set(const struct xattr_handler *handler, 92 - struct user_namespace *mnt_userns, 92 + struct mnt_idmap *idmap, 93 93 struct dentry *dentry, struct inode *inode, 94 94 const char *name, const void *value, 95 95 size_t size, int flags)
+1 -1
fs/ecryptfs/crypto.c
··· 1105 1105 } 1106 1106 1107 1107 inode_lock(lower_inode); 1108 - rc = __vfs_setxattr(&init_user_ns, lower_dentry, lower_inode, 1108 + rc = __vfs_setxattr(&nop_mnt_idmap, lower_dentry, lower_inode, 1109 1109 ECRYPTFS_XATTR_NAME, page_virt, size, 0); 1110 1110 if (!rc && ecryptfs_inode) 1111 1111 fsstack_copy_attr_all(ecryptfs_inode, lower_inode);
+2 -2
fs/ecryptfs/inode.c
··· 1099 1099 goto out; 1100 1100 } 1101 1101 inode_lock(lower_inode); 1102 - rc = __vfs_removexattr(&init_user_ns, lower_dentry, name); 1102 + rc = __vfs_removexattr(&nop_mnt_idmap, lower_dentry, name); 1103 1103 inode_unlock(lower_inode); 1104 1104 out: 1105 1105 return rc; ··· 1190 1190 } 1191 1191 1192 1192 static int ecryptfs_xattr_set(const struct xattr_handler *handler, 1193 - struct user_namespace *mnt_userns, 1193 + struct mnt_idmap *idmap, 1194 1194 struct dentry *dentry, struct inode *inode, 1195 1195 const char *name, const void *value, size_t size, 1196 1196 int flags)
+1 -1
fs/ecryptfs/mmap.c
··· 428 428 if (size < 0) 429 429 size = 8; 430 430 put_unaligned_be64(i_size_read(ecryptfs_inode), xattr_virt); 431 - rc = __vfs_setxattr(&init_user_ns, lower_dentry, lower_inode, 431 + rc = __vfs_setxattr(&nop_mnt_idmap, lower_dentry, lower_inode, 432 432 ECRYPTFS_XATTR_NAME, xattr_virt, size, 0); 433 433 inode_unlock(lower_inode); 434 434 if (rc)
+1 -1
fs/ext2/xattr_security.c
··· 19 19 20 20 static int 21 21 ext2_xattr_security_set(const struct xattr_handler *handler, 22 - struct user_namespace *mnt_userns, 22 + struct mnt_idmap *idmap, 23 23 struct dentry *unused, struct inode *inode, 24 24 const char *name, const void *value, 25 25 size_t size, int flags)
+1 -1
fs/ext2/xattr_trusted.c
··· 26 26 27 27 static int 28 28 ext2_xattr_trusted_set(const struct xattr_handler *handler, 29 - struct user_namespace *mnt_userns, 29 + struct mnt_idmap *idmap, 30 30 struct dentry *unused, struct inode *inode, 31 31 const char *name, const void *value, 32 32 size_t size, int flags)
+1 -1
fs/ext2/xattr_user.c
··· 30 30 31 31 static int 32 32 ext2_xattr_user_set(const struct xattr_handler *handler, 33 - struct user_namespace *mnt_userns, 33 + struct mnt_idmap *idmap, 34 34 struct dentry *unused, struct inode *inode, 35 35 const char *name, const void *value, 36 36 size_t size, int flags)
+1 -1
fs/ext4/xattr_hurd.c
··· 32 32 33 33 static int 34 34 ext4_xattr_hurd_set(const struct xattr_handler *handler, 35 - struct user_namespace *mnt_userns, 35 + struct mnt_idmap *idmap, 36 36 struct dentry *unused, struct inode *inode, 37 37 const char *name, const void *value, 38 38 size_t size, int flags)
+1 -1
fs/ext4/xattr_security.c
··· 23 23 24 24 static int 25 25 ext4_xattr_security_set(const struct xattr_handler *handler, 26 - struct user_namespace *mnt_userns, 26 + struct mnt_idmap *idmap, 27 27 struct dentry *unused, struct inode *inode, 28 28 const char *name, const void *value, 29 29 size_t size, int flags)
+1 -1
fs/ext4/xattr_trusted.c
··· 30 30 31 31 static int 32 32 ext4_xattr_trusted_set(const struct xattr_handler *handler, 33 - struct user_namespace *mnt_userns, 33 + struct mnt_idmap *idmap, 34 34 struct dentry *unused, struct inode *inode, 35 35 const char *name, const void *value, 36 36 size_t size, int flags)
+1 -1
fs/ext4/xattr_user.c
··· 31 31 32 32 static int 33 33 ext4_xattr_user_set(const struct xattr_handler *handler, 34 - struct user_namespace *mnt_userns, 34 + struct mnt_idmap *idmap, 35 35 struct dentry *unused, struct inode *inode, 36 36 const char *name, const void *value, 37 37 size_t size, int flags)
+2 -2
fs/f2fs/xattr.c
··· 65 65 } 66 66 67 67 static int f2fs_xattr_generic_set(const struct xattr_handler *handler, 68 - struct user_namespace *mnt_userns, 68 + struct mnt_idmap *idmap, 69 69 struct dentry *unused, struct inode *inode, 70 70 const char *name, const void *value, 71 71 size_t size, int flags) ··· 109 109 } 110 110 111 111 static int f2fs_xattr_advise_set(const struct xattr_handler *handler, 112 - struct user_namespace *mnt_userns, 112 + struct mnt_idmap *idmap, 113 113 struct dentry *unused, struct inode *inode, 114 114 const char *name, const void *value, 115 115 size_t size, int flags)
+2 -2
fs/fuse/xattr.c
··· 189 189 } 190 190 191 191 static int fuse_xattr_set(const struct xattr_handler *handler, 192 - struct user_namespace *mnt_userns, 192 + struct mnt_idmap *idmap, 193 193 struct dentry *dentry, struct inode *inode, 194 194 const char *name, const void *value, size_t size, 195 195 int flags) ··· 216 216 } 217 217 218 218 static int no_xattr_set(const struct xattr_handler *handler, 219 - struct user_namespace *mnt_userns, 219 + struct mnt_idmap *idmap, 220 220 struct dentry *dentry, struct inode *nodee, 221 221 const char *name, const void *value, 222 222 size_t size, int flags)
+1 -1
fs/gfs2/xattr.c
··· 1225 1225 } 1226 1226 1227 1227 static int gfs2_xattr_set(const struct xattr_handler *handler, 1228 - struct user_namespace *mnt_userns, 1228 + struct mnt_idmap *idmap, 1229 1229 struct dentry *unused, struct inode *inode, 1230 1230 const char *name, const void *value, 1231 1231 size_t size, int flags)
+1 -1
fs/hfs/attr.c
··· 121 121 } 122 122 123 123 static int hfs_xattr_set(const struct xattr_handler *handler, 124 - struct user_namespace *mnt_userns, 124 + struct mnt_idmap *idmap, 125 125 struct dentry *unused, struct inode *inode, 126 126 const char *name, const void *value, size_t size, 127 127 int flags)
+1 -1
fs/hfsplus/xattr.c
··· 857 857 } 858 858 859 859 static int hfsplus_osx_setxattr(const struct xattr_handler *handler, 860 - struct user_namespace *mnt_userns, 860 + struct mnt_idmap *idmap, 861 861 struct dentry *unused, struct inode *inode, 862 862 const char *name, const void *buffer, 863 863 size_t size, int flags)
+1 -1
fs/hfsplus/xattr_security.c
··· 23 23 } 24 24 25 25 static int hfsplus_security_setxattr(const struct xattr_handler *handler, 26 - struct user_namespace *mnt_userns, 26 + struct mnt_idmap *idmap, 27 27 struct dentry *unused, struct inode *inode, 28 28 const char *name, const void *buffer, 29 29 size_t size, int flags)
+1 -1
fs/hfsplus/xattr_trusted.c
··· 22 22 } 23 23 24 24 static int hfsplus_trusted_setxattr(const struct xattr_handler *handler, 25 - struct user_namespace *mnt_userns, 25 + struct mnt_idmap *idmap, 26 26 struct dentry *unused, struct inode *inode, 27 27 const char *name, const void *buffer, 28 28 size_t size, int flags)
+1 -1
fs/hfsplus/xattr_user.c
··· 22 22 } 23 23 24 24 static int hfsplus_user_setxattr(const struct xattr_handler *handler, 25 - struct user_namespace *mnt_userns, 25 + struct mnt_idmap *idmap, 26 26 struct dentry *unused, struct inode *inode, 27 27 const char *name, const void *buffer, 28 28 size_t size, int flags)
+1 -1
fs/jffs2/security.c
··· 57 57 } 58 58 59 59 static int jffs2_security_setxattr(const struct xattr_handler *handler, 60 - struct user_namespace *mnt_userns, 60 + struct mnt_idmap *idmap, 61 61 struct dentry *unused, struct inode *inode, 62 62 const char *name, const void *buffer, 63 63 size_t size, int flags)
+1 -1
fs/jffs2/xattr_trusted.c
··· 25 25 } 26 26 27 27 static int jffs2_trusted_setxattr(const struct xattr_handler *handler, 28 - struct user_namespace *mnt_userns, 28 + struct mnt_idmap *idmap, 29 29 struct dentry *unused, struct inode *inode, 30 30 const char *name, const void *buffer, 31 31 size_t size, int flags)
+1 -1
fs/jffs2/xattr_user.c
··· 25 25 } 26 26 27 27 static int jffs2_user_setxattr(const struct xattr_handler *handler, 28 - struct user_namespace *mnt_userns, 28 + struct mnt_idmap *idmap, 29 29 struct dentry *unused, struct inode *inode, 30 30 const char *name, const void *buffer, 31 31 size_t size, int flags)
+2 -2
fs/jfs/xattr.c
··· 932 932 } 933 933 934 934 static int jfs_xattr_set(const struct xattr_handler *handler, 935 - struct user_namespace *mnt_userns, 935 + struct mnt_idmap *idmap, 936 936 struct dentry *unused, struct inode *inode, 937 937 const char *name, const void *value, 938 938 size_t size, int flags) ··· 951 951 } 952 952 953 953 static int jfs_xattr_set_os2(const struct xattr_handler *handler, 954 - struct user_namespace *mnt_userns, 954 + struct mnt_idmap *idmap, 955 955 struct dentry *unused, struct inode *inode, 956 956 const char *name, const void *value, 957 957 size_t size, int flags)
+2 -2
fs/kernfs/inode.c
··· 324 324 } 325 325 326 326 static int kernfs_vfs_xattr_set(const struct xattr_handler *handler, 327 - struct user_namespace *mnt_userns, 327 + struct mnt_idmap *idmap, 328 328 struct dentry *unused, struct inode *inode, 329 329 const char *suffix, const void *value, 330 330 size_t size, int flags) ··· 391 391 } 392 392 393 393 static int kernfs_vfs_user_xattr_set(const struct xattr_handler *handler, 394 - struct user_namespace *mnt_userns, 394 + struct mnt_idmap *idmap, 395 395 struct dentry *unused, struct inode *inode, 396 396 const char *suffix, const void *value, 397 397 size_t size, int flags)
+2 -4
fs/namei.c
··· 3633 3633 inode->i_state |= I_LINKABLE; 3634 3634 spin_unlock(&inode->i_lock); 3635 3635 } 3636 - ima_post_create_tmpfile(mnt_userns, inode); 3636 + ima_post_create_tmpfile(idmap, inode); 3637 3637 return 0; 3638 3638 } 3639 3639 ··· 3953 3953 unsigned int dev) 3954 3954 { 3955 3955 struct mnt_idmap *idmap; 3956 - struct user_namespace *mnt_userns; 3957 3956 struct dentry *dentry; 3958 3957 struct path path; 3959 3958 int error; ··· 3973 3974 goto out2; 3974 3975 3975 3976 idmap = mnt_idmap(path.mnt); 3976 - mnt_userns = mnt_idmap_owner(idmap); 3977 3977 switch (mode & S_IFMT) { 3978 3978 case 0: case S_IFREG: 3979 3979 error = vfs_create(idmap, path.dentry->d_inode, 3980 3980 dentry, mode, true); 3981 3981 if (!error) 3982 - ima_post_path_mknod(mnt_userns, dentry); 3982 + ima_post_path_mknod(idmap, dentry); 3983 3983 break; 3984 3984 case S_IFCHR: case S_IFBLK: 3985 3985 error = vfs_mknod(idmap, path.dentry->d_inode,
+5 -5
fs/nfs/nfs4proc.c
··· 7692 7692 #define XATTR_NAME_NFSV4_ACL "system.nfs4_acl" 7693 7693 7694 7694 static int nfs4_xattr_set_nfs4_acl(const struct xattr_handler *handler, 7695 - struct user_namespace *mnt_userns, 7695 + struct mnt_idmap *idmap, 7696 7696 struct dentry *unused, struct inode *inode, 7697 7697 const char *key, const void *buf, 7698 7698 size_t buflen, int flags) ··· 7716 7716 #define XATTR_NAME_NFSV4_DACL "system.nfs4_dacl" 7717 7717 7718 7718 static int nfs4_xattr_set_nfs4_dacl(const struct xattr_handler *handler, 7719 - struct user_namespace *mnt_userns, 7719 + struct mnt_idmap *idmap, 7720 7720 struct dentry *unused, struct inode *inode, 7721 7721 const char *key, const void *buf, 7722 7722 size_t buflen, int flags) ··· 7739 7739 #define XATTR_NAME_NFSV4_SACL "system.nfs4_sacl" 7740 7740 7741 7741 static int nfs4_xattr_set_nfs4_sacl(const struct xattr_handler *handler, 7742 - struct user_namespace *mnt_userns, 7742 + struct mnt_idmap *idmap, 7743 7743 struct dentry *unused, struct inode *inode, 7744 7744 const char *key, const void *buf, 7745 7745 size_t buflen, int flags) ··· 7764 7764 #ifdef CONFIG_NFS_V4_SECURITY_LABEL 7765 7765 7766 7766 static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler, 7767 - struct user_namespace *mnt_userns, 7767 + struct mnt_idmap *idmap, 7768 7768 struct dentry *unused, struct inode *inode, 7769 7769 const char *key, const void *buf, 7770 7770 size_t buflen, int flags) ··· 7815 7815 7816 7816 #ifdef CONFIG_NFS_V4_2 7817 7817 static int nfs4_xattr_set_nfs4_user(const struct xattr_handler *handler, 7818 - struct user_namespace *mnt_userns, 7818 + struct mnt_idmap *idmap, 7819 7819 struct dentry *unused, struct inode *inode, 7820 7820 const char *key, const void *buf, 7821 7821 size_t buflen, int flags)
+1 -1
fs/ntfs3/xattr.c
··· 837 837 * ntfs_setxattr - inode_operations::setxattr 838 838 */ 839 839 static noinline int ntfs_setxattr(const struct xattr_handler *handler, 840 - struct user_namespace *mnt_userns, 840 + struct mnt_idmap *idmap, 841 841 struct dentry *de, struct inode *inode, 842 842 const char *name, const void *value, 843 843 size_t size, int flags)
+3 -3
fs/ocfs2/xattr.c
··· 7247 7247 } 7248 7248 7249 7249 static int ocfs2_xattr_security_set(const struct xattr_handler *handler, 7250 - struct user_namespace *mnt_userns, 7250 + struct mnt_idmap *idmap, 7251 7251 struct dentry *unused, struct inode *inode, 7252 7252 const char *name, const void *value, 7253 7253 size_t size, int flags) ··· 7320 7320 } 7321 7321 7322 7322 static int ocfs2_xattr_trusted_set(const struct xattr_handler *handler, 7323 - struct user_namespace *mnt_userns, 7323 + struct mnt_idmap *idmap, 7324 7324 struct dentry *unused, struct inode *inode, 7325 7325 const char *name, const void *value, 7326 7326 size_t size, int flags) ··· 7351 7351 } 7352 7352 7353 7353 static int ocfs2_xattr_user_set(const struct xattr_handler *handler, 7354 - struct user_namespace *mnt_userns, 7354 + struct mnt_idmap *idmap, 7355 7355 struct dentry *unused, struct inode *inode, 7356 7356 const char *name, const void *value, 7357 7357 size_t size, int flags)
+1 -1
fs/orangefs/xattr.c
··· 526 526 } 527 527 528 528 static int orangefs_xattr_set_default(const struct xattr_handler *handler, 529 - struct user_namespace *mnt_userns, 529 + struct mnt_idmap *idmap, 530 530 struct dentry *unused, 531 531 struct inode *inode, 532 532 const char *name,
+2 -2
fs/overlayfs/super.c
··· 1012 1012 } 1013 1013 1014 1014 static int ovl_own_xattr_set(const struct xattr_handler *handler, 1015 - struct user_namespace *mnt_userns, 1015 + struct mnt_idmap *idmap, 1016 1016 struct dentry *dentry, struct inode *inode, 1017 1017 const char *name, const void *value, 1018 1018 size_t size, int flags) ··· 1028 1028 } 1029 1029 1030 1030 static int ovl_other_xattr_set(const struct xattr_handler *handler, 1031 - struct user_namespace *mnt_userns, 1031 + struct mnt_idmap *idmap, 1032 1032 struct dentry *dentry, struct inode *inode, 1033 1033 const char *name, const void *value, 1034 1034 size_t size, int flags)
+1 -1
fs/reiserfs/xattr_security.c
··· 22 22 23 23 static int 24 24 security_set(const struct xattr_handler *handler, 25 - struct user_namespace *mnt_userns, struct dentry *unused, 25 + struct mnt_idmap *idmap, struct dentry *unused, 26 26 struct inode *inode, const char *name, const void *buffer, 27 27 size_t size, int flags) 28 28 {
+1 -1
fs/reiserfs/xattr_trusted.c
··· 21 21 22 22 static int 23 23 trusted_set(const struct xattr_handler *handler, 24 - struct user_namespace *mnt_userns, struct dentry *unused, 24 + struct mnt_idmap *idmap, struct dentry *unused, 25 25 struct inode *inode, const char *name, const void *buffer, 26 26 size_t size, int flags) 27 27 {
+1 -1
fs/reiserfs/xattr_user.c
··· 18 18 } 19 19 20 20 static int 21 - user_set(const struct xattr_handler *handler, struct user_namespace *mnt_userns, 21 + user_set(const struct xattr_handler *handler, struct mnt_idmap *idmap, 22 22 struct dentry *unused, 23 23 struct inode *inode, const char *name, const void *buffer, 24 24 size_t size, int flags)
+1 -1
fs/ubifs/xattr.c
··· 699 699 } 700 700 701 701 static int xattr_set(const struct xattr_handler *handler, 702 - struct user_namespace *mnt_userns, 702 + struct mnt_idmap *idmap, 703 703 struct dentry *dentry, struct inode *inode, 704 704 const char *name, const void *value, 705 705 size_t size, int flags)
+12 -15
fs/xattr.c
··· 185 185 EXPORT_SYMBOL(xattr_supported_namespace); 186 186 187 187 int 188 - __vfs_setxattr(struct user_namespace *mnt_userns, struct dentry *dentry, 188 + __vfs_setxattr(struct mnt_idmap *idmap, struct dentry *dentry, 189 189 struct inode *inode, const char *name, const void *value, 190 190 size_t size, int flags) 191 191 { ··· 201 201 return -EOPNOTSUPP; 202 202 if (size == 0) 203 203 value = ""; /* empty EA, do not remove */ 204 - return handler->set(handler, mnt_userns, dentry, inode, name, value, 204 + return handler->set(handler, idmap, dentry, inode, name, value, 205 205 size, flags); 206 206 } 207 207 EXPORT_SYMBOL(__vfs_setxattr); ··· 210 210 * __vfs_setxattr_noperm - perform setxattr operation without performing 211 211 * permission checks. 212 212 * 213 - * @mnt_userns: user namespace of the mount the inode was found from 213 + * @idmap: idmap of the mount the inode was found from 214 214 * @dentry: object to perform setxattr on 215 215 * @name: xattr name to set 216 216 * @value: value to set @name to ··· 223 223 * is executed. It also assumes that the caller will make the appropriate 224 224 * permission checks. 225 225 */ 226 - int __vfs_setxattr_noperm(struct user_namespace *mnt_userns, 226 + int __vfs_setxattr_noperm(struct mnt_idmap *idmap, 227 227 struct dentry *dentry, const char *name, 228 228 const void *value, size_t size, int flags) 229 229 { ··· 235 235 if (issec) 236 236 inode->i_flags &= ~S_NOSEC; 237 237 if (inode->i_opflags & IOP_XATTR) { 238 - error = __vfs_setxattr(mnt_userns, dentry, inode, name, value, 238 + error = __vfs_setxattr(idmap, dentry, inode, name, value, 239 239 size, flags); 240 240 if (!error) { 241 241 fsnotify_xattr(dentry); ··· 280 280 const char *name, const void *value, size_t size, 281 281 int flags, struct inode **delegated_inode) 282 282 { 283 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 284 283 struct inode *inode = dentry->d_inode; 285 284 int error; 286 285 ··· 287 288 if (error) 288 289 return error; 289 290 290 - error = security_inode_setxattr(mnt_userns, dentry, name, value, size, 291 + error = security_inode_setxattr(idmap, dentry, name, value, size, 291 292 flags); 292 293 if (error) 293 294 goto out; ··· 296 297 if (error) 297 298 goto out; 298 299 299 - error = __vfs_setxattr_noperm(mnt_userns, dentry, name, value, 300 + error = __vfs_setxattr_noperm(idmap, dentry, name, value, 300 301 size, flags); 301 302 302 303 out: ··· 308 309 vfs_setxattr(struct mnt_idmap *idmap, struct dentry *dentry, 309 310 const char *name, const void *value, size_t size, int flags) 310 311 { 311 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 312 312 struct inode *inode = dentry->d_inode; 313 313 struct inode *delegated_inode = NULL; 314 314 const void *orig_value = value; 315 315 int error; 316 316 317 317 if (size && strcmp(name, XATTR_NAME_CAPS) == 0) { 318 - error = cap_convert_nscap(mnt_userns, dentry, &value, size); 318 + error = cap_convert_nscap(idmap, dentry, &value, size); 319 319 if (error < 0) 320 320 return error; 321 321 size = error; ··· 482 484 EXPORT_SYMBOL_GPL(vfs_listxattr); 483 485 484 486 int 485 - __vfs_removexattr(struct user_namespace *mnt_userns, struct dentry *dentry, 487 + __vfs_removexattr(struct mnt_idmap *idmap, struct dentry *dentry, 486 488 const char *name) 487 489 { 488 490 struct inode *inode = d_inode(dentry); ··· 496 498 return PTR_ERR(handler); 497 499 if (!handler->set) 498 500 return -EOPNOTSUPP; 499 - return handler->set(handler, mnt_userns, dentry, inode, name, NULL, 0, 501 + return handler->set(handler, idmap, dentry, inode, name, NULL, 0, 500 502 XATTR_REPLACE); 501 503 } 502 504 EXPORT_SYMBOL(__vfs_removexattr); ··· 516 518 struct dentry *dentry, const char *name, 517 519 struct inode **delegated_inode) 518 520 { 519 - struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 520 521 struct inode *inode = dentry->d_inode; 521 522 int error; 522 523 ··· 523 526 if (error) 524 527 return error; 525 528 526 - error = security_inode_removexattr(mnt_userns, dentry, name); 529 + error = security_inode_removexattr(idmap, dentry, name); 527 530 if (error) 528 531 goto out; 529 532 ··· 531 534 if (error) 532 535 goto out; 533 536 534 - error = __vfs_removexattr(mnt_userns, dentry, name); 537 + error = __vfs_removexattr(idmap, dentry, name); 535 538 536 539 if (!error) { 537 540 fsnotify_xattr(dentry);
+1 -1
fs/xfs/xfs_xattr.c
··· 133 133 134 134 static int 135 135 xfs_xattr_set(const struct xattr_handler *handler, 136 - struct user_namespace *mnt_userns, struct dentry *unused, 136 + struct mnt_idmap *idmap, struct dentry *unused, 137 137 struct inode *inode, const char *name, const void *value, 138 138 size_t size, int flags) 139 139 {
+3 -2
include/linux/capability.h
··· 42 42 struct dentry; 43 43 struct task_struct; 44 44 struct user_namespace; 45 + struct mnt_idmap; 45 46 46 47 extern const kernel_cap_t __cap_empty_set; 47 48 extern const kernel_cap_t __cap_init_eff_set; ··· 272 271 } 273 272 274 273 /* audit system wants to get cap info from files as well */ 275 - int get_vfs_caps_from_disk(struct user_namespace *mnt_userns, 274 + int get_vfs_caps_from_disk(struct mnt_idmap *idmap, 276 275 const struct dentry *dentry, 277 276 struct cpu_vfs_cap_data *cpu_caps); 278 277 279 - int cap_convert_nscap(struct user_namespace *mnt_userns, struct dentry *dentry, 278 + int cap_convert_nscap(struct mnt_idmap *idmap, struct dentry *dentry, 280 279 const void **ivalue, size_t size); 281 280 282 281 #endif /* !_LINUX_CAPABILITY_H */
+4 -4
include/linux/evm.h
··· 24 24 extern int evm_inode_setattr(struct mnt_idmap *idmap, 25 25 struct dentry *dentry, struct iattr *attr); 26 26 extern void evm_inode_post_setattr(struct dentry *dentry, int ia_valid); 27 - extern int evm_inode_setxattr(struct user_namespace *mnt_userns, 27 + extern int evm_inode_setxattr(struct mnt_idmap *idmap, 28 28 struct dentry *dentry, const char *name, 29 29 const void *value, size_t size); 30 30 extern void evm_inode_post_setxattr(struct dentry *dentry, 31 31 const char *xattr_name, 32 32 const void *xattr_value, 33 33 size_t xattr_value_len); 34 - extern int evm_inode_removexattr(struct user_namespace *mnt_userns, 34 + extern int evm_inode_removexattr(struct mnt_idmap *idmap, 35 35 struct dentry *dentry, const char *xattr_name); 36 36 extern void evm_inode_post_removexattr(struct dentry *dentry, 37 37 const char *xattr_name); ··· 101 101 return; 102 102 } 103 103 104 - static inline int evm_inode_setxattr(struct user_namespace *mnt_userns, 104 + static inline int evm_inode_setxattr(struct mnt_idmap *idmap, 105 105 struct dentry *dentry, const char *name, 106 106 const void *value, size_t size) 107 107 { ··· 116 116 return; 117 117 } 118 118 119 - static inline int evm_inode_removexattr(struct user_namespace *mnt_userns, 119 + static inline int evm_inode_removexattr(struct mnt_idmap *idmap, 120 120 struct dentry *dentry, 121 121 const char *xattr_name) 122 122 {
+6 -6
include/linux/ima.h
··· 18 18 extern enum hash_algo ima_get_current_hash_algo(void); 19 19 extern int ima_bprm_check(struct linux_binprm *bprm); 20 20 extern int ima_file_check(struct file *file, int mask); 21 - extern void ima_post_create_tmpfile(struct user_namespace *mnt_userns, 21 + extern void ima_post_create_tmpfile(struct mnt_idmap *idmap, 22 22 struct inode *inode); 23 23 extern void ima_file_free(struct file *file); 24 24 extern int ima_file_mmap(struct file *file, unsigned long prot); ··· 30 30 bool contents); 31 31 extern int ima_post_read_file(struct file *file, void *buf, loff_t size, 32 32 enum kernel_read_file_id id); 33 - extern void ima_post_path_mknod(struct user_namespace *mnt_userns, 33 + extern void ima_post_path_mknod(struct mnt_idmap *idmap, 34 34 struct dentry *dentry); 35 35 extern int ima_file_hash(struct file *file, char *buf, size_t buf_size); 36 36 extern int ima_inode_hash(struct inode *inode, char *buf, size_t buf_size); ··· 66 66 return 0; 67 67 } 68 68 69 - static inline void ima_post_create_tmpfile(struct user_namespace *mnt_userns, 69 + static inline void ima_post_create_tmpfile(struct mnt_idmap *idmap, 70 70 struct inode *inode) 71 71 { 72 72 } ··· 111 111 return 0; 112 112 } 113 113 114 - static inline void ima_post_path_mknod(struct user_namespace *mnt_userns, 114 + static inline void ima_post_path_mknod(struct mnt_idmap *idmap, 115 115 struct dentry *dentry) 116 116 { 117 117 return; ··· 183 183 184 184 #ifdef CONFIG_IMA_APPRAISE 185 185 extern bool is_ima_appraise_enabled(void); 186 - extern void ima_inode_post_setattr(struct user_namespace *mnt_userns, 186 + extern void ima_inode_post_setattr(struct mnt_idmap *idmap, 187 187 struct dentry *dentry); 188 188 extern int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name, 189 189 const void *xattr_value, size_t xattr_value_len); ··· 203 203 return 0; 204 204 } 205 205 206 - static inline void ima_inode_post_setattr(struct user_namespace *mnt_userns, 206 + static inline void ima_inode_post_setattr(struct mnt_idmap *idmap, 207 207 struct dentry *dentry) 208 208 { 209 209 return;
+3 -3
include/linux/lsm_hook_defs.h
··· 136 136 LSM_HOOK(int, 0, inode_permission, struct inode *inode, int mask) 137 137 LSM_HOOK(int, 0, inode_setattr, struct dentry *dentry, struct iattr *attr) 138 138 LSM_HOOK(int, 0, inode_getattr, const struct path *path) 139 - LSM_HOOK(int, 0, inode_setxattr, struct user_namespace *mnt_userns, 139 + LSM_HOOK(int, 0, inode_setxattr, struct mnt_idmap *idmap, 140 140 struct dentry *dentry, const char *name, const void *value, 141 141 size_t size, int flags) 142 142 LSM_HOOK(void, LSM_RET_VOID, inode_post_setxattr, struct dentry *dentry, 143 143 const char *name, const void *value, size_t size, int flags) 144 144 LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name) 145 145 LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry) 146 - LSM_HOOK(int, 0, inode_removexattr, struct user_namespace *mnt_userns, 146 + LSM_HOOK(int, 0, inode_removexattr, struct mnt_idmap *idmap, 147 147 struct dentry *dentry, const char *name) 148 148 LSM_HOOK(int, 0, inode_set_acl, struct user_namespace *mnt_userns, 149 149 struct dentry *dentry, const char *acl_name, struct posix_acl *kacl) ··· 152 152 LSM_HOOK(int, 0, inode_remove_acl, struct user_namespace *mnt_userns, 153 153 struct dentry *dentry, const char *acl_name) 154 154 LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry) 155 - LSM_HOOK(int, 0, inode_killpriv, struct user_namespace *mnt_userns, 155 + LSM_HOOK(int, 0, inode_killpriv, struct mnt_idmap *idmap, 156 156 struct dentry *dentry) 157 157 LSM_HOOK(int, -EOPNOTSUPP, inode_getsecurity, struct mnt_idmap *idmap, 158 158 struct inode *inode, const char *name, void **buffer, bool alloc)
+1 -1
include/linux/lsm_hooks.h
··· 475 475 * @inode_killpriv: 476 476 * The setuid bit is being removed. Remove similar security labels. 477 477 * Called with the dentry->d_inode->i_mutex held. 478 - * @mnt_userns: user namespace of the mount. 478 + * @idmap: idmap of the mount. 479 479 * @dentry is the dentry being changed. 480 480 * Return 0 on success. If error is returned, then the operation 481 481 * causing setuid bit removal is failed.
+10 -12
include/linux/security.h
··· 153 153 extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, struct file *file); 154 154 int cap_inode_setxattr(struct dentry *dentry, const char *name, 155 155 const void *value, size_t size, int flags); 156 - int cap_inode_removexattr(struct user_namespace *mnt_userns, 156 + int cap_inode_removexattr(struct mnt_idmap *idmap, 157 157 struct dentry *dentry, const char *name); 158 158 int cap_inode_need_killpriv(struct dentry *dentry); 159 - int cap_inode_killpriv(struct user_namespace *mnt_userns, 160 - struct dentry *dentry); 159 + int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry); 161 160 int cap_inode_getsecurity(struct mnt_idmap *idmap, 162 161 struct inode *inode, const char *name, void **buffer, 163 162 bool alloc); ··· 358 359 int security_inode_setattr(struct mnt_idmap *idmap, 359 360 struct dentry *dentry, struct iattr *attr); 360 361 int security_inode_getattr(const struct path *path); 361 - int security_inode_setxattr(struct user_namespace *mnt_userns, 362 + int security_inode_setxattr(struct mnt_idmap *idmap, 362 363 struct dentry *dentry, const char *name, 363 364 const void *value, size_t size, int flags); 364 365 int security_inode_set_acl(struct user_namespace *mnt_userns, ··· 372 373 const void *value, size_t size, int flags); 373 374 int security_inode_getxattr(struct dentry *dentry, const char *name); 374 375 int security_inode_listxattr(struct dentry *dentry); 375 - int security_inode_removexattr(struct user_namespace *mnt_userns, 376 + int security_inode_removexattr(struct mnt_idmap *idmap, 376 377 struct dentry *dentry, const char *name); 377 378 int security_inode_need_killpriv(struct dentry *dentry); 378 - int security_inode_killpriv(struct user_namespace *mnt_userns, 379 - struct dentry *dentry); 379 + int security_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry); 380 380 int security_inode_getsecurity(struct mnt_idmap *idmap, 381 381 struct inode *inode, const char *name, 382 382 void **buffer, bool alloc); ··· 872 874 return 0; 873 875 } 874 876 875 - static inline int security_inode_setxattr(struct user_namespace *mnt_userns, 877 + static inline int security_inode_setxattr(struct mnt_idmap *idmap, 876 878 struct dentry *dentry, const char *name, const void *value, 877 879 size_t size, int flags) 878 880 { ··· 916 918 return 0; 917 919 } 918 920 919 - static inline int security_inode_removexattr(struct user_namespace *mnt_userns, 921 + static inline int security_inode_removexattr(struct mnt_idmap *idmap, 920 922 struct dentry *dentry, 921 923 const char *name) 922 924 { 923 - return cap_inode_removexattr(mnt_userns, dentry, name); 925 + return cap_inode_removexattr(idmap, dentry, name); 924 926 } 925 927 926 928 static inline int security_inode_need_killpriv(struct dentry *dentry) ··· 928 930 return cap_inode_need_killpriv(dentry); 929 931 } 930 932 931 - static inline int security_inode_killpriv(struct user_namespace *mnt_userns, 933 + static inline int security_inode_killpriv(struct mnt_idmap *idmap, 932 934 struct dentry *dentry) 933 935 { 934 - return cap_inode_killpriv(mnt_userns, dentry); 936 + return cap_inode_killpriv(idmap, dentry); 935 937 } 936 938 937 939 static inline int security_inode_getsecurity(struct mnt_idmap *idmap,
+4 -4
include/linux/xattr.h
··· 42 42 struct inode *inode, const char *name, void *buffer, 43 43 size_t size); 44 44 int (*set)(const struct xattr_handler *, 45 - struct user_namespace *mnt_userns, struct dentry *dentry, 45 + struct mnt_idmap *idmap, struct dentry *dentry, 46 46 struct inode *inode, const char *name, const void *buffer, 47 47 size_t size, int flags); 48 48 }; ··· 59 59 ssize_t vfs_getxattr(struct mnt_idmap *, struct dentry *, const char *, 60 60 void *, size_t); 61 61 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size); 62 - int __vfs_setxattr(struct user_namespace *, struct dentry *, struct inode *, 62 + int __vfs_setxattr(struct mnt_idmap *, struct dentry *, struct inode *, 63 63 const char *, const void *, size_t, int); 64 - int __vfs_setxattr_noperm(struct user_namespace *, struct dentry *, 64 + int __vfs_setxattr_noperm(struct mnt_idmap *, struct dentry *, 65 65 const char *, const void *, size_t, int); 66 66 int __vfs_setxattr_locked(struct mnt_idmap *, struct dentry *, 67 67 const char *, const void *, size_t, int, 68 68 struct inode **); 69 69 int vfs_setxattr(struct mnt_idmap *, struct dentry *, const char *, 70 70 const void *, size_t, int); 71 - int __vfs_removexattr(struct user_namespace *, struct dentry *, const char *); 71 + int __vfs_removexattr(struct mnt_idmap *, struct dentry *, const char *); 72 72 int __vfs_removexattr_locked(struct mnt_idmap *, struct dentry *, 73 73 const char *, struct inode **); 74 74 int vfs_removexattr(struct mnt_idmap *, struct dentry *, const char *);
+2 -2
kernel/auditsc.c
··· 2252 2252 if (!dentry) 2253 2253 return 0; 2254 2254 2255 - rc = get_vfs_caps_from_disk(&init_user_ns, dentry, &caps); 2255 + rc = get_vfs_caps_from_disk(&nop_mnt_idmap, dentry, &caps); 2256 2256 if (rc) 2257 2257 return rc; 2258 2258 ··· 2807 2807 ax->d.next = context->aux; 2808 2808 context->aux = (void *)ax; 2809 2809 2810 - get_vfs_caps_from_disk(&init_user_ns, 2810 + get_vfs_caps_from_disk(&nop_mnt_idmap, 2811 2811 bprm->file->f_path.dentry, &vcaps); 2812 2812 2813 2813 ax->fcap.permitted = vcaps.permitted;
+1 -1
mm/shmem.c
··· 3303 3303 } 3304 3304 3305 3305 static int shmem_xattr_handler_set(const struct xattr_handler *handler, 3306 - struct user_namespace *mnt_userns, 3306 + struct mnt_idmap *idmap, 3307 3307 struct dentry *unused, struct inode *inode, 3308 3308 const char *name, const void *value, 3309 3309 size_t size, int flags)
+1 -1
net/socket.c
··· 385 385 }; 386 386 387 387 static int sockfs_security_xattr_set(const struct xattr_handler *handler, 388 - struct user_namespace *mnt_userns, 388 + struct mnt_idmap *idmap, 389 389 struct dentry *dentry, struct inode *inode, 390 390 const char *suffix, const void *value, 391 391 size_t size, int flags)
+30 -27
security/commoncap.c
··· 305 305 /** 306 306 * cap_inode_killpriv - Erase the security markings on an inode 307 307 * 308 - * @mnt_userns: user namespace of the mount the inode was found from 308 + * @idmap: idmap of the mount the inode was found from 309 309 * @dentry: The inode/dentry to alter 310 310 * 311 311 * Erase the privilege-enhancing security markings on an inode. 312 312 * 313 - * If the inode has been found through an idmapped mount the user namespace of 314 - * the vfsmount must be passed through @mnt_userns. This function will then 315 - * take care to map the inode according to @mnt_userns before checking 313 + * If the inode has been found through an idmapped mount the idmap of 314 + * the vfsmount must be passed through @idmap. This function will then 315 + * take care to map the inode according to @idmap before checking 316 316 * permissions. On non-idmapped mounts or if permission checking is to be 317 - * performed on the raw inode simply passs init_user_ns. 317 + * performed on the raw inode simply passs @nop_mnt_idmap. 318 318 * 319 319 * Return: 0 if successful, -ve on error. 320 320 */ 321 - int cap_inode_killpriv(struct user_namespace *mnt_userns, struct dentry *dentry) 321 + int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry) 322 322 { 323 323 int error; 324 324 325 - error = __vfs_removexattr(mnt_userns, dentry, XATTR_NAME_CAPS); 325 + error = __vfs_removexattr(idmap, dentry, XATTR_NAME_CAPS); 326 326 if (error == -EOPNOTSUPP) 327 327 error = 0; 328 328 return error; ··· 511 511 /** 512 512 * cap_convert_nscap - check vfs caps 513 513 * 514 - * @mnt_userns: user namespace of the mount the inode was found from 514 + * @idmap: idmap of the mount the inode was found from 515 515 * @dentry: used to retrieve inode to check permissions on 516 516 * @ivalue: vfs caps value which may be modified by this function 517 517 * @size: size of @ivalue ··· 519 519 * User requested a write of security.capability. If needed, update the 520 520 * xattr to change from v2 to v3, or to fixup the v3 rootid. 521 521 * 522 - * If the inode has been found through an idmapped mount the user namespace of 523 - * the vfsmount must be passed through @mnt_userns. This function will then 524 - * take care to map the inode according to @mnt_userns before checking 522 + * If the inode has been found through an idmapped mount the idmap of 523 + * the vfsmount must be passed through @idmap. This function will then 524 + * take care to map the inode according to @idmap before checking 525 525 * permissions. On non-idmapped mounts or if permission checking is to be 526 - * performed on the raw inode simply passs init_user_ns. 526 + * performed on the raw inode simply passs @nop_mnt_idmap. 527 527 * 528 528 * Return: On success, return the new size; on error, return < 0. 529 529 */ 530 - int cap_convert_nscap(struct user_namespace *mnt_userns, struct dentry *dentry, 530 + int cap_convert_nscap(struct mnt_idmap *idmap, struct dentry *dentry, 531 531 const void **ivalue, size_t size) 532 532 { 533 533 struct vfs_ns_cap_data *nscap; ··· 537 537 struct inode *inode = d_backing_inode(dentry); 538 538 struct user_namespace *task_ns = current_user_ns(), 539 539 *fs_ns = inode->i_sb->s_user_ns; 540 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 540 541 kuid_t rootid; 541 542 vfsuid_t vfsrootid; 542 543 size_t newsize; ··· 548 547 return -EINVAL; 549 548 if (!capable_wrt_inode_uidgid(mnt_userns, inode, CAP_SETFCAP)) 550 549 return -EPERM; 551 - if (size == XATTR_CAPS_SZ_2 && (mnt_userns == fs_ns)) 550 + if (size == XATTR_CAPS_SZ_2 && (idmap == &nop_mnt_idmap)) 552 551 if (ns_capable(inode->i_sb->s_user_ns, CAP_SETFCAP)) 553 552 /* user is privileged, just write the v2 */ 554 553 return size; ··· 628 627 /** 629 628 * get_vfs_caps_from_disk - retrieve vfs caps from disk 630 629 * 631 - * @mnt_userns: user namespace of the mount the inode was found from 630 + * @idmap: idmap of the mount the inode was found from 632 631 * @dentry: dentry from which @inode is retrieved 633 632 * @cpu_caps: vfs capabilities 634 633 * 635 634 * Extract the on-exec-apply capability sets for an executable file. 636 635 * 637 - * If the inode has been found through an idmapped mount the user namespace of 638 - * the vfsmount must be passed through @mnt_userns. This function will then 639 - * take care to map the inode according to @mnt_userns before checking 636 + * If the inode has been found through an idmapped mount the idmap of 637 + * the vfsmount must be passed through @idmap. This function will then 638 + * take care to map the inode according to @idmap before checking 640 639 * permissions. On non-idmapped mounts or if permission checking is to be 641 - * performed on the raw inode simply passs init_user_ns. 640 + * performed on the raw inode simply passs @nop_mnt_idmap. 642 641 */ 643 - int get_vfs_caps_from_disk(struct user_namespace *mnt_userns, 642 + int get_vfs_caps_from_disk(struct mnt_idmap *idmap, 644 643 const struct dentry *dentry, 645 644 struct cpu_vfs_cap_data *cpu_caps) 646 645 { ··· 653 652 kuid_t rootkuid; 654 653 vfsuid_t rootvfsuid; 655 654 struct user_namespace *fs_ns; 655 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 656 656 657 657 memset(cpu_caps, 0, sizeof(struct cpu_vfs_cap_data)); 658 658 ··· 750 748 if (!current_in_userns(file->f_path.mnt->mnt_sb->s_user_ns)) 751 749 return 0; 752 750 753 - rc = get_vfs_caps_from_disk(file_mnt_user_ns(file), 751 + rc = get_vfs_caps_from_disk(file_mnt_idmap(file), 754 752 file->f_path.dentry, &vcaps); 755 753 if (rc < 0) { 756 754 if (rc == -EINVAL) ··· 1019 1017 /** 1020 1018 * cap_inode_removexattr - Determine whether an xattr may be removed 1021 1019 * 1022 - * @mnt_userns: User namespace of the mount the inode was found from 1020 + * @idmap: idmap of the mount the inode was found from 1023 1021 * @dentry: The inode/dentry being altered 1024 1022 * @name: The name of the xattr to be changed 1025 1023 * 1026 1024 * Determine whether an xattr may be removed from an inode, returning 0 if 1027 1025 * permission is granted, -ve if denied. 1028 1026 * 1029 - * If the inode has been found through an idmapped mount the user namespace of 1030 - * the vfsmount must be passed through @mnt_userns. This function will then 1031 - * take care to map the inode according to @mnt_userns before checking 1027 + * If the inode has been found through an idmapped mount the idmap of 1028 + * the vfsmount must be passed through @idmap. This function will then 1029 + * take care to map the inode according to @idmap before checking 1032 1030 * permissions. On non-idmapped mounts or if permission checking is to be 1033 - * performed on the raw inode simply passs init_user_ns. 1031 + * performed on the raw inode simply pass @nop_mnt_idmap. 1034 1032 * 1035 1033 * This is used to make sure security xattrs don't get removed by those who 1036 1034 * aren't privileged to remove them. 1037 1035 */ 1038 - int cap_inode_removexattr(struct user_namespace *mnt_userns, 1036 + int cap_inode_removexattr(struct mnt_idmap *idmap, 1039 1037 struct dentry *dentry, const char *name) 1040 1038 { 1041 1039 struct user_namespace *user_ns = dentry->d_sb->s_user_ns; 1040 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 1042 1041 1043 1042 /* Ignore non-security xattrs */ 1044 1043 if (strncmp(name, XATTR_SECURITY_PREFIX,
+2 -2
security/integrity/evm/evm_crypto.c
··· 376 376 xattr_value_len, &data); 377 377 if (rc == 0) { 378 378 data.hdr.xattr.sha1.type = EVM_XATTR_HMAC; 379 - rc = __vfs_setxattr_noperm(&init_user_ns, dentry, 379 + rc = __vfs_setxattr_noperm(&nop_mnt_idmap, dentry, 380 380 XATTR_NAME_EVM, 381 381 &data.hdr.xattr.data[1], 382 382 SHA1_DIGEST_SIZE + 1, 0); 383 383 } else if (rc == -ENODATA && (inode->i_opflags & IOP_XATTR)) { 384 - rc = __vfs_removexattr(&init_user_ns, dentry, XATTR_NAME_EVM); 384 + rc = __vfs_removexattr(&nop_mnt_idmap, dentry, XATTR_NAME_EVM); 385 385 } 386 386 return rc; 387 387 }
+10 -10
security/integrity/evm/evm_main.c
··· 436 436 437 437 /* 438 438 * evm_xattr_change - check if passed xattr value differs from current value 439 - * @mnt_userns: user namespace of the idmapped mount 439 + * @idmap: idmap of the mount 440 440 * @dentry: pointer to the affected dentry 441 441 * @xattr_name: requested xattr 442 442 * @xattr_value: requested xattr value ··· 446 446 * 447 447 * Returns 1 if passed xattr value differs from current value, 0 otherwise. 448 448 */ 449 - static int evm_xattr_change(struct user_namespace *mnt_userns, 449 + static int evm_xattr_change(struct mnt_idmap *idmap, 450 450 struct dentry *dentry, const char *xattr_name, 451 451 const void *xattr_value, size_t xattr_value_len) 452 452 { ··· 482 482 * For posix xattr acls only, permit security.evm, even if it currently 483 483 * doesn't exist, to be updated unless the EVM signature is immutable. 484 484 */ 485 - static int evm_protect_xattr(struct user_namespace *mnt_userns, 485 + static int evm_protect_xattr(struct mnt_idmap *idmap, 486 486 struct dentry *dentry, const char *xattr_name, 487 487 const void *xattr_value, size_t xattr_value_len) 488 488 { ··· 538 538 return 0; 539 539 540 540 if (evm_status == INTEGRITY_PASS_IMMUTABLE && 541 - !evm_xattr_change(mnt_userns, dentry, xattr_name, xattr_value, 541 + !evm_xattr_change(idmap, dentry, xattr_name, xattr_value, 542 542 xattr_value_len)) 543 543 return 0; 544 544 ··· 553 553 554 554 /** 555 555 * evm_inode_setxattr - protect the EVM extended attribute 556 - * @mnt_userns: user namespace of the idmapped mount 556 + * @idmap: idmap of the mount 557 557 * @dentry: pointer to the affected dentry 558 558 * @xattr_name: pointer to the affected extended attribute name 559 559 * @xattr_value: pointer to the new extended attribute value ··· 565 565 * userspace from writing HMAC value. Writing 'security.evm' requires 566 566 * requires CAP_SYS_ADMIN privileges. 567 567 */ 568 - int evm_inode_setxattr(struct user_namespace *mnt_userns, struct dentry *dentry, 568 + int evm_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry, 569 569 const char *xattr_name, const void *xattr_value, 570 570 size_t xattr_value_len) 571 571 { ··· 584 584 xattr_data->type != EVM_XATTR_PORTABLE_DIGSIG) 585 585 return -EPERM; 586 586 } 587 - return evm_protect_xattr(mnt_userns, dentry, xattr_name, xattr_value, 587 + return evm_protect_xattr(idmap, dentry, xattr_name, xattr_value, 588 588 xattr_value_len); 589 589 } 590 590 591 591 /** 592 592 * evm_inode_removexattr - protect the EVM extended attribute 593 - * @mnt_userns: user namespace of the idmapped mount 593 + * @idmap: idmap of the mount 594 594 * @dentry: pointer to the affected dentry 595 595 * @xattr_name: pointer to the affected extended attribute name 596 596 * 597 597 * Removing 'security.evm' requires CAP_SYS_ADMIN privileges and that 598 598 * the current value is valid. 599 599 */ 600 - int evm_inode_removexattr(struct user_namespace *mnt_userns, 600 + int evm_inode_removexattr(struct mnt_idmap *idmap, 601 601 struct dentry *dentry, const char *xattr_name) 602 602 { 603 603 /* Policy permits modification of the protected xattrs even though ··· 606 606 if (evm_initialized & EVM_ALLOW_METADATA_WRITES) 607 607 return 0; 608 608 609 - return evm_protect_xattr(mnt_userns, dentry, xattr_name, NULL, 0); 609 + return evm_protect_xattr(idmap, dentry, xattr_name, NULL, 0); 610 610 } 611 611 612 612 #ifdef CONFIG_FS_POSIX_ACL
+5 -5
security/integrity/ima/ima.h
··· 254 254 #endif /* CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS */ 255 255 256 256 /* LIM API function definitions */ 257 - int ima_get_action(struct user_namespace *mnt_userns, struct inode *inode, 257 + int ima_get_action(struct mnt_idmap *idmap, struct inode *inode, 258 258 const struct cred *cred, u32 secid, int mask, 259 259 enum ima_hooks func, int *pcr, 260 260 struct ima_template_desc **template_desc, ··· 268 268 struct evm_ima_xattr_data *xattr_value, 269 269 int xattr_len, const struct modsig *modsig, int pcr, 270 270 struct ima_template_desc *template_desc); 271 - int process_buffer_measurement(struct user_namespace *mnt_userns, 271 + int process_buffer_measurement(struct mnt_idmap *idmap, 272 272 struct inode *inode, const void *buf, int size, 273 273 const char *eventname, enum ima_hooks func, 274 274 int pcr, const char *func_data, ··· 285 285 const char *ima_d_path(const struct path *path, char **pathbuf, char *filename); 286 286 287 287 /* IMA policy related functions */ 288 - int ima_match_policy(struct user_namespace *mnt_userns, struct inode *inode, 288 + int ima_match_policy(struct mnt_idmap *idmap, struct inode *inode, 289 289 const struct cred *cred, u32 secid, enum ima_hooks func, 290 290 int mask, int flags, int *pcr, 291 291 struct ima_template_desc **template_desc, ··· 318 318 struct file *file, const unsigned char *filename, 319 319 struct evm_ima_xattr_data *xattr_value, 320 320 int xattr_len, const struct modsig *modsig); 321 - int ima_must_appraise(struct user_namespace *mnt_userns, struct inode *inode, 321 + int ima_must_appraise(struct mnt_idmap *idmap, struct inode *inode, 322 322 int mask, enum ima_hooks func); 323 323 void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file); 324 324 enum integrity_status ima_get_cache_status(struct integrity_iint_cache *iint, ··· 346 346 return INTEGRITY_UNKNOWN; 347 347 } 348 348 349 - static inline int ima_must_appraise(struct user_namespace *mnt_userns, 349 + static inline int ima_must_appraise(struct mnt_idmap *idmap, 350 350 struct inode *inode, int mask, 351 351 enum ima_hooks func) 352 352 {
+3 -3
security/integrity/ima/ima_api.c
··· 163 163 164 164 /** 165 165 * ima_get_action - appraise & measure decision based on policy. 166 - * @mnt_userns: user namespace of the mount the inode was found from 166 + * @idmap: idmap of the mount the inode was found from 167 167 * @inode: pointer to the inode associated with the object being validated 168 168 * @cred: pointer to credentials structure to validate 169 169 * @secid: secid of the task being validated ··· 186 186 * Returns IMA_MEASURE, IMA_APPRAISE mask. 187 187 * 188 188 */ 189 - int ima_get_action(struct user_namespace *mnt_userns, struct inode *inode, 189 + int ima_get_action(struct mnt_idmap *idmap, struct inode *inode, 190 190 const struct cred *cred, u32 secid, int mask, 191 191 enum ima_hooks func, int *pcr, 192 192 struct ima_template_desc **template_desc, ··· 196 196 197 197 flags &= ima_policy_flag; 198 198 199 - return ima_match_policy(mnt_userns, inode, cred, secid, func, mask, 199 + return ima_match_policy(idmap, inode, cred, secid, func, mask, 200 200 flags, pcr, template_desc, func_data, 201 201 allowed_algos); 202 202 }
+7 -7
security/integrity/ima/ima_appraise.c
··· 70 70 * 71 71 * Return 1 to appraise or hash 72 72 */ 73 - int ima_must_appraise(struct user_namespace *mnt_userns, struct inode *inode, 73 + int ima_must_appraise(struct mnt_idmap *idmap, struct inode *inode, 74 74 int mask, enum ima_hooks func) 75 75 { 76 76 u32 secid; ··· 79 79 return 0; 80 80 81 81 security_current_getsecid_subj(&secid); 82 - return ima_match_policy(mnt_userns, inode, current_cred(), secid, 82 + return ima_match_policy(idmap, inode, current_cred(), secid, 83 83 func, mask, IMA_APPRAISE | IMA_HASH, NULL, 84 84 NULL, NULL, NULL); 85 85 } ··· 98 98 iint->ima_hash->xattr.ng.type = IMA_XATTR_DIGEST_NG; 99 99 iint->ima_hash->xattr.ng.algo = algo; 100 100 } 101 - rc = __vfs_setxattr_noperm(&init_user_ns, dentry, XATTR_NAME_IMA, 101 + rc = __vfs_setxattr_noperm(&nop_mnt_idmap, dentry, XATTR_NAME_IMA, 102 102 &iint->ima_hash->xattr.data[offset], 103 103 (sizeof(iint->ima_hash->xattr) - offset) + 104 104 iint->ima_hash->length, 0); ··· 456 456 457 457 rc = is_binary_blacklisted(digest, digestsize); 458 458 if ((rc == -EPERM) && (iint->flags & IMA_MEASURE)) 459 - process_buffer_measurement(&init_user_ns, NULL, digest, digestsize, 459 + process_buffer_measurement(&nop_mnt_idmap, NULL, digest, digestsize, 460 460 "blacklisted-hash", NONE, 461 461 pcr, NULL, false, NULL, 0); 462 462 } ··· 622 622 623 623 /** 624 624 * ima_inode_post_setattr - reflect file metadata changes 625 - * @mnt_userns: user namespace of the mount the inode was found from 625 + * @idmap: idmap of the mount the inode was found from 626 626 * @dentry: pointer to the affected dentry 627 627 * 628 628 * Changes to a dentry's metadata might result in needing to appraise. ··· 630 630 * This function is called from notify_change(), which expects the caller 631 631 * to lock the inode's i_mutex. 632 632 */ 633 - void ima_inode_post_setattr(struct user_namespace *mnt_userns, 633 + void ima_inode_post_setattr(struct mnt_idmap *idmap, 634 634 struct dentry *dentry) 635 635 { 636 636 struct inode *inode = d_backing_inode(dentry); ··· 641 641 || !(inode->i_opflags & IOP_XATTR)) 642 642 return; 643 643 644 - action = ima_must_appraise(mnt_userns, inode, MAY_ACCESS, POST_SETATTR); 644 + action = ima_must_appraise(idmap, inode, MAY_ACCESS, POST_SETATTR); 645 645 iint = integrity_iint_find(inode); 646 646 if (iint) { 647 647 set_bit(IMA_CHANGE_ATTR, &iint->atomic_flags);
+1 -1
security/integrity/ima/ima_asymmetric_keys.c
··· 60 60 * if the IMA policy is configured to measure a key linked 61 61 * to the given keyring. 62 62 */ 63 - process_buffer_measurement(&init_user_ns, NULL, payload, payload_len, 63 + process_buffer_measurement(&nop_mnt_idmap, NULL, payload, payload_len, 64 64 keyring->description, KEY_CHECK, 0, 65 65 keyring->description, false, NULL, 0); 66 66 }
+13 -13
security/integrity/ima/ima_main.c
··· 224 224 * bitmask based on the appraise/audit/measurement policy. 225 225 * Included is the appraise submask. 226 226 */ 227 - action = ima_get_action(file_mnt_user_ns(file), inode, cred, secid, 227 + action = ima_get_action(file_mnt_idmap(file), inode, cred, secid, 228 228 mask, func, &pcr, &template_desc, NULL, 229 229 &allowed_algos); 230 230 violation_check = ((func == FILE_CHECK || func == MMAP_CHECK) && ··· 451 451 452 452 security_current_getsecid_subj(&secid); 453 453 inode = file_inode(vma->vm_file); 454 - action = ima_get_action(file_mnt_user_ns(vma->vm_file), inode, 454 + action = ima_get_action(file_mnt_idmap(vma->vm_file), inode, 455 455 current_cred(), secid, MAY_EXEC, MMAP_CHECK, 456 456 &pcr, &template, NULL, NULL); 457 457 ··· 638 638 639 639 /** 640 640 * ima_post_create_tmpfile - mark newly created tmpfile as new 641 - * @mnt_userns: user namespace of the mount the inode was found from 641 + * @idmap: idmap of the mount the inode was found from 642 642 * @inode: inode of the newly created tmpfile 643 643 * 644 644 * No measuring, appraising or auditing of newly created tmpfiles is needed. 645 645 * Skip calling process_measurement(), but indicate which newly, created 646 646 * tmpfiles are in policy. 647 647 */ 648 - void ima_post_create_tmpfile(struct user_namespace *mnt_userns, 648 + void ima_post_create_tmpfile(struct mnt_idmap *idmap, 649 649 struct inode *inode) 650 650 { 651 651 struct integrity_iint_cache *iint; ··· 654 654 if (!ima_policy_flag || !S_ISREG(inode->i_mode)) 655 655 return; 656 656 657 - must_appraise = ima_must_appraise(mnt_userns, inode, MAY_ACCESS, 657 + must_appraise = ima_must_appraise(idmap, inode, MAY_ACCESS, 658 658 FILE_CHECK); 659 659 if (!must_appraise) 660 660 return; ··· 671 671 672 672 /** 673 673 * ima_post_path_mknod - mark as a new inode 674 - * @mnt_userns: user namespace of the mount the inode was found from 674 + * @idmap: idmap of the mount the inode was found from 675 675 * @dentry: newly created dentry 676 676 * 677 677 * Mark files created via the mknodat syscall as new, so that the 678 678 * file data can be written later. 679 679 */ 680 - void ima_post_path_mknod(struct user_namespace *mnt_userns, 680 + void ima_post_path_mknod(struct mnt_idmap *idmap, 681 681 struct dentry *dentry) 682 682 { 683 683 struct integrity_iint_cache *iint; ··· 687 687 if (!ima_policy_flag || !S_ISREG(inode->i_mode)) 688 688 return; 689 689 690 - must_appraise = ima_must_appraise(mnt_userns, inode, MAY_ACCESS, 690 + must_appraise = ima_must_appraise(idmap, inode, MAY_ACCESS, 691 691 FILE_CHECK); 692 692 if (!must_appraise) 693 693 return; ··· 869 869 870 870 /** 871 871 * process_buffer_measurement - Measure the buffer or the buffer data hash 872 - * @mnt_userns: user namespace of the mount the inode was found from 872 + * @idmap: idmap of the mount the inode was found from 873 873 * @inode: inode associated with the object being measured (NULL for KEY_CHECK) 874 874 * @buf: pointer to the buffer that needs to be added to the log. 875 875 * @size: size of buffer(in bytes). ··· 887 887 * has been written to the passed location but not added to a measurement entry, 888 888 * a negative value otherwise. 889 889 */ 890 - int process_buffer_measurement(struct user_namespace *mnt_userns, 890 + int process_buffer_measurement(struct mnt_idmap *idmap, 891 891 struct inode *inode, const void *buf, int size, 892 892 const char *eventname, enum ima_hooks func, 893 893 int pcr, const char *func_data, ··· 931 931 */ 932 932 if (func) { 933 933 security_current_getsecid_subj(&secid); 934 - action = ima_get_action(mnt_userns, inode, current_cred(), 934 + action = ima_get_action(idmap, inode, current_cred(), 935 935 secid, 0, func, &pcr, &template, 936 936 func_data, NULL); 937 937 if (!(action & IMA_MEASURE) && !digest) ··· 1011 1011 if (!f.file) 1012 1012 return; 1013 1013 1014 - process_buffer_measurement(file_mnt_user_ns(f.file), file_inode(f.file), 1014 + process_buffer_measurement(file_mnt_idmap(f.file), file_inode(f.file), 1015 1015 buf, size, "kexec-cmdline", KEXEC_CMDLINE, 0, 1016 1016 NULL, false, NULL, 0); 1017 1017 fdput(f); ··· 1044 1044 if (!event_name || !event_label || !buf || !buf_len) 1045 1045 return -ENOPARAM; 1046 1046 1047 - return process_buffer_measurement(&init_user_ns, NULL, buf, buf_len, 1047 + return process_buffer_measurement(&nop_mnt_idmap, NULL, buf, buf_len, 1048 1048 event_name, CRITICAL_DATA, 0, 1049 1049 event_label, hash, digest, 1050 1050 digest_len);
+6 -5
security/integrity/ima/ima_policy.c
··· 552 552 /** 553 553 * ima_match_rules - determine whether an inode matches the policy rule. 554 554 * @rule: a pointer to a rule 555 - * @mnt_userns: user namespace of the mount the inode was found from 555 + * @idmap: idmap of the mount the inode was found from 556 556 * @inode: a pointer to an inode 557 557 * @cred: a pointer to a credentials structure for user validation 558 558 * @secid: the secid of the task to be validated ··· 563 563 * Returns true on rule match, false on failure. 564 564 */ 565 565 static bool ima_match_rules(struct ima_rule_entry *rule, 566 - struct user_namespace *mnt_userns, 566 + struct mnt_idmap *idmap, 567 567 struct inode *inode, const struct cred *cred, 568 568 u32 secid, enum ima_hooks func, int mask, 569 569 const char *func_data) ··· 572 572 bool result = false; 573 573 struct ima_rule_entry *lsm_rule = rule; 574 574 bool rule_reinitialized = false; 575 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 575 576 576 577 if ((rule->flags & IMA_FUNC) && 577 578 (rule->func != func && func != POST_SETATTR)) ··· 714 713 715 714 /** 716 715 * ima_match_policy - decision based on LSM and other conditions 717 - * @mnt_userns: user namespace of the mount the inode was found from 716 + * @idmap: idmap of the mount the inode was found from 718 717 * @inode: pointer to an inode for which the policy decision is being made 719 718 * @cred: pointer to a credentials structure for which the policy decision is 720 719 * being made ··· 733 732 * list when walking it. Reads are many orders of magnitude more numerous 734 733 * than writes so ima_match_policy() is classical RCU candidate. 735 734 */ 736 - int ima_match_policy(struct user_namespace *mnt_userns, struct inode *inode, 735 + int ima_match_policy(struct mnt_idmap *idmap, struct inode *inode, 737 736 const struct cred *cred, u32 secid, enum ima_hooks func, 738 737 int mask, int flags, int *pcr, 739 738 struct ima_template_desc **template_desc, ··· 753 752 if (!(entry->action & actmask)) 754 753 continue; 755 754 756 - if (!ima_match_rules(entry, mnt_userns, inode, cred, secid, 755 + if (!ima_match_rules(entry, idmap, inode, cred, secid, 757 756 func, mask, func_data)) 758 757 continue; 759 758
+1 -1
security/integrity/ima/ima_queue_keys.c
··· 159 159 160 160 list_for_each_entry_safe(entry, tmp, &ima_keys, list) { 161 161 if (!timer_expired) 162 - process_buffer_measurement(&init_user_ns, NULL, 162 + process_buffer_measurement(&nop_mnt_idmap, NULL, 163 163 entry->payload, 164 164 entry->payload_len, 165 165 entry->keyring_name,
+9 -9
security/security.c
··· 1375 1375 return call_int_hook(inode_getattr, 0, path); 1376 1376 } 1377 1377 1378 - int security_inode_setxattr(struct user_namespace *mnt_userns, 1378 + int security_inode_setxattr(struct mnt_idmap *idmap, 1379 1379 struct dentry *dentry, const char *name, 1380 1380 const void *value, size_t size, int flags) 1381 1381 { ··· 1387 1387 * SELinux and Smack integrate the cap call, 1388 1388 * so assume that all LSMs supplying this call do so. 1389 1389 */ 1390 - ret = call_int_hook(inode_setxattr, 1, mnt_userns, dentry, name, value, 1390 + ret = call_int_hook(inode_setxattr, 1, idmap, dentry, name, value, 1391 1391 size, flags); 1392 1392 1393 1393 if (ret == 1) ··· 1397 1397 ret = ima_inode_setxattr(dentry, name, value, size); 1398 1398 if (ret) 1399 1399 return ret; 1400 - return evm_inode_setxattr(mnt_userns, dentry, name, value, size); 1400 + return evm_inode_setxattr(idmap, dentry, name, value, size); 1401 1401 } 1402 1402 1403 1403 int security_inode_set_acl(struct user_namespace *mnt_userns, ··· 1465 1465 return call_int_hook(inode_listxattr, 0, dentry); 1466 1466 } 1467 1467 1468 - int security_inode_removexattr(struct user_namespace *mnt_userns, 1468 + int security_inode_removexattr(struct mnt_idmap *idmap, 1469 1469 struct dentry *dentry, const char *name) 1470 1470 { 1471 1471 int ret; ··· 1476 1476 * SELinux and Smack integrate the cap call, 1477 1477 * so assume that all LSMs supplying this call do so. 1478 1478 */ 1479 - ret = call_int_hook(inode_removexattr, 1, mnt_userns, dentry, name); 1479 + ret = call_int_hook(inode_removexattr, 1, idmap, dentry, name); 1480 1480 if (ret == 1) 1481 - ret = cap_inode_removexattr(mnt_userns, dentry, name); 1481 + ret = cap_inode_removexattr(idmap, dentry, name); 1482 1482 if (ret) 1483 1483 return ret; 1484 1484 ret = ima_inode_removexattr(dentry, name); 1485 1485 if (ret) 1486 1486 return ret; 1487 - return evm_inode_removexattr(mnt_userns, dentry, name); 1487 + return evm_inode_removexattr(idmap, dentry, name); 1488 1488 } 1489 1489 1490 1490 int security_inode_need_killpriv(struct dentry *dentry) ··· 1492 1492 return call_int_hook(inode_need_killpriv, 0, dentry); 1493 1493 } 1494 1494 1495 - int security_inode_killpriv(struct user_namespace *mnt_userns, 1495 + int security_inode_killpriv(struct mnt_idmap *idmap, 1496 1496 struct dentry *dentry) 1497 1497 { 1498 - return call_int_hook(inode_killpriv, 0, mnt_userns, dentry); 1498 + return call_int_hook(inode_killpriv, 0, idmap, dentry); 1499 1499 } 1500 1500 1501 1501 int security_inode_getsecurity(struct mnt_idmap *idmap,
+5 -4
security/selinux/hooks.c
··· 3145 3145 return true; 3146 3146 } 3147 3147 3148 - static int selinux_inode_setxattr(struct user_namespace *mnt_userns, 3148 + static int selinux_inode_setxattr(struct mnt_idmap *idmap, 3149 3149 struct dentry *dentry, const char *name, 3150 3150 const void *value, size_t size, int flags) 3151 3151 { ··· 3154 3154 struct superblock_security_struct *sbsec; 3155 3155 struct common_audit_data ad; 3156 3156 u32 newsid, sid = current_sid(); 3157 + struct user_namespace *mnt_userns = mnt_idmap_owner(idmap); 3157 3158 int rc = 0; 3158 3159 3159 3160 if (strcmp(name, XATTR_NAME_SELINUX)) { ··· 3314 3313 return dentry_has_perm(cred, dentry, FILE__GETATTR); 3315 3314 } 3316 3315 3317 - static int selinux_inode_removexattr(struct user_namespace *mnt_userns, 3316 + static int selinux_inode_removexattr(struct mnt_idmap *idmap, 3318 3317 struct dentry *dentry, const char *name) 3319 3318 { 3320 3319 if (strcmp(name, XATTR_NAME_SELINUX)) { 3321 - int rc = cap_inode_removexattr(mnt_userns, dentry, name); 3320 + int rc = cap_inode_removexattr(idmap, dentry, name); 3322 3321 if (rc) 3323 3322 return rc; 3324 3323 ··· 6589 6588 */ 6590 6589 static int selinux_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen) 6591 6590 { 6592 - return __vfs_setxattr_noperm(&init_user_ns, dentry, XATTR_NAME_SELINUX, 6591 + return __vfs_setxattr_noperm(&nop_mnt_idmap, dentry, XATTR_NAME_SELINUX, 6593 6592 ctx, ctxlen, 0); 6594 6593 } 6595 6594
+7 -7
security/smack/smack_lsm.c
··· 1207 1207 1208 1208 /** 1209 1209 * smack_inode_setxattr - Smack check for setting xattrs 1210 - * @mnt_userns: active user namespace 1210 + * @idmap: idmap of the mount 1211 1211 * @dentry: the object 1212 1212 * @name: name of the attribute 1213 1213 * @value: value of the attribute ··· 1218 1218 * 1219 1219 * Returns 0 if access is permitted, an error code otherwise 1220 1220 */ 1221 - static int smack_inode_setxattr(struct user_namespace *mnt_userns, 1221 + static int smack_inode_setxattr(struct mnt_idmap *idmap, 1222 1222 struct dentry *dentry, const char *name, 1223 1223 const void *value, size_t size, int flags) 1224 1224 { ··· 1334 1334 1335 1335 /** 1336 1336 * smack_inode_removexattr - Smack check on removexattr 1337 - * @mnt_userns: active user namespace 1337 + * @idmap: idmap of the mount 1338 1338 * @dentry: the object 1339 1339 * @name: name of the attribute 1340 1340 * ··· 1342 1342 * 1343 1343 * Returns 0 if access is permitted, an error code otherwise 1344 1344 */ 1345 - static int smack_inode_removexattr(struct user_namespace *mnt_userns, 1345 + static int smack_inode_removexattr(struct mnt_idmap *idmap, 1346 1346 struct dentry *dentry, const char *name) 1347 1347 { 1348 1348 struct inode_smack *isp; ··· 1358 1358 if (!smack_privileged(CAP_MAC_ADMIN)) 1359 1359 rc = -EPERM; 1360 1360 } else 1361 - rc = cap_inode_removexattr(mnt_userns, dentry, name); 1361 + rc = cap_inode_removexattr(idmap, dentry, name); 1362 1362 1363 1363 if (rc != 0) 1364 1364 return rc; ··· 3507 3507 */ 3508 3508 if (isp->smk_flags & SMK_INODE_CHANGED) { 3509 3509 isp->smk_flags &= ~SMK_INODE_CHANGED; 3510 - rc = __vfs_setxattr(&init_user_ns, dp, inode, 3510 + rc = __vfs_setxattr(&nop_mnt_idmap, dp, inode, 3511 3511 XATTR_NAME_SMACKTRANSMUTE, 3512 3512 TRANS_TRUE, TRANS_TRUE_SIZE, 3513 3513 0); ··· 4686 4686 4687 4687 static int smack_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen) 4688 4688 { 4689 - return __vfs_setxattr_noperm(&init_user_ns, dentry, XATTR_NAME_SMACK, 4689 + return __vfs_setxattr_noperm(&nop_mnt_idmap, dentry, XATTR_NAME_SMACK, 4690 4690 ctx, ctxlen, 0); 4691 4691 } 4692 4692