idmapped mounts
Subsystems (94)
PATCH v5 32/42 fs: make helpers idmap mount aware
In reply to Christian BraunerExtend some inode methods with an additional user namespace argument. A filesystem that is aware of idmapped mounts will receive the user namespace the mount has been marked with. This can be used for additional permission checking and also to enable filesystems to translate between uids and gids if they need to. We have implemented all relevant helpers in earlier patches.
As requested we simply extend the exisiting inode method instead of introducing new ones. This is a little more code churn but it's mostly mechanical and doesnt't leave us with additional inode methods.
---
/* v2 */
- Christoph Hellwig <[email protected]>:
- Don't pollute the vfs with additional helpers simply extend the existing inode methods with an additional argument and switch all callers.
/* v3 */
- kernel test robot <[email protected]>:
- Fix call to simple_rename() in drivers/android/binderfs.c.
- Fix ntfs_setattr() in fs/ntfs/file.c.
/* v4 */
- Serge Hallyn <[email protected]>:
- Use "mnt_userns" to refer to a vfsmount's userns everywhere to make terminology consistent.
/* v5 */
base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837
- Christoph Hellwig <[email protected]>:
- Use new file_userns_helper().
--- Documentation/filesystems/vfs.rst | 19 +++++---- arch/powerpc/platforms/cell/spufs/inode.c | 3 +- drivers/android/binderfs.c | 6 ++- fs/9p/acl.c | 4 +- fs/9p/v9fs.h | 3 +- fs/9p/v9fs_vfs.h | 2 +- fs/9p/vfs_inode.c | 26 +++++++----- fs/9p/vfs_inode_dotl.c | 31 ++++++++------ fs/adfs/adfs.h | 3 +- fs/adfs/inode.c | 3 +- fs/affs/affs.h | 10 ++--- fs/affs/inode.c | 3 +- fs/affs/namei.c | 15 ++++--- fs/afs/dir.c | 34 ++++++++------- fs/afs/inode.c | 7 +-- fs/afs/internal.h | 7 +-- fs/afs/security.c | 2 +- fs/attr.c | 4 +- fs/autofs/root.c | 13 +++--- fs/bad_inode.c | 36 ++++++++++------ fs/bfs/dir.c | 10 ++--- fs/btrfs/acl.c | 3 +- fs/btrfs/ctree.h | 3 +- fs/btrfs/inode.c | 33 ++++++++------ fs/ceph/acl.c | 3 +- fs/ceph/dir.c | 23 +++++----- fs/ceph/inode.c | 9 ++-- fs/ceph/super.h | 12 ++++-- fs/cifs/cifsfs.c | 2 +- fs/cifs/cifsfs.h | 21 ++++----- fs/cifs/dir.c | 8 ++-- fs/cifs/inode.c | 16 ++++--- fs/cifs/link.c | 3 +- fs/coda/coda_linux.h | 6 +-- fs/coda/dir.c | 17 +++++--- fs/coda/inode.c | 7 +-- fs/coda/pioctl.c | 6 ++- fs/configfs/configfs_internal.h | 7 +-- fs/configfs/dir.c | 3 +- fs/configfs/inode.c | 5 ++- fs/configfs/symlink.c | 3 +- fs/debugfs/inode.c | 9 ++-- fs/ecryptfs/inode.c | 31 ++++++++------ fs/efivarfs/inode.c | 4 +- fs/erofs/inode.c | 5 ++- fs/erofs/internal.h | 5 ++- fs/exec.c | 2 +- fs/exfat/exfat_fs.h | 8 ++-- fs/exfat/file.c | 8 ++-- fs/exfat/namei.c | 14 +++--- fs/ext2/acl.c | 3 +- fs/ext2/acl.h | 3 +- fs/ext2/ext2.h | 5 ++- fs/ext2/inode.c | 7 +-- fs/ext2/namei.c | 22 ++++++---- fs/ext4/acl.c | 3 +- fs/ext4/acl.h | 3 +- fs/ext4/ext4.h | 8 ++-- fs/ext4/inode.c | 12 +++--- fs/ext4/namei.c | 19 +++++---- fs/f2fs/acl.c | 3 +- fs/f2fs/acl.h | 3 +- fs/f2fs/f2fs.h | 7 +-- fs/f2fs/file.c | 7 +-- fs/f2fs/namei.c | 21 +++++---- fs/fat/fat.h | 6 ++- fs/fat/file.c | 9 ++-- fs/fat/namei_msdos.c | 10 +++-- fs/fat/namei_vfat.c | 13 +++--- fs/fuse/acl.c | 3 +- fs/fuse/dir.c | 37 +++++++++------- fs/fuse/fuse_i.h | 4 +- fs/gfs2/acl.c | 3 +- fs/gfs2/acl.h | 3 +- fs/gfs2/file.c | 2 +- fs/gfs2/inode.c | 49 ++++++++++++--------- fs/gfs2/inode.h | 3 +- fs/hfs/dir.c | 13 +++--- fs/hfs/hfs_fs.h | 2 +- fs/hfs/inode.c | 3 +- fs/hfsplus/dir.c | 25 +++++------ fs/hfsplus/hfsplus_fs.h | 5 ++- fs/hfsplus/inode.c | 8 ++-- fs/hostfs/hostfs_kern.c | 23 ++++++---- fs/hpfs/hpfs_fn.h | 2 +- fs/hpfs/inode.c | 3 +- fs/hpfs/namei.c | 20 +++++---- fs/hugetlbfs/inode.c | 25 ++++++----- fs/jffs2/acl.c | 3 +- fs/jffs2/acl.h | 3 +- fs/jffs2/dir.c | 32 ++++++++------ fs/jffs2/fs.c | 3 +- fs/jffs2/os-linux.h | 2 +- fs/jfs/acl.c | 3 +- fs/jfs/file.c | 3 +- fs/jfs/jfs_acl.h | 3 +- fs/jfs/jfs_inode.h | 2 +- fs/jfs/namei.c | 21 ++++----- fs/kernfs/dir.c | 7 +-- fs/kernfs/inode.c | 9 ++-- fs/kernfs/kernfs-internal.h | 9 ++-- fs/libfs.c | 31 +++++++------- fs/minix/file.c | 3 +- fs/minix/inode.c | 4 +- fs/minix/minix.h | 3 +- fs/minix/namei.c | 24 ++++++----- fs/namei.c | 51 ++++++++++++---------- fs/nfs/dir.c | 23 ++++++---- fs/nfs/inode.c | 7 +-- fs/nfs/internal.h | 10 ++--- fs/nfs/namespace.c | 12 +++--- fs/nfs/nfs3_fs.h | 3 +- fs/nfs/nfs3acl.c | 3 +- fs/nilfs2/inode.c | 5 ++- fs/nilfs2/namei.c | 19 +++++---- fs/nilfs2/nilfs.h | 4 +- fs/ntfs/inode.c | 4 +- fs/ntfs/inode.h | 3 +- fs/ocfs2/acl.c | 3 +- fs/ocfs2/acl.h | 3 +- fs/ocfs2/dlmfs/dlmfs.c | 9 ++-- fs/ocfs2/file.c | 9 ++-- fs/ocfs2/file.h | 11 +++-- fs/ocfs2/namei.c | 19 ++++++--- fs/omfs/dir.c | 13 +++--- fs/omfs/file.c | 3 +- fs/orangefs/acl.c | 3 +- fs/orangefs/inode.c | 10 +++-- fs/orangefs/namei.c | 12 ++++-- fs/orangefs/orangefs-kernel.h | 13 +++--- fs/overlayfs/dir.c | 21 ++++----- fs/overlayfs/inode.c | 10 +++-- fs/overlayfs/overlayfs.h | 9 ++-- fs/overlayfs/super.c | 2 +- fs/posix_acl.c | 9 ++-- fs/proc/base.c | 16 ++++--- fs/proc/fd.c | 3 +- fs/proc/fd.h | 3 +- fs/proc/generic.c | 6 ++- fs/proc/internal.h | 5 ++- fs/proc/proc_net.c | 3 +- fs/proc/proc_sysctl.c | 9 ++-- fs/proc/root.c | 3 +- fs/ramfs/file-nommu.c | 5 ++- fs/ramfs/inode.c | 16 ++++--- fs/reiserfs/acl.h | 3 +- fs/reiserfs/inode.c | 3 +- fs/reiserfs/namei.c | 19 +++++---- fs/reiserfs/reiserfs.h | 3 +- fs/reiserfs/xattr.c | 10 ++--- fs/reiserfs/xattr.h | 3 +- fs/reiserfs/xattr_acl.c | 3 +- fs/stat.c | 8 ++-- fs/sysv/file.c | 3 +- fs/sysv/itree.c | 4 +- fs/sysv/namei.c | 21 +++++---- fs/sysv/sysv.h | 3 +- fs/tracefs/inode.c | 4 +- fs/ubifs/dir.c | 26 ++++++------ fs/ubifs/file.c | 3 +- fs/ubifs/ubifs.h | 5 ++- fs/udf/file.c | 3 +- fs/udf/namei.c | 24 ++++++----- fs/udf/symlink.c | 5 ++- fs/ufs/inode.c | 3 +- fs/ufs/namei.c | 19 +++++---- fs/ufs/ufs.h | 3 +- fs/vboxsf/dir.c | 12 ++++-- fs/vboxsf/utils.c | 7 +-- fs/vboxsf/vfsmod.h | 8 ++-- fs/xfs/xfs_acl.c | 3 +- fs/xfs/xfs_acl.h | 3 +- fs/xfs/xfs_iops.c | 52 +++++++++++++---------- fs/zonefs/super.c | 3 +- include/linux/fs.h | 31 ++++++++------ include/linux/nfs_fs.h | 7 +-- include/linux/posix_acl.h | 2 +- ipc/mqueue.c | 4 +- kernel/bpf/inode.c | 7 +-- mm/shmem.c | 37 ++++++++++------ net/socket.c | 5 ++- security/apparmor/apparmorfs.c | 3 +- security/integrity/evm/evm_secfs.c | 2 +- 183 files changed, 1056 insertions(+), 759 deletions(-)
Documentation/filesystems/vfs.rst +10 -9
@@ -415,28 +415,29 @@ As of kernel 2.6.22, the following members are defined: .. code-block:: c struct inode_operations { - int (*create) (struct inode *,struct dentry *, umode_t, bool); + int (*create) (struct user_namespace *, struct inode *,struct dentry *, umode_t, bool); struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int); int (*link) (struct dentry *,struct inode *,struct dentry *); int (*unlink) (struct inode *,struct dentry *); - int (*symlink) (struct inode *,struct dentry *,const char *); - int (*mkdir) (struct inode *,struct dentry *,umode_t); + int (*symlink) (struct user_namespace *, struct inode *,struct dentry *,const char *); + int (*mkdir) (struct user_namespace *, struct inode *,struct dentry *,umode_t); int (*rmdir) (struct inode *,struct dentry *); - int (*mknod) (struct inode *,struct dentry *,umode_t,dev_t); - int (*rename) (struct inode *, struct dentry *, + int (*mknod) (struct user_namespace *, struct inode *,struct dentry *,umode_t,dev_t); + int (*rename) (struct user_namespace *, struct inode *, struct dentry *, struct inode *, struct dentry *, unsigned int); int (*readlink) (struct dentry *, char __user *,int); const char *(*get_link) (struct dentry *, struct inode *, struct delayed_call *); - int (*permission) (struct inode *, int); + int (*permission) (struct user_namespace *, struct inode *, int); int (*get_acl)(struct inode *, int); - int (*setattr) (struct dentry *, struct iattr *); - int (*getattr) (const struct path *, struct kstat *, u32, unsigned int); + int (*setattr) (struct user_namespace *, struct dentry *, struct iattr *); + int (*getattr) (struct user_namespace *, const struct path *, struct kstat *, u32, unsigned int); ssize_t (*listxattr) (struct dentry *, char *, size_t); void (*update_time)(struct inode *, struct timespec *, int); int (*atomic_open)(struct inode *, struct dentry *, struct file *, unsigned open_flag, umode_t create_mode); - int (*tmpfile) (struct inode *, struct dentry *, umode_t); + int (*tmpfile) (struct user_namespace *, struct inode *, struct dentry *, umode_t); + int (*set_acl)(struct user_namespace *, struct inode *, struct posix_acl *, int); }; Again, all methods are called without any locks being held, unless
arch/powerpc/platforms/cell/spufs/inode.c +2 -1
@@ -91,7 +91,8 @@ spufs_new_inode(struct super_block *sb, umode_t mode) }static int -spufs_setattr (struct dentry *dentry,struct iattr *attr) +spufs_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct inode *inode =d_inode (dentry);
drivers/android/binderfs.c +4 -2
@@ -355,7 +355,8 @@ static inline bool is_binderfs_control_device(const struct dentry *dentry)return info->control_dentry == dentry; } -static int binderfs_rename (struct inode *old_dir,struct dentry *old_dentry, +static int binderfs_rename (struct user_namespace *mnt_userns, +struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry,unsigned int flags) {
@@ -363,7 +364,8 @@ static int binderfs_rename(struct inode *old_dir, struct dentry *old_dentry, is_binderfs_control_device(new_dentry))return -EPERM ; -return simple_rename (old_dir, old_dentry, new_dir, new_dentry, flags); +return simple_rename (&init_user_ns, old_dir, old_dentry, new_dir, + new_dentry, flags); }static int binderfs_unlink (struct inode *dir,struct dentry *dentry)
fs/9p/acl.c +2 -2
@@ -280,7 +280,7 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,struct iattr iattr = {0 };struct posix_acl *old_acl = acl; - retval =posix_acl_update_mode (mnt_userns, inode, + retval =posix_acl_update_mode (&init_user_ns, inode, &iattr.ia_mode, &acl);if (retval) goto err_out;
@@ -299,7 +299,7 @@ static int v9fs_xattr_set_acl(const struct xattr_handler *handler,* What is the following setxattr update the * mode ? */ -v9fs_vfs_setattr_dotl (dentry, &iattr); +v9fs_vfs_setattr_dotl (&init_user_ns, dentry, &iattr); }break ;case ACL_TYPE_DEFAULT :
fs/9p/v9fs.h +2 -1
@@ -135,7 +135,8 @@ extern struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags);extern int v9fs_vfs_unlink (struct inode *i,struct dentry *d);extern int v9fs_vfs_rmdir (struct inode *i,struct dentry *d); -extern int v9fs_vfs_rename (struct inode *old_dir,struct dentry *old_dentry, +extern int v9fs_vfs_rename (struct user_namespace *mnt_userns, +struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry,unsigned int flags); extern struct inode *v9fs_inode_from_fid(struct v9fs_session_info *v9ses,
fs/9p/v9fs_vfs.h +1 -1
@@ -59,7 +59,7 @@ void v9fs_inode2stat(struct inode *inode, struct p9_wstat *stat);int v9fs_uflags2omode (int uflags,int extended);void v9fs_blank_wstat (struct p9_wstat *wstat); -int v9fs_vfs_setattr_dotl (struct dentry *,struct iattr *); +int v9fs_vfs_setattr_dotl (struct user_namespace *,struct dentry *,struct iattr *);int v9fs_file_fsync_dotl (struct file *filp,loff_t start,loff_t end,int datasync);int v9fs_refresh_inode (struct p9_fid *fid,struct inode *inode);
fs/9p/vfs_inode.c +15 -11
@@ -676,8 +676,8 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,*/ static int -v9fs_vfs_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +v9fs_vfs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct v9fs_session_info *v9ses =v9fs_inode2v9ses (dir);u32 perm =unixmode2p9mode (v9ses, mode);
@@ -702,7 +702,8 @@ v9fs_vfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,* */ -static int v9fs_vfs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int v9fs_vfs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {int err;u32 perm;
@@ -907,9 +908,9 @@ int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)*/ int -v9fs_vfs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +v9fs_vfs_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {int retval;struct inode *old_inode;
@@ -1016,8 +1017,8 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry,*/ static int -v9fs_vfs_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int flags) +v9fs_vfs_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int flags) {struct dentry *dentry = path->dentry;struct v9fs_session_info *v9ses;
@@ -1054,7 +1055,8 @@ v9fs_vfs_getattr(const struct path *path, struct kstat *stat,* */ -static int v9fs_vfs_setattr (struct dentry *dentry,struct iattr *iattr) +static int v9fs_vfs_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *iattr) {int retval, use_dentry =0 ;struct v9fs_session_info *v9ses;
@@ -1295,7 +1297,8 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,*/ static int -v9fs_vfs_symlink (struct inode *dir,struct dentry *dentry,const char *symname) +v9fs_vfs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {p9_debug (P9_DEBUG_VFS ," %lu,%pd,%s\n" , dir->i_ino, dentry, symname);
@@ -1348,7 +1351,8 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,*/ static int -v9fs_vfs_mknod (struct inode *dir,struct dentry *dentry,umode_t mode,dev_t rdev) +v9fs_vfs_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {struct v9fs_session_info *v9ses =v9fs_inode2v9ses (dir);int retval;
fs/9p/vfs_inode_dotl.c +17 -14
@@ -33,8 +33,8 @@#include "acl.h" static int -v9fs_vfs_mknod_dotl (struct inode *dir,struct dentry *dentry,umode_t omode, -dev_t rdev); +v9fs_vfs_mknod_dotl (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t omode,dev_t rdev);/** * v9fs_get_fsgid_for_create - Helper function to get the gid for creating a
@@ -218,10 +218,10 @@ int v9fs_open_to_dotl_flags(int flags)*/ static int -v9fs_vfs_create_dotl (struct inode *dir,struct dentry *dentry,umode_t omode, -bool excl) +v9fs_vfs_create_dotl (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t omode,bool excl) { -return v9fs_vfs_mknod_dotl (dir, dentry, omode,0 ); +return v9fs_vfs_mknod_dotl (mnt_userns, dir, dentry, omode,0 ); } static int
@@ -367,8 +367,9 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,* */ -static int v9fs_vfs_mkdir_dotl (struct inode *dir, -struct dentry *dentry,umode_t omode) +static int v9fs_vfs_mkdir_dotl (struct user_namespace *mnt_userns, +struct inode *dir,struct dentry *dentry, +umode_t omode) {int err;struct v9fs_session_info *v9ses;
@@ -457,8 +458,9 @@ static int v9fs_vfs_mkdir_dotl(struct inode *dir, }static int -v9fs_vfs_getattr_dotl (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int flags) +v9fs_vfs_getattr_dotl (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat, +u32 request_mask,unsigned int flags) {struct dentry *dentry = path->dentry;struct v9fs_session_info *v9ses;
@@ -540,7 +542,8 @@ static int v9fs_mapped_iattr_valid(int iattr_valid)* */ -int v9fs_vfs_setattr_dotl (struct dentry *dentry,struct iattr *iattr) +int v9fs_vfs_setattr_dotl (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *iattr) {int retval, use_dentry =0 ;struct p9_fid *fid =NULL ;
@@ -684,8 +687,8 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode, }static int -v9fs_vfs_symlink_dotl (struct inode *dir,struct dentry *dentry, -const char *symname) +v9fs_vfs_symlink_dotl (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {int err;kgid_t gid;
@@ -824,8 +827,8 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,* */ static int -v9fs_vfs_mknod_dotl (struct inode *dir,struct dentry *dentry,umode_t omode, -dev_t rdev) +v9fs_vfs_mknod_dotl (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t omode,dev_t rdev) {int err;kgid_t gid;
fs/adfs/adfs.h +2 -1
@@ -144,7 +144,8 @@ struct adfs_discmap {/* Inode stuff */ struct inode *adfs_iget (struct super_block *sb,struct object_info *obj);int adfs_write_inode (struct inode *inode,struct writeback_control *wbc); -int adfs_notify_change (struct dentry *dentry,struct iattr *attr); +int adfs_notify_change (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr);/* map.c */ int adfs_map_lookup (struct super_block *sb,u32 frag_id,unsigned int offset);
fs/adfs/inode.c +2 -1
@@ -292,7 +292,8 @@ adfs_iget(struct super_block *sb, struct object_info *obj)* later. */ int -adfs_notify_change (struct dentry *dentry,struct iattr *attr) +adfs_notify_change (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct inode *inode =d_inode (dentry);struct super_block *sb = inode->i_sb;
fs/affs/affs.h +5 -5
@@ -167,21 +167,21 @@ extern const struct export_operations affs_export_ops;extern int affs_hash_name (struct super_block *sb,const u8 *name,unsigned int len);extern struct dentry *affs_lookup (struct inode *dir,struct dentry *dentry,unsigned int );extern int affs_unlink (struct inode *dir,struct dentry *dentry); -extern int affs_create (struct inode *dir,struct dentry *dentry,umode_t mode,bool ); -extern int affs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode); +extern int affs_create (struct user_namespace *mnt_userns,struct inode *dir,struct dentry *dentry,umode_t mode,bool ); +extern int affs_mkdir (struct user_namespace *mnt_userns,struct inode *dir,struct dentry *dentry,umode_t mode);extern int affs_rmdir (struct inode *dir,struct dentry *dentry);extern int affs_link (struct dentry *olddentry,struct inode *dir,struct dentry *dentry); -extern int affs_symlink (struct inode *dir,struct dentry *dentry, +extern int affs_symlink (struct user_namespace *mnt_userns,struct inode *dir,struct dentry *dentry,const char *symname); -extern int affs_rename2 (struct inode *old_dir,struct dentry *old_dentry, +extern int affs_rename2 (struct user_namespace *mnt_userns,struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry,unsigned int flags);/* inode.c */ extern struct inode *affs_new_inode (struct inode *dir); -extern int affs_notify_change (struct dentry *dentry,struct iattr *attr); +extern int affs_notify_change (struct user_namespace *mnt_userns,struct dentry *dentry,struct iattr *attr);extern void affs_evict_inode (struct inode *inode);extern struct inode *affs_iget (struct super_block *sb,unsigned long ino);
fs/affs/inode.c +2 -1
@@ -216,7 +216,8 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc) }int -affs_notify_change (struct dentry *dentry,struct iattr *attr) +affs_notify_change (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct inode *inode =d_inode (dentry);int error;
fs/affs/namei.c +9 -6
@@ -242,7 +242,8 @@ affs_unlink(struct inode *dir, struct dentry *dentry) }int -affs_create (struct inode *dir,struct dentry *dentry,umode_t mode,bool excl) +affs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct super_block *sb = dir->i_sb;struct inode *inode;
@@ -273,7 +274,8 @@ affs_create(struct inode *dir, struct dentry *dentry, umode_t mode, bool excl) }int -affs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +affs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct inode *inode;int error;
@@ -311,7 +313,8 @@ affs_rmdir(struct inode *dir, struct dentry *dentry) }int -affs_symlink (struct inode *dir,struct dentry *dentry,const char *symname) +affs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {struct super_block *sb = dir->i_sb;struct buffer_head *bh;
@@ -498,9 +501,9 @@ affs_xrename(struct inode *old_dir, struct dentry *old_dentry,return retval; } -int affs_rename2 (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +int affs_rename2 (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {if (flags & ~(RENAME_NOREPLACE |RENAME_EXCHANGE ))
fs/afs/dir.c +18 -16
@@ -28,18 +28,19 @@ static int afs_lookup_one_filldir(struct dir_context *ctx, const char *name, int loff_t fpos, u64 ino, unsigned dtype);static int afs_lookup_filldir (struct dir_context *ctx,const char *name,int nlen,loff_t fpos,u64 ino,unsigned dtype); -static int afs_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl); -static int afs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode); +static int afs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl); +static int afs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode);static int afs_rmdir (struct inode *dir,struct dentry *dentry);static int afs_unlink (struct inode *dir,struct dentry *dentry);static int afs_link (struct dentry *from,struct inode *dir,struct dentry *dentry); -static int afs_symlink (struct inode *dir,struct dentry *dentry, -const char *content); -static int afs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags); +static int afs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *content); +static int afs_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags);static int afs_dir_releasepage (struct page *page,gfp_t gfp_flags);static void afs_dir_invalidatepage (struct page *page,unsigned int offset,unsigned int length);
@@ -1325,7 +1326,8 @@ static const struct afs_operation_ops afs_mkdir_operation = {/* * create a directory on an AFS filesystem */ -static int afs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int afs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct afs_operation *op;struct afs_vnode *dvnode =AFS_FS_I (dir);
@@ -1619,8 +1621,8 @@ static const struct afs_operation_ops afs_create_operation = {/* * create a regular file on an AFS filesystem */ -static int afs_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int afs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct afs_operation *op;struct afs_vnode *dvnode =AFS_FS_I (dir);
@@ -1741,8 +1743,8 @@ static const struct afs_operation_ops afs_symlink_operation = {/* * create a symlink in an AFS filesystem */ -static int afs_symlink (struct inode *dir,struct dentry *dentry, -const char *content) +static int afs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *content) {struct afs_operation *op;struct afs_vnode *dvnode =AFS_FS_I (dir);
@@ -1876,9 +1878,9 @@ static const struct afs_operation_ops afs_rename_operation = {/* * rename a file in an AFS filesystem and/or move it between directories */ -static int afs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int afs_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {struct afs_operation *op;struct afs_vnode *orig_dvnode, *new_dvnode, *vnode;
fs/afs/inode.c +4 -3
@@ -734,8 +734,8 @@ int afs_validate(struct afs_vnode *vnode, struct key *key)/* * read the attributes of an inode */ -int afs_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int query_flags) +int afs_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int query_flags) {struct inode *inode =d_inode (path->dentry);struct afs_vnode *vnode =AFS_FS_I (inode);
@@ -857,7 +857,8 @@ static const struct afs_operation_ops afs_setattr_operation = {/* * set the attributes of an inode */ -int afs_setattr (struct dentry *dentry,struct iattr *attr) +int afs_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct afs_operation *op;struct afs_vnode *vnode =AFS_FS_I (d_inode (dentry));
fs/afs/internal.h +4 -3
@@ -1149,8 +1149,9 @@ extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);extern struct inode *afs_root_iget (struct super_block *,struct key *);extern bool afs_check_validity (struct afs_vnode *);extern int afs_validate (struct afs_vnode *,struct key *); -extern int afs_getattr (const struct path *,struct kstat *,u32 ,unsigned int ); -extern int afs_setattr (struct dentry *,struct iattr *); +extern int afs_getattr (struct user_namespace *mnt_userns,const struct path *, +struct kstat *,u32 ,unsigned int ); +extern int afs_setattr (struct user_namespace *mnt_userns,struct dentry *,struct iattr *);extern void afs_evict_inode (struct inode *);extern int afs_drop_inode (struct inode *);
@@ -1361,7 +1362,7 @@ extern void afs_zap_permits(struct rcu_head *);extern struct key *afs_request_key (struct afs_cell *);extern struct key *afs_request_key_rcu (struct afs_cell *);extern int afs_check_permit (struct afs_vnode *,struct key *,afs_access_t *); -extern int afs_permission (struct inode *,int ); +extern int afs_permission (struct user_namespace *,struct inode *,int ); extern void __exit afs_clean_up_permit_cache(void);/*
fs/afs/security.c +1 -1
@@ -396,7 +396,7 @@ int afs_check_permit(struct afs_vnode *vnode, struct key *key,* - AFS ACLs are attached to directories only, and a file is controlled by its * parent directory's ACL */ -int afs_permission (struct inode *inode,int mask) +int afs_permission (struct user_namespace *mnt_userns,struct inode *inode,int mask) {struct afs_vnode *vnode =AFS_FS_I (inode);afs_access_t access;
fs/attr.c +2 -2
@@ -393,9 +393,9 @@ int notify_change(struct user_namespace *mnt_userns, struct dentry *dentry,return error;if (inode->i_op->setattr) - error = inode->i_op->setattr (dentry, attr); + error = inode->i_op->setattr (mnt_userns, dentry, attr);else - error =simple_setattr (dentry, attr); + error =simple_setattr (mnt_userns, dentry, attr);if (!error) {fsnotify_change (dentry, ia_valid);
fs/autofs/root.c +7 -6
@@ -10,10 +10,12 @@#include "autofs_i.h" -static int autofs_dir_symlink (struct inode *,struct dentry *,const char *); +static int autofs_dir_symlink (struct user_namespace *,struct inode *, +struct dentry *,const char *);static int autofs_dir_unlink (struct inode *,struct dentry *);static int autofs_dir_rmdir (struct inode *,struct dentry *); -static int autofs_dir_mkdir (struct inode *,struct dentry *,umode_t ); +static int autofs_dir_mkdir (struct user_namespace *,struct inode *, +struct dentry *,umode_t );static long autofs_root_ioctl (struct file *,unsigned int ,unsigned long );#ifdef CONFIG_COMPAT static long autofs_root_compat_ioctl(struct file *,
@@ -524,9 +526,8 @@ static struct dentry *autofs_lookup(struct inode *dir,return NULL ; } -static int autofs_dir_symlink (struct inode *dir, -struct dentry *dentry, -const char *symname) +static int autofs_dir_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {struct autofs_sb_info *sbi =autofs_sbi (dir->i_sb);struct autofs_info *ino =autofs_dentry_ino (dentry);
@@ -715,7 +716,7 @@ static int autofs_dir_rmdir(struct inode *dir, struct dentry *dentry)return 0 ; } -static int autofs_dir_mkdir (struct inode *dir, +static int autofs_dir_mkdir (struct user_namespace *mnt_userns,struct inode *dir,struct dentry *dentry,umode_t mode) {struct autofs_sb_info *sbi =autofs_sbi (dir->i_sb);
fs/bad_inode.c +22 -14
@@ -27,8 +27,9 @@ static const struct file_operations bad_file_ops = .open = bad_file_open, }; -static int bad_inode_create (struct inode *dir,struct dentry *dentry, -umode_t mode,bool excl) +static int bad_inode_create (struct user_namespace *mnt_userns, +struct inode *dir,struct dentry *dentry, +umode_t mode,bool excl) {return -EIO ; }
@@ -50,14 +51,15 @@ static int bad_inode_unlink(struct inode *dir, struct dentry *dentry)return -EIO ; } -static int bad_inode_symlink (struct inode *dir,struct dentry *dentry, -const char *symname) +static int bad_inode_symlink (struct user_namespace *mnt_userns, +struct inode *dir,struct dentry *dentry, +const char *symname) {return -EIO ; } -static int bad_inode_mkdir (struct inode *dir,struct dentry *dentry, -umode_t mode) +static int bad_inode_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {return -EIO ; }
@@ -67,13 +69,14 @@ static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)return -EIO ; } -static int bad_inode_mknod (struct inode *dir,struct dentry *dentry, -umode_t mode,dev_t rdev) +static int bad_inode_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {return -EIO ; } -static int bad_inode_rename2 (struct inode *old_dir,struct dentry *old_dentry, +static int bad_inode_rename2 (struct user_namespace *mnt_userns, +struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry,unsigned int flags) {
@@ -86,18 +89,21 @@ static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,return -EIO ; } -static int bad_inode_permission (struct inode *inode,int mask) +static int bad_inode_permission (struct user_namespace *mnt_userns, +struct inode *inode,int mask) {return -EIO ; } -static int bad_inode_getattr (const struct path *path,struct kstat *stat, +static int bad_inode_getattr (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int query_flags) {return -EIO ; } -static int bad_inode_setattr (struct dentry *direntry,struct iattr *attrs) +static int bad_inode_setattr (struct user_namespace *mnt_userns, +struct dentry *direntry,struct iattr *attrs) {return -EIO ; }
@@ -140,13 +146,15 @@ static int bad_inode_atomic_open(struct inode *inode, struct dentry *dentry,return -EIO ; } -static int bad_inode_tmpfile (struct inode *inode,struct dentry *dentry, +static int bad_inode_tmpfile (struct user_namespace *mnt_userns, +struct inode *inode,struct dentry *dentry,umode_t mode) {return -EIO ; } -static int bad_inode_set_acl (struct inode *inode,struct posix_acl *acl, +static int bad_inode_set_acl (struct user_namespace *mnt_userns, +struct inode *inode,struct posix_acl *acl,int type) {return -EIO ;
fs/bfs/dir.c +5 -5
@@ -75,8 +75,8 @@ const struct file_operations bfs_dir_operations = { .llseek = generic_file_llseek, }; -static int bfs_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int bfs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {int err;struct inode *inode;
@@ -199,9 +199,9 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)return error; } -static int bfs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int bfs_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {struct inode *old_inode, *new_inode;struct buffer_head *old_bh, *new_bh;
fs/btrfs/acl.c +2 -1
@@ -107,7 +107,8 @@ static int __btrfs_set_acl(struct btrfs_trans_handle *trans,return ret; } -int btrfs_set_acl (struct inode *inode,struct posix_acl *acl,int type) +int btrfs_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type) {int ret;umode_t old_mode = inode->i_mode;
fs/btrfs/ctree.h +2 -1
@@ -3625,7 +3625,8 @@ static inline int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag)/* acl.c */ #ifdef CONFIG_BTRFS_FS_POSIX_ACL struct posix_acl *btrfs_get_acl (struct inode *inode,int type); -int btrfs_set_acl (struct inode *inode,struct posix_acl *acl,int type); +int btrfs_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type);int btrfs_init_acl (struct btrfs_trans_handle *trans,struct inode *inode,struct inode *dir);#else
fs/btrfs/inode.c +19 -14
@@ -5045,7 +5045,8 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)return ret; } -static int btrfs_setattr (struct dentry *dentry,struct iattr *attr) +static int btrfs_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct inode *inode =d_inode (dentry);struct btrfs_root *root =BTRFS_I (inode)->root;
@@ -6351,8 +6352,8 @@ static int btrfs_add_nondir(struct btrfs_trans_handle *trans,return err; } -static int btrfs_mknod (struct inode *dir,struct dentry *dentry, -umode_t mode,dev_t rdev) +static int btrfs_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {struct btrfs_fs_info *fs_info =btrfs_sb (dir->i_sb);struct btrfs_trans_handle *trans;
@@ -6415,8 +6416,8 @@ static int btrfs_mknod(struct inode *dir, struct dentry *dentry,return err; } -static int btrfs_create (struct inode *dir,struct dentry *dentry, -umode_t mode,bool excl) +static int btrfs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct btrfs_fs_info *fs_info =btrfs_sb (dir->i_sb);struct btrfs_trans_handle *trans;
@@ -6560,7 +6561,8 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,return err; } -static int btrfs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int btrfs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct btrfs_fs_info *fs_info =btrfs_sb (dir->i_sb);struct inode *inode =NULL ;
@@ -8815,7 +8817,8 @@ int __init btrfs_init_cachep(void)return -ENOMEM ; } -static int btrfs_getattr (const struct path *path,struct kstat *stat, +static int btrfs_getattr (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags) {u64 delalloc_bytes;
@@ -9332,9 +9335,9 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,return ret; } -static int btrfs_rename2 (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int btrfs_rename2 (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {if (flags & ~(RENAME_NOREPLACE |RENAME_EXCHANGE |RENAME_WHITEOUT ))return -EINVAL ;
@@ -9516,8 +9519,8 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, u64 nr,return ret; } -static int btrfs_symlink (struct inode *dir,struct dentry *dentry, -const char *symname) +static int btrfs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {struct btrfs_fs_info *fs_info =btrfs_sb (dir->i_sb);struct btrfs_trans_handle *trans;
@@ -9851,7 +9854,8 @@ static int btrfs_set_page_dirty(struct page *page)return __set_page_dirty_nobuffers (page); } -static int btrfs_permission (struct inode *inode,int mask) +static int btrfs_permission (struct user_namespace *mnt_userns, +struct inode *inode,int mask) {struct btrfs_root *root =BTRFS_I (inode)->root;umode_t mode = inode->i_mode;
@@ -9866,7 +9870,8 @@ static int btrfs_permission(struct inode *inode, int mask)return generic_permission (&init_user_ns, inode, mask); } -static int btrfs_tmpfile (struct inode *dir,struct dentry *dentry,umode_t mode) +static int btrfs_tmpfile (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct btrfs_fs_info *fs_info =btrfs_sb (dir->i_sb);struct btrfs_trans_handle *trans;
fs/ceph/acl.c +2 -1
@@ -82,7 +82,8 @@ struct posix_acl *ceph_get_acl(struct inode *inode, int type)return acl; } -int ceph_set_acl (struct inode *inode,struct posix_acl *acl,int type) +int ceph_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type) {int ret =0 , size =0 ;const char *name =NULL ;
fs/ceph/dir.c +12 -11
@@ -823,8 +823,8 @@ int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)return PTR_ERR (result); } -static int ceph_mknod (struct inode *dir,struct dentry *dentry, -umode_t mode,dev_t rdev) +static int ceph_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {struct ceph_mds_client *mdsc =ceph_sb_to_mdsc (dir->i_sb);struct ceph_mds_request *req;
@@ -878,14 +878,14 @@ static int ceph_mknod(struct inode *dir, struct dentry *dentry,return err; } -static int ceph_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int ceph_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) { -return ceph_mknod (dir, dentry, mode,0 ); +return ceph_mknod (mnt_userns, dir, dentry, mode,0 ); } -static int ceph_symlink (struct inode *dir,struct dentry *dentry, -const char *dest) +static int ceph_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *dest) {struct ceph_mds_client *mdsc =ceph_sb_to_mdsc (dir->i_sb);struct ceph_mds_request *req;
@@ -937,7 +937,8 @@ static int ceph_symlink(struct inode *dir, struct dentry *dentry,return err; } -static int ceph_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int ceph_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct ceph_mds_client *mdsc =ceph_sb_to_mdsc (dir->i_sb);struct ceph_mds_request *req;
@@ -1183,9 +1184,9 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry)return err; } -static int ceph_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int ceph_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {struct ceph_mds_client *mdsc =ceph_sb_to_mdsc (old_dir->i_sb);struct ceph_mds_request *req;
fs/ceph/inode.c +5 -4
@@ -2238,7 +2238,8 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)/* * setattr */ -int ceph_setattr (struct dentry *dentry,struct iattr *attr) +int ceph_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct inode *inode =d_inode (dentry);struct ceph_fs_client *fsc =ceph_inode_to_client (inode);
@@ -2321,7 +2322,7 @@ int __ceph_do_getattr(struct inode *inode, struct page *locked_page,* Check inode permissions. We verify we have a valid value for * the AUTH cap, then call the generic handler. */ -int ceph_permission (struct inode *inode,int mask) +int ceph_permission (struct user_namespace *mnt_userns,struct inode *inode,int mask) {int err;
@@ -2368,8 +2369,8 @@ static int statx_to_caps(u32 want, umode_t mode)* Get all the attributes. If we have sufficient caps for the requested attrs, * then we can avoid talking to the MDS at all. */ -int ceph_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int flags) +int ceph_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int flags) {struct inode *inode =d_inode (path->dentry);struct ceph_inode_info *ci =ceph_inode (inode);
fs/ceph/super.h +8 -4
@@ -973,10 +973,13 @@ static inline int ceph_do_getattr(struct inode *inode, int mask, bool force) {return __ceph_do_getattr (inode,NULL , mask, force); } -extern int ceph_permission (struct inode *inode,int mask); +extern int ceph_permission (struct user_namespace *mnt_userns, +struct inode *inode,int mask);extern int __ceph_setattr (struct inode *inode,struct iattr *attr); -extern int ceph_setattr (struct dentry *dentry,struct iattr *attr); -extern int ceph_getattr (const struct path *path,struct kstat *stat, +extern int ceph_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *attr); +extern int ceph_getattr (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags);/* xattr.c */
@@ -1037,7 +1040,8 @@ void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx);#ifdef CONFIG_CEPH_FS_POSIX_ACL struct posix_acl *ceph_get_acl (struct inode *,int ); -int ceph_set_acl (struct inode *inode,struct posix_acl *acl,int type); +int ceph_set_acl (struct user_namespace *mnt_userns, +struct inode *inode,struct posix_acl *acl,int type);int ceph_pre_init_acls (struct inode *dir,umode_t *mode,struct ceph_acl_sec_ctx *as_ctx); void ceph_init_inode_acls(struct inode *inode,
fs/cifs/cifsfs.c +1 -1
@@ -305,7 +305,7 @@ static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)return -EOPNOTSUPP ; } -static int cifs_permission (struct inode *inode,int mask) +static int cifs_permission (struct user_namespace *mnt_userns,struct inode *inode,int mask) {struct cifs_sb_info *cifs_sb;
fs/cifs/cifsfs.h +11 -10
@@ -62,19 +62,19 @@ extern void cifs_sb_deactive(struct super_block *sb);/* Functions related to inodes */ extern const struct inode_operations cifs_dir_inode_ops;extern struct inode *cifs_root_iget (struct super_block *); -extern int cifs_create (struct inode *,struct dentry *,umode_t , -bool excl); +extern int cifs_create (struct user_namespace *,struct inode *, +struct dentry *,umode_t ,bool excl);extern int cifs_atomic_open (struct inode *,struct dentry *,struct file *,unsigned ,umode_t );extern struct dentry *cifs_lookup (struct inode *,struct dentry *,unsigned int );extern int cifs_unlink (struct inode *dir,struct dentry *dentry);extern int cifs_hardlink (struct dentry *,struct inode *,struct dentry *); -extern int cifs_mknod (struct inode *,struct dentry *,umode_t ,dev_t ); -extern int cifs_mkdir (struct inode *,struct dentry *,umode_t ); +extern int cifs_mknod (struct user_namespace *,struct inode *,struct dentry *,umode_t ,dev_t ); +extern int cifs_mkdir (struct user_namespace *,struct inode *,struct dentry *,umode_t );extern int cifs_rmdir (struct inode *,struct dentry *); -extern int cifs_rename2 (struct inode *,struct dentry *,struct inode *, -struct dentry *,unsigned int ); +extern int cifs_rename2 (struct user_namespace *,struct inode *, +struct dentry *,struct inode *,struct dentry *,unsigned int );extern int cifs_revalidate_file_attr (struct file *filp);extern int cifs_revalidate_dentry_attr (struct dentry *);extern int cifs_revalidate_file (struct file *filp);
@@ -82,8 +82,9 @@ extern int cifs_revalidate_dentry(struct dentry *);extern int cifs_invalidate_mapping (struct inode *inode);extern int cifs_revalidate_mapping (struct inode *inode);extern int cifs_zap_mapping (struct inode *inode); -extern int cifs_getattr (const struct path *,struct kstat *,u32 ,unsigned int ); -extern int cifs_setattr (struct dentry *,struct iattr *); +extern int cifs_getattr (struct user_namespace *,const struct path *, +struct kstat *,u32 ,unsigned int ); +extern int cifs_setattr (struct user_namespace *,struct dentry *,struct iattr *);extern int cifs_fiemap (struct inode *,struct fiemap_extent_info *,u64 start,u64 len);
@@ -132,8 +133,8 @@ extern struct vfsmount *cifs_dfs_d_automount(struct path *path);/* Functions related to symlinks */ extern const char *cifs_get_link (struct dentry *,struct inode *,struct delayed_call *); -extern int cifs_symlink (struct inode *inode,struct dentry *direntry, -const char *symname); +extern int cifs_symlink (struct user_namespace *mnt_userns,struct inode *inode, +struct dentry *direntry,const char *symname);#ifdef CONFIG_CIFS_XATTR extern const struct xattr_handler *cifs_xattr_handlers[];
fs/cifs/dir.c +4 -4
@@ -567,8 +567,8 @@ cifs_atomic_open(struct inode *inode, struct dentry *direntry,return rc; } -int cifs_create (struct inode *inode,struct dentry *direntry,umode_t mode, -bool excl) +int cifs_create (struct user_namespace *mnt_userns,struct inode *inode, +struct dentry *direntry,umode_t mode,bool excl) {int rc;unsigned int xid =get_xid ();
@@ -611,8 +611,8 @@ int cifs_create(struct inode *inode, struct dentry *direntry, umode_t mode,return rc; } -int cifs_mknod (struct inode *inode,struct dentry *direntry,umode_t mode, -dev_t device_number) +int cifs_mknod (struct user_namespace *mnt_userns,struct inode *inode, +struct dentry *direntry,umode_t mode,dev_t device_number) {int rc = -EPERM ;unsigned int xid;
fs/cifs/inode.c +9 -7
@@ -1857,7 +1857,8 @@ cifs_posix_mkdir(struct inode *inode, struct dentry *dentry, umode_t mode, goto posix_mkdir_out; } -int cifs_mkdir (struct inode *inode,struct dentry *direntry,umode_t mode) +int cifs_mkdir (struct user_namespace *mnt_userns,struct inode *inode, +struct dentry *direntry,umode_t mode) {int rc =0 ;unsigned int xid;
@@ -2067,9 +2068,9 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry, }int -cifs_rename2 (struct inode *source_dir,struct dentry *source_dentry, -struct inode *target_dir,struct dentry *target_dentry, -unsigned int flags) +cifs_rename2 (struct user_namespace *mnt_userns,struct inode *source_dir, +struct dentry *source_dentry,struct inode *target_dir, +struct dentry *target_dentry,unsigned int flags) {char *from_name =NULL ;char *to_name =NULL ;
@@ -2370,8 +2371,8 @@ int cifs_revalidate_dentry(struct dentry *dentry)return cifs_revalidate_mapping (inode); } -int cifs_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int flags) +int cifs_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int flags) {struct dentry *dentry = path->dentry;struct cifs_sb_info *cifs_sb =CIFS_SB (dentry->d_sb);
@@ -2923,7 +2924,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) }int -cifs_setattr (struct dentry *direntry,struct iattr *attrs) +cifs_setattr (struct user_namespace *mnt_userns,struct dentry *direntry, +struct iattr *attrs) {struct cifs_sb_info *cifs_sb =CIFS_SB (direntry->d_sb);struct cifs_tcon *pTcon =cifs_sb_master_tcon (cifs_sb);
fs/cifs/link.c +2 -1
@@ -661,7 +661,8 @@ cifs_get_link(struct dentry *direntry, struct inode *inode, }int -cifs_symlink (struct inode *inode,struct dentry *direntry,const char *symname) +cifs_symlink (struct user_namespace *mnt_userns,struct inode *inode, +struct dentry *direntry,const char *symname) {int rc = -EOPNOTSUPP ;unsigned int xid;
fs/coda/coda_linux.h +3 -3
@@ -46,10 +46,10 @@ extern const struct file_operations coda_ioctl_operations;/* operations shared over more than one file */ int coda_open (struct inode *i,struct file *f);int coda_release (struct inode *i,struct file *f); -int coda_permission (struct inode *inode,int mask); +int coda_permission (struct user_namespace *mnt_userns,struct inode *inode,int mask);int coda_revalidate_inode (struct inode *); -int coda_getattr (const struct path *,struct kstat *,u32 ,unsigned int ); -int coda_setattr (struct dentry *,struct iattr *); +int coda_getattr (struct user_namespace *,const struct path *,struct kstat *,u32 ,unsigned int ); +int coda_setattr (struct user_namespace *,struct dentry *,struct iattr *);/* this file: heloers */ char *coda_f2s (struct CodaFid *f);
fs/coda/dir.c +10 -7
@@ -73,7 +73,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, unsig } -int coda_permission (struct inode *inode,int mask) +int coda_permission (struct user_namespace *mnt_userns,struct inode *inode,int mask) {int error;
@@ -132,7 +132,8 @@ static inline void coda_dir_drop_nlink(struct inode *dir) }/* creation routines: create, mknod, mkdir, link, symlink */ -static int coda_create (struct inode *dir,struct dentry *de,umode_t mode,bool excl) +static int coda_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *de,umode_t mode,bool excl) {int error;const char *name=de->d_name.name;
@@ -164,7 +165,8 @@ static int coda_create(struct inode *dir, struct dentry *de, umode_t mode, boolreturn error; } -static int coda_mkdir (struct inode *dir,struct dentry *de,umode_t mode) +static int coda_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *de,umode_t mode) {struct inode *inode;struct coda_vattr attrs;
@@ -225,7 +227,8 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode, } -static int coda_symlink (struct inode *dir_inode,struct dentry *de, +static int coda_symlink (struct user_namespace *mnt_userns, +struct inode *dir_inode,struct dentry *de,const char *symname) {const char *name = de->d_name.name;
@@ -291,9 +294,9 @@ static int coda_rmdir(struct inode *dir, struct dentry *de) }/* rename */ -static int coda_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int coda_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {const char *old_name = old_dentry->d_name.name;const char *new_name = new_dentry->d_name.name;
fs/coda/inode.c +4 -3
@@ -251,8 +251,8 @@ static void coda_evict_inode(struct inode *inode)coda_cache_clear_inode (inode); } -int coda_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int flags) +int coda_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int flags) {int err =coda_revalidate_inode (d_inode (path->dentry));if (!err)
@@ -260,7 +260,8 @@ int coda_getattr(const struct path *path, struct kstat *stat,return err; } -int coda_setattr (struct dentry *de,struct iattr *iattr) +int coda_setattr (struct user_namespace *mnt_userns,struct dentry *de, +struct iattr *iattr) {struct inode *inode =d_inode (de);struct coda_vattr vattr;
fs/coda/pioctl.c +4 -2
@@ -24,7 +24,8 @@#include "coda_linux.h" /* pioctl ops */ -static int coda_ioctl_permission (struct inode *inode,int mask); +static int coda_ioctl_permission (struct user_namespace *mnt_userns, +struct inode *inode,int mask);static long coda_pioctl (struct file *filp,unsigned int cmd,unsigned long user_data);
@@ -40,7 +41,8 @@ const struct file_operations coda_ioctl_operations = { };/* the coda pioctl inode ops */ -static int coda_ioctl_permission (struct inode *inode,int mask) +static int coda_ioctl_permission (struct user_namespace *mnt_userns, +struct inode *inode,int mask) {return (mask &MAY_EXEC ) ? -EACCES :0 ; }
fs/configfs/configfs_internal.h +4 -3
@@ -79,7 +79,8 @@ extern void configfs_hash_and_remove(struct dentry * dir, const char * name);extern const unsigned char *configfs_get_name (struct configfs_dirent *sd);extern void configfs_drop_dentry (struct configfs_dirent *sd,struct dentry *parent); -extern int configfs_setattr (struct dentry *dentry,struct iattr *iattr); +extern int configfs_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *iattr);extern struct dentry *configfs_pin_fs (void );extern void configfs_release_fs (void );
@@ -92,8 +93,8 @@ extern const struct inode_operations configfs_root_inode_operations;extern const struct inode_operations configfs_symlink_inode_operations;extern const struct dentry_operations configfs_dentry_ops; -extern int configfs_symlink (struct inode *dir,struct dentry *dentry, -const char *symname); +extern int configfs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname);extern int configfs_unlink (struct inode *dir,struct dentry *dentry); int configfs_create_link(struct configfs_dirent *target, struct dentry *parent,
fs/configfs/dir.c +2 -1
@@ -1268,7 +1268,8 @@ int configfs_depend_item_unlocked(struct configfs_subsystem *caller_subsys, }EXPORT_SYMBOL (configfs_depend_item_unlocked); -static int configfs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int configfs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {int ret =0 ;int module_got =0 ;
fs/configfs/inode.c +3 -2
@@ -40,7 +40,8 @@ static const struct inode_operations configfs_inode_operations ={ .setattr = configfs_setattr, }; -int configfs_setattr (struct dentry * dentry,struct iattr * iattr) +int configfs_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *iattr) {struct inode * inode =d_inode (dentry);struct configfs_dirent * sd = dentry->d_fsdata;
@@ -67,7 +68,7 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr) }/* attributes were changed atleast once in past */ - error =simple_setattr (dentry, iattr); + error =simple_setattr (mnt_userns, dentry, iattr);if (error)return error;
fs/configfs/symlink.c +2 -1
@@ -139,7 +139,8 @@ static int get_target(const char *symname, struct path *path, } -int configfs_symlink (struct inode *dir,struct dentry *dentry,const char *symname) +int configfs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {int ret;struct path path;
fs/debugfs/inode.c +5 -4
@@ -42,13 +42,14 @@ static unsigned int debugfs_allow = DEFAULT_DEBUGFS_ALLOW_BITS;* so that we can use the file mode as part of a heuristic to determine whether * to lock down individual files. */ -static int debugfs_setattr (struct dentry *dentry,struct iattr *ia) +static int debugfs_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *ia) {int ret =security_locked_down (LOCKDOWN_DEBUGFS );if (ret && (ia->ia_valid & (ATTR_MODE |ATTR_UID |ATTR_GID )))return ret; -return simple_setattr (dentry, ia); +return simple_setattr (&init_user_ns, dentry, ia); }static const struct inode_operations debugfs_file_inode_operations = {
@@ -775,8 +776,8 @@ struct dentry *debugfs_rename(struct dentry *old_dir, struct dentry *old_dentry,take_dentry_name_snapshot (&old_name, old_dentry); - error =simple_rename (d_inode (old_dir), old_dentry,d_inode (new_dir), - dentry,0 ); + error =simple_rename (&init_user_ns,d_inode (old_dir), old_dentry, +d_inode (new_dir), dentry,0 );if (error) {release_dentry_name_snapshot (&old_name); goto exit;
fs/ecryptfs/inode.c +18 -13
@@ -255,8 +255,8 @@ int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,* Returns zero on success; non-zero on error condition */ static int -ecryptfs_create (struct inode *directory_inode,struct dentry *ecryptfs_dentry, -umode_t mode,bool excl) +ecryptfs_create (struct user_namespace *mnt_userns,struct inode *directory_inode, +struct dentry *ecryptfs_dentry,umode_t mode,bool excl) {struct inode *ecryptfs_inode;int rc;
@@ -461,8 +461,8 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)return ecryptfs_do_unlink (dir, dentry,d_inode (dentry)); } -static int ecryptfs_symlink (struct inode *dir,struct dentry *dentry, -const char *symname) +static int ecryptfs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {int rc;struct dentry *lower_dentry;
@@ -500,7 +500,8 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,return rc; } -static int ecryptfs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int ecryptfs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {int rc;struct dentry *lower_dentry;
@@ -556,7 +557,8 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry) }static int -ecryptfs_mknod (struct inode *dir,struct dentry *dentry,umode_t mode,dev_t dev) +ecryptfs_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t dev) {int rc;struct dentry *lower_dentry;
@@ -581,9 +583,9 @@ ecryptfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev }static int -ecryptfs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +ecryptfs_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {int rc;struct dentry *lower_old_dentry;
@@ -870,7 +872,7 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length) }static int -ecryptfs_permission (struct inode *inode,int mask) +ecryptfs_permission (struct user_namespace *mnt_userns,struct inode *inode,int mask) {return inode_permission (&init_user_ns,ecryptfs_inode_to_lower (inode), mask); }
@@ -887,7 +889,8 @@ ecryptfs_permission(struct inode *inode, int mask)* All other metadata changes will be passed right to the lower filesystem, * and we will just update our inode to look like the lower. */ -static int ecryptfs_setattr (struct dentry *dentry,struct iattr *ia) +static int ecryptfs_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *ia) {int rc =0 ;struct dentry *lower_dentry;
@@ -974,7 +977,8 @@ static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)return rc; } -static int ecryptfs_getattr_link (const struct path *path,struct kstat *stat, +static int ecryptfs_getattr_link (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags) {struct dentry *dentry = path->dentry;
@@ -999,7 +1003,8 @@ static int ecryptfs_getattr_link(const struct path *path, struct kstat *stat,return rc; } -static int ecryptfs_getattr (const struct path *path,struct kstat *stat, +static int ecryptfs_getattr (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags) {struct dentry *dentry = path->dentry;
fs/efivarfs/inode.c +2 -2
@@ -66,8 +66,8 @@ bool efivarfs_valid_name(const char *str, int len)return uuid_is_valid (s); } -static int efivarfs_create (struct inode *dir,struct dentry *dentry, -umode_t mode,bool excl) +static int efivarfs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct inode *inode =NULL ;struct efivar_entry *var;
fs/erofs/inode.c +3 -2
@@ -331,8 +331,9 @@ struct inode *erofs_iget(struct super_block *sb,return inode; } -int erofs_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int query_flags) +int erofs_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask, +unsigned int query_flags) {struct inode *const inode =d_inode (path->dentry);
fs/erofs/internal.h +3 -2
@@ -373,8 +373,9 @@ extern const struct inode_operations erofs_symlink_iops;extern const struct inode_operations erofs_fast_symlink_iops;struct inode *erofs_iget (struct super_block *sb,erofs_nid_t nid,bool dir); -int erofs_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int query_flags); +int erofs_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask, +unsigned int query_flags);/* namei.c */ extern const struct inode_operations erofs_dir_iops;
fs/exec.c +1 -1
@@ -1597,7 +1597,7 @@ static void bprm_fill_uid(struct linux_binprm *bprm, struct file *file)if (!(mode & (S_ISUID |S_ISGID )))return ; - mnt_userns =mnt_user_ns (file->f_path.mnt); + mnt_userns =file_user_ns (file);/* Be careful if suid/sgid is set */ inode_lock (inode);
fs/exfat/exfat_fs.h +5 -3
@@ -416,9 +416,11 @@ int exfat_count_used_clusters(struct super_block *sb, unsigned int *ret_count);extern const struct file_operations exfat_file_operations;int __exfat_truncate (struct inode *inode,loff_t new_size);void exfat_truncate (struct inode *inode,loff_t size); -int exfat_setattr (struct dentry *dentry,struct iattr *attr); -int exfat_getattr (const struct path *path,struct kstat *stat, -unsigned int request_mask,unsigned int query_flags); +int exfat_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr); +int exfat_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,unsigned int request_mask, +unsigned int query_flags);int exfat_file_fsync (struct file *file,loff_t start,loff_t end,int datasync);/* namei.c */
fs/exfat/file.c +5 -3
@@ -267,8 +267,9 @@ void exfat_truncate(struct inode *inode, loff_t size)mutex_unlock (&sbi->s_lock); } -int exfat_getattr (const struct path *path,struct kstat *stat, -unsigned int request_mask,unsigned int query_flags) +int exfat_getattr (struct user_namespace *mnt_uerns,const struct path *path, +struct kstat *stat,unsigned int request_mask, +unsigned int query_flags) {struct inode *inode =d_backing_inode (path->dentry);struct exfat_inode_info *ei =EXFAT_I (inode);
@@ -282,7 +283,8 @@ int exfat_getattr(const struct path *path, struct kstat *stat,return 0 ; } -int exfat_setattr (struct dentry *dentry,struct iattr *attr) +int exfat_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct exfat_sb_info *sbi =EXFAT_SB (dentry->d_sb);struct inode *inode = dentry->d_inode;
fs/exfat/namei.c +8 -6
@@ -541,8 +541,8 @@ static int exfat_add_entry(struct inode *inode, const char *path,return ret; } -static int exfat_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int exfat_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct super_block *sb = dir->i_sb;struct inode *inode;
@@ -827,7 +827,8 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)return err; } -static int exfat_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int exfat_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct inode *inode;
@@ -1318,9 +1319,10 @@ static int __exfat_rename(struct inode *old_parent_inode,return ret; } -static int exfat_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int exfat_rename (struct user_namespace *mnt_userns, +struct inode *old_dir,struct dentry *old_dentry, +struct inode *new_dir,struct dentry *new_dentry, +unsigned int flags) {struct inode *old_inode, *new_inode;struct super_block *sb = old_dir->i_sb;
fs/ext2/acl.c +2 -1
@@ -216,7 +216,8 @@ __ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)* inode->i_mutex: down */ int -ext2_set_acl (struct inode *inode,struct posix_acl *acl,int type) +ext2_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type) {int error;int update_mode =0 ;
fs/ext2/acl.h +2 -1
@@ -56,7 +56,8 @@ static inline int ext2_acl_count(size_t size)/* acl.c */ extern struct posix_acl *ext2_get_acl (struct inode *inode,int type); -extern int ext2_set_acl (struct inode *inode,struct posix_acl *acl,int type); +extern int ext2_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type);extern int ext2_init_acl (struct inode *,struct inode *);#else
fs/ext2/ext2.h +3 -2
@@ -764,8 +764,9 @@ extern struct inode *ext2_iget (struct super_block *, unsigned long);extern int ext2_write_inode (struct inode *,struct writeback_control *);extern void ext2_evict_inode (struct inode *);extern int ext2_get_block (struct inode *,sector_t ,struct buffer_head *,int ); -extern int ext2_setattr (struct dentry *,struct iattr *); -extern int ext2_getattr (const struct path *,struct kstat *,u32 ,unsigned int ); +extern int ext2_setattr (struct user_namespace *,struct dentry *,struct iattr *); +extern int ext2_getattr (struct user_namespace *,const struct path *, +struct kstat *,u32 ,unsigned int );extern void ext2_set_inode_flags (struct inode *inode);extern int ext2_fiemap (struct inode *inode,struct fiemap_extent_info *fieinfo,u64 start,u64 len);
fs/ext2/inode.c +4 -3
@@ -1638,8 +1638,8 @@ int ext2_write_inode(struct inode *inode, struct writeback_control *wbc)return __ext2_write_inode (inode, wbc->sync_mode ==WB_SYNC_ALL ); } -int ext2_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int query_flags) +int ext2_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int query_flags) {struct inode *inode =d_inode (path->dentry);struct ext2_inode_info *ei =EXT2_I (inode);
@@ -1664,7 +1664,8 @@ int ext2_getattr(const struct path *path, struct kstat *stat,return 0 ; } -int ext2_setattr (struct dentry *dentry,struct iattr *iattr) +int ext2_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *iattr) {struct inode *inode =d_inode (dentry);int error;
fs/ext2/namei.c +13 -9
@@ -100,7 +100,8 @@ struct dentry *ext2_get_parent(struct dentry *child)* If the create succeeds, we fill in the inode information * with d_instantiate(). */ -static int ext2_create (struct inode * dir,struct dentry * dentry,umode_t mode,bool excl) +static int ext2_create (struct user_namespace * mnt_userns, +struct inode * dir,struct dentry * dentry,umode_t mode,bool excl) {struct inode *inode;int err;
@@ -118,7 +119,8 @@ static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t modereturn ext2_add_nondir (dentry, inode); } -static int ext2_tmpfile (struct inode *dir,struct dentry *dentry,umode_t mode) +static int ext2_tmpfile (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct inode *inode =ext2_new_inode (dir, mode,NULL );if (IS_ERR (inode))
@@ -131,7 +133,8 @@ static int ext2_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)return 0 ; } -static int ext2_mknod (struct inode * dir,struct dentry *dentry,umode_t mode,dev_t rdev) +static int ext2_mknod (struct user_namespace * mnt_userns,struct inode * dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {struct inode * inode;int err;
@@ -151,8 +154,8 @@ static int ext2_mknod (struct inode * dir, struct dentry *dentry, umode_t mode,return err; } -static int ext2_symlink (struct inode * dir,struct dentry * dentry, -const char * symname) +static int ext2_symlink (struct user_namespace * mnt_userns,struct inode * dir, +struct dentry * dentry,const char * symname) {struct super_block * sb = dir->i_sb;int err = -ENAMETOOLONG ;
@@ -225,7 +228,8 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,return err; } -static int ext2_mkdir (struct inode * dir,struct dentry * dentry,umode_t mode) +static int ext2_mkdir (struct user_namespace * mnt_userns, +struct inode * dir,struct dentry * dentry,umode_t mode) {struct inode * inode;int err;
@@ -315,9 +319,9 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry)return err; } -static int ext2_rename (struct inode * old_dir,struct dentry * old_dentry, -struct inode * new_dir,struct dentry * new_dentry, -unsigned int flags) +static int ext2_rename (struct user_namespace * mnt_userns,struct inode * old_dir, +struct dentry * old_dentry,struct inode * new_dir, +struct dentry * new_dentry,unsigned int flags) {struct inode * old_inode =d_inode (old_dentry);struct inode * new_inode =d_inode (new_dentry);
fs/ext4/acl.c +2 -1
@@ -222,7 +222,8 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type, }int -ext4_set_acl (struct inode *inode,struct posix_acl *acl,int type) +ext4_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type) {handle_t *handle;int error, credits, retries =0 ;
fs/ext4/acl.h +2 -1
@@ -56,7 +56,8 @@ static inline int ext4_acl_count(size_t size)/* acl.c */ struct posix_acl *ext4_get_acl (struct inode *inode,int type); -int ext4_set_acl (struct inode *inode,struct posix_acl *acl,int type); +int ext4_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type);extern int ext4_init_acl (handle_t *,struct inode *,struct inode *);#else /* CONFIG_EXT4_FS_POSIX_ACL */
fs/ext4/ext4.h +5 -3
@@ -2877,11 +2877,13 @@ extern struct inode *__ext4_iget(struct super_block *sb, unsigned long ino, __ext4_iget((sb), (ino), (flags), __func__, __LINE__)extern int ext4_write_inode (struct inode *,struct writeback_control *); -extern int ext4_setattr (struct dentry *,struct iattr *); -extern int ext4_getattr (const struct path *,struct kstat *,u32 ,unsigned int ); +extern int ext4_setattr (struct user_namespace *,struct dentry *,struct iattr *); +extern int ext4_getattr (struct user_namespace *,const struct path *, +struct kstat *,u32 ,unsigned int );extern void ext4_evict_inode (struct inode *);extern void ext4_clear_inode (struct inode *); -extern int ext4_file_getattr (const struct path *,struct kstat *,u32 ,unsigned int ); +extern int ext4_file_getattr (struct user_namespace *,const struct path *, +struct kstat *,u32 ,unsigned int );extern int ext4_sync_inode (handle_t *,struct inode *);extern void ext4_dirty_inode (struct inode *,int );extern int ext4_change_inode_journal_flag (struct inode *,int );
fs/ext4/inode.c +7 -5
@@ -5315,7 +5315,8 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)* * Called with inode->i_mutex down. */ -int ext4_setattr (struct dentry *dentry,struct iattr *attr) +int ext4_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct inode *inode =d_inode (dentry);int error, rc =0 ;
@@ -5531,8 +5532,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)return error; } -int ext4_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int query_flags) +int ext4_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int query_flags) {struct inode *inode =d_inode (path->dentry);struct ext4_inode *raw_inode;
@@ -5571,13 +5572,14 @@ int ext4_getattr(const struct path *path, struct kstat *stat,return 0 ; } -int ext4_file_getattr (const struct path *path,struct kstat *stat, +int ext4_file_getattr (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int query_flags) {struct inode *inode =d_inode (path->dentry);u64 delalloc_blocks; -ext4_getattr (path, stat, request_mask, query_flags); +ext4_getattr (&init_user_ns, path, stat, request_mask, query_flags);/* * If there is inline data in the inode, the inode will normally not
fs/ext4/namei.c +11 -8
@@ -2596,8 +2596,8 @@ static int ext4_add_nondir(handle_t *handle,* If the create succeeds, we fill in the inode information * with d_instantiate(). */ -static int ext4_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int ext4_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {handle_t *handle;struct inode *inode;
@@ -2631,8 +2631,8 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, umode_t mode,return err; } -static int ext4_mknod (struct inode *dir,struct dentry *dentry, -umode_t mode,dev_t rdev) +static int ext4_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {handle_t *handle;struct inode *inode;
@@ -2665,7 +2665,8 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,return err; } -static int ext4_tmpfile (struct inode *dir,struct dentry *dentry,umode_t mode) +static int ext4_tmpfile (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {handle_t *handle;struct inode *inode;
@@ -2774,7 +2775,8 @@ int ext4_init_new_dir(handle_t *handle, struct inode *dir,return err; } -static int ext4_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int ext4_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {handle_t *handle;struct inode *inode;
@@ -3286,7 +3288,7 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry)return retval; } -static int ext4_symlink (struct inode *dir, +static int ext4_symlink (struct user_namespace *mnt_userns,struct inode *dir,struct dentry *dentry,const char *symname) {handle_t *handle;
@@ -4078,7 +4080,8 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,return retval; } -static int ext4_rename2 (struct inode *old_dir,struct dentry *old_dentry, +static int ext4_rename2 (struct user_namespace *mnt_userns, +struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry,unsigned int flags) {
fs/f2fs/acl.c +2 -1
@@ -248,7 +248,8 @@ static int __f2fs_set_acl(struct inode *inode, int type,return error; } -int f2fs_set_acl (struct inode *inode,struct posix_acl *acl,int type) +int f2fs_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type) {if (unlikely (f2fs_cp_error (F2FS_I_SB (inode))))return -EIO ;
fs/f2fs/acl.h +2 -1
@@ -34,7 +34,8 @@ struct f2fs_acl_header {#ifdef CONFIG_F2FS_FS_POSIX_ACL extern struct posix_acl *f2fs_get_acl (struct inode *,int ); -extern int f2fs_set_acl (struct inode *,struct posix_acl *,int ); +extern int f2fs_set_acl (struct user_namespace *,struct inode *, +struct posix_acl *,int );extern int f2fs_init_acl (struct inode *,struct inode *,struct page *,struct page *);#else
fs/f2fs/f2fs.h +4 -3
@@ -3135,9 +3135,10 @@ void f2fs_truncate_data_blocks(struct dnode_of_data *dn);int f2fs_do_truncate_blocks (struct inode *inode,u64 from,bool lock);int f2fs_truncate_blocks (struct inode *inode,u64 from,bool lock);int f2fs_truncate (struct inode *inode); -int f2fs_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int flags); -int f2fs_setattr (struct dentry *dentry,struct iattr *attr); +int f2fs_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int flags); +int f2fs_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr);int f2fs_truncate_hole (struct inode *inode,pgoff_t pg_start,pgoff_t pg_end);void f2fs_truncate_data_blocks_range (struct dnode_of_data *dn,int count);int f2fs_precache_extents (struct inode *inode);
fs/f2fs/file.c +4 -3
@@ -783,8 +783,8 @@ int f2fs_truncate(struct inode *inode)return 0 ; } -int f2fs_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int query_flags) +int f2fs_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int query_flags) {struct inode *inode =d_inode (path->dentry);struct f2fs_inode_info *fi =F2FS_I (inode);
@@ -859,7 +859,8 @@ static void __setattr_copy(struct user_namespace *mnt_userns, struct inode *inod#define __setattr_copy setattr_copy#endif -int f2fs_setattr (struct dentry *dentry,struct iattr *attr) +int f2fs_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct inode *inode =d_inode (dentry);int err;
fs/f2fs/namei.c +12 -9
@@ -314,8 +314,8 @@ static void set_compress_inode(struct f2fs_sb_info *sbi, struct inode *inode, } } -static int f2fs_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int f2fs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct f2fs_sb_info *sbi =F2FS_I_SB (dir);struct inode *inode;
@@ -637,8 +637,8 @@ static const char *f2fs_get_link(struct dentry *dentry,return link; } -static int f2fs_symlink (struct inode *dir,struct dentry *dentry, -const char *symname) +static int f2fs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {struct f2fs_sb_info *sbi =F2FS_I_SB (dir);struct inode *inode;
@@ -717,7 +717,8 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,return err; } -static int f2fs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int f2fs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct f2fs_sb_info *sbi =F2FS_I_SB (dir);struct inode *inode;
@@ -770,8 +771,8 @@ static int f2fs_rmdir(struct inode *dir, struct dentry *dentry)return -ENOTEMPTY ; } -static int f2fs_mknod (struct inode *dir,struct dentry *dentry, -umode_t mode,dev_t rdev) +static int f2fs_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {struct f2fs_sb_info *sbi =F2FS_I_SB (dir);struct inode *inode;
@@ -874,7 +875,8 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,return err; } -static int f2fs_tmpfile (struct inode *dir,struct dentry *dentry,umode_t mode) +static int f2fs_tmpfile (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct f2fs_sb_info *sbi =F2FS_I_SB (dir);
@@ -1247,7 +1249,8 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,return err; } -static int f2fs_rename2 (struct inode *old_dir,struct dentry *old_dentry, +static int f2fs_rename2 (struct user_namespace *mnt_userns, +struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry,unsigned int flags) {
fs/fat/fat.h +4 -2
@@ -397,9 +397,11 @@ extern long fat_generic_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);extern const struct file_operations fat_file_operations;extern const struct inode_operations fat_file_inode_operations; -extern int fat_setattr (struct dentry *dentry,struct iattr *attr); +extern int fat_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr);extern void fat_truncate_blocks (struct inode *inode,loff_t offset); -extern int fat_getattr (const struct path *path,struct kstat *stat, +extern int fat_getattr (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags);extern int fat_file_fsync (struct file *file,loff_t start,loff_t end,int datasync);
fs/fat/file.c +5 -4
@@ -95,7 +95,7 @@ static int fat_ioctl_set_attributes(struct file *file, u32 __user *user_attr) goto out_unlock_inode;/* This MUST be done before doing anything irreversible... */ - err =fat_setattr (file->f_path.dentry, &ia); + err =fat_setattr (file_user_ns (file), file->f_path.dentry, &ia);if (err) goto out_unlock_inode;
@@ -394,8 +394,8 @@ void fat_truncate_blocks(struct inode *inode, loff_t offset)fat_flush_inodes (inode->i_sb, inode,NULL ); } -int fat_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int flags) +int fat_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int flags) {struct inode *inode =d_inode (path->dentry);generic_fillattr (&init_user_ns, inode, stat);
@@ -466,7 +466,8 @@ static int fat_allow_set_time(struct msdos_sb_info *sbi, struct inode *inode)/* valid file mode bits */ #define FAT_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXUGO) -int fat_setattr (struct dentry *dentry,struct iattr *attr) +int fat_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct msdos_sb_info *sbi =MSDOS_SB (dentry->d_sb);struct inode *inode =d_inode (dentry);
fs/fat/namei_msdos.c +6 -4
@@ -261,8 +261,8 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name, }/***** Create a file */ -static int msdos_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int msdos_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct super_block *sb = dir->i_sb;struct inode *inode =NULL ;
@@ -339,7 +339,8 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry) }/***** Make a directory */ -static int msdos_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int msdos_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct fat_slot_info sinfo;
@@ -593,7 +594,8 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name, }/***** Rename, a wrapper for rename_same_dir & rename_diff_dir */ -static int msdos_rename (struct inode *old_dir,struct dentry *old_dentry, +static int msdos_rename (struct user_namespace *mnt_userns, +struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry,unsigned int flags) {
fs/fat/namei_vfat.c +7 -6
@@ -756,8 +756,8 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,return ERR_PTR (err); } -static int vfat_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int vfat_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct super_block *sb = dir->i_sb;struct inode *inode;
@@ -846,7 +846,8 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)return err; } -static int vfat_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int vfat_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct super_block *sb = dir->i_sb;struct inode *inode;
@@ -892,9 +893,9 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)return err; } -static int vfat_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int vfat_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {struct buffer_head *dotdot_bh;struct msdos_dir_entry *dotdot_de;
fs/fuse/acl.c +2 -1
@@ -50,7 +50,8 @@ struct posix_acl *fuse_get_acl(struct inode *inode, int type)return acl; } -int fuse_set_acl (struct inode *inode,struct posix_acl *acl,int type) +int fuse_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type) {struct fuse_conn *fc =get_fuse_conn (inode);const char *name;
fs/fuse/dir.c +21 -16
@@ -605,7 +605,8 @@ static int fuse_create_open(struct inode *dir, struct dentry *entry,return err; } -static int fuse_mknod (struct inode *,struct dentry *,umode_t ,dev_t ); +static int fuse_mknod (struct user_namespace *,struct inode *,struct dentry *, +umode_t ,dev_t );static int fuse_atomic_open (struct inode *dir,struct dentry *entry,struct file *file,unsigned flags,umode_t mode)
@@ -645,7 +646,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,return err; mknod: - err =fuse_mknod (dir, entry, mode,0 ); + err =fuse_mknod (&init_user_ns, dir, entry, mode,0 );if (err) goto out_dput; no_open:
@@ -715,8 +716,8 @@ static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args,return err; } -static int fuse_mknod (struct inode *dir,struct dentry *entry,umode_t mode, -dev_t rdev) +static int fuse_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *entry,umode_t mode,dev_t rdev) {struct fuse_mknod_in inarg;struct fuse_mount *fm =get_fuse_mount (dir);
@@ -738,13 +739,14 @@ static int fuse_mknod(struct inode *dir, struct dentry *entry, umode_t mode,return create_new_entry (fm, &args, dir, entry, mode); } -static int fuse_create (struct inode *dir,struct dentry *entry,umode_t mode, -bool excl) +static int fuse_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *entry,umode_t mode,bool excl) { -return fuse_mknod (dir, entry, mode,0 ); +return fuse_mknod (&init_user_ns, dir, entry, mode,0 ); } -static int fuse_mkdir (struct inode *dir,struct dentry *entry,umode_t mode) +static int fuse_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *entry,umode_t mode) {struct fuse_mkdir_in inarg;struct fuse_mount *fm =get_fuse_mount (dir);
@@ -765,8 +767,8 @@ static int fuse_mkdir(struct inode *dir, struct dentry *entry, umode_t mode)return create_new_entry (fm, &args, dir, entry,S_IFDIR ); } -static int fuse_symlink (struct inode *dir,struct dentry *entry, -const char *link) +static int fuse_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *entry,const char *link) {struct fuse_mount *fm =get_fuse_mount (dir);unsigned len =strlen (link) +1 ;
@@ -908,9 +910,9 @@ static int fuse_rename_common(struct inode *olddir, struct dentry *oldent,return err; } -static int fuse_rename2 (struct inode *olddir,struct dentry *oldent, -struct inode *newdir,struct dentry *newent, -unsigned int flags) +static int fuse_rename2 (struct user_namespace *mnt_userns,struct inode *olddir, +struct dentry *oldent,struct inode *newdir, +struct dentry *newent,unsigned int flags) {struct fuse_conn *fc =get_fuse_conn (olddir);int err;
@@ -1249,7 +1251,8 @@ static int fuse_perm_getattr(struct inode *inode, int mask)* access request is sent. Execute permission is still checked * locally based on file mode. */ -static int fuse_permission (struct inode *inode,int mask) +static int fuse_permission (struct user_namespace *mnt_userns, +struct inode *inode,int mask) {struct fuse_conn *fc =get_fuse_conn (inode);bool refreshed = false;
@@ -1756,7 +1759,8 @@ int fuse_do_setattr(struct dentry *dentry, struct iattr *attr,return err; } -static int fuse_setattr (struct dentry *entry,struct iattr *attr) +static int fuse_setattr (struct user_namespace *mnt_userns,struct dentry *entry, +struct iattr *attr) {struct inode *inode =d_inode (entry);struct fuse_conn *fc =get_fuse_conn (inode);
@@ -1818,7 +1822,8 @@ static int fuse_setattr(struct dentry *entry, struct iattr *attr)return ret; } -static int fuse_getattr (const struct path *path,struct kstat *stat, +static int fuse_getattr (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags) {struct inode *inode =d_inode (path->dentry);
fs/fuse/fuse_i.h +2 -2
@@ -1180,8 +1180,8 @@ extern const struct xattr_handler *fuse_no_acl_xattr_handlers[];struct posix_acl ;struct posix_acl *fuse_get_acl (struct inode *inode,int type); -int fuse_set_acl (struct inode *inode,struct posix_acl *acl,int type); - +int fuse_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type);/* readdir.c */ int fuse_readdir (struct file *file,struct dir_context *ctx);
fs/gfs2/acl.c +2 -1
@@ -106,7 +106,8 @@ int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)return error; } -int gfs2_set_acl (struct inode *inode,struct posix_acl *acl,int type) +int gfs2_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type) {struct gfs2_inode *ip =GFS2_I (inode);struct gfs2_holder gh;
fs/gfs2/acl.h +2 -1
@@ -13,6 +13,7 @@extern struct posix_acl *gfs2_get_acl (struct inode *inode,int type);extern int __gfs2_set_acl (struct inode *inode,struct posix_acl *acl,int type); -extern int gfs2_set_acl (struct inode *inode,struct posix_acl *acl,int type); +extern int gfs2_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type);#endif /* __ACL_DOT_H__ */
fs/gfs2/file.c +1 -1
@@ -256,7 +256,7 @@ static int do_gfs2_set_flags(struct file *filp, u32 reqflags, u32 mask, !capable(CAP_LINUX_IMMUTABLE)) goto out;if (!IS_IMMUTABLE (inode)) { - error =gfs2_permission (inode,MAY_WRITE ); + error =gfs2_permission (&init_user_ns, inode,MAY_WRITE );if (error) goto out; }
fs/gfs2/inode.c +28 -21
149 lines not on this page · raw message
fs/gfs2/inode.h +2 -1
@@ -99,7 +99,8 @@ extern int gfs2_inode_refresh(struct gfs2_inode *ip);extern struct inode *gfs2_lookupi (struct inode *dir,const struct qstr *name,int is_root); -extern int gfs2_permission (struct inode *inode,int mask); +extern int gfs2_permission (struct user_namespace *mnt_userns, +struct inode *inode,int mask);extern int gfs2_setattr_simple (struct inode *inode,struct iattr *attr);extern struct inode *gfs2_lookup_simple (struct inode *dip,const char *name);extern void gfs2_dinode_out (const struct gfs2_inode *ip,void *buf);
fs/hfs/dir.c +7 -6
@@ -189,8 +189,8 @@ static int hfs_dir_release(struct inode *inode, struct file *file)* a directory and return a corresponding inode, given the inode for * the directory and the name (and its length) of the new file. */ -static int hfs_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int hfs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct inode *inode;int res;
@@ -219,7 +219,8 @@ static int hfs_create(struct inode *dir, struct dentry *dentry, umode_t mode,* in a directory, given the inode for the parent directory and the * name (and its length) of the new directory. */ -static int hfs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int hfs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct inode *inode;int res;
@@ -279,9 +280,9 @@ static int hfs_remove(struct inode *dir, struct dentry *dentry)* new file/directory. * XXX: how do you handle must_be dir? */ -static int hfs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int hfs_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {int res;
fs/hfs/hfs_fs.h +1 -1
@@ -204,7 +204,7 @@ extern const struct address_space_operations hfs_btree_aops;extern struct inode *hfs_new_inode (struct inode *,const struct qstr *,umode_t );extern void hfs_inode_write_fork (struct inode *,struct hfs_extent *,__be32 *,__be32 *);extern int hfs_write_inode (struct inode *,struct writeback_control *); -extern int hfs_inode_setattr (struct dentry *,struct iattr *); +extern int hfs_inode_setattr (struct user_namespace *,struct dentry *,struct iattr *);extern void hfs_inode_read_fork (struct inode *inode,struct hfs_extent *ext,__be32 log_size,__be32 phys_size,u32 clump_size);extern struct inode *hfs_iget (struct super_block *,struct hfs_cat_key *,hfs_cat_rec *);
fs/hfs/inode.c +2 -1
@@ -602,7 +602,8 @@ static int hfs_file_release(struct inode *inode, struct file *file)* correspond to the same HFS file. */ -int hfs_inode_setattr (struct dentry *dentry,struct iattr * attr) +int hfs_inode_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct inode *inode =d_inode (dentry);struct hfs_sb_info *hsb =HFS_SB (inode->i_sb);
fs/hfsplus/dir.c +13 -12
@@ -434,8 +434,8 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)return res; } -static int hfsplus_symlink (struct inode *dir,struct dentry *dentry, -const char *symname) +static int hfsplus_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {struct hfsplus_sb_info *sbi =HFSPLUS_SB (dir->i_sb);struct inode *inode;
@@ -476,8 +476,8 @@ static int hfsplus_symlink(struct inode *dir, struct dentry *dentry,return res; } -static int hfsplus_mknod (struct inode *dir,struct dentry *dentry, -umode_t mode,dev_t rdev) +static int hfsplus_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {struct hfsplus_sb_info *sbi =HFSPLUS_SB (dir->i_sb);struct inode *inode;
@@ -517,20 +517,21 @@ static int hfsplus_mknod(struct inode *dir, struct dentry *dentry,return res; } -static int hfsplus_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int hfsplus_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) { -return hfsplus_mknod (dir, dentry, mode,0 ); +return hfsplus_mknod (&init_user_ns, dir, dentry, mode,0 ); } -static int hfsplus_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int hfsplus_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) { -return hfsplus_mknod (dir, dentry, mode |S_IFDIR ,0 ); +return hfsplus_mknod (&init_user_ns, dir, dentry, mode |S_IFDIR ,0 ); } -static int hfsplus_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int hfsplus_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {int res;
fs/hfsplus/hfsplus_fs.h +3 -2
@@ -488,8 +488,9 @@ void hfsplus_inode_write_fork(struct inode *inode, struct hfsplus_fork_raw *fork);int hfsplus_cat_read_inode (struct inode *inode,struct hfs_find_data *fd);int hfsplus_cat_write_inode (struct inode *inode); -int hfsplus_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int query_flags); +int hfsplus_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask, +unsigned int query_flags);int hfsplus_file_fsync (struct file *file,loff_t start,loff_t end,int datasync);
fs/hfsplus/inode.c +5 -3
@@ -241,7 +241,8 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)return 0 ; } -static int hfsplus_setattr (struct dentry *dentry,struct iattr *attr) +static int hfsplus_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);int error;
@@ -270,8 +271,9 @@ static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)return 0 ; } -int hfsplus_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int query_flags) +int hfsplus_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask, +unsigned int query_flags) {struct inode *inode =d_inode (path->dentry);struct hfsplus_inode_info *hip =HFSPLUS_I (inode);
fs/hostfs/hostfs_kern.c +14 -9
@@ -555,8 +555,8 @@ static int read_name(struct inode *ino, char *name)return 0 ; } -static int hostfs_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int hostfs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct inode *inode;char *name;
@@ -654,8 +654,8 @@ static int hostfs_unlink(struct inode *ino, struct dentry *dentry)return err; } -static int hostfs_symlink (struct inode *ino,struct dentry *dentry, -const char *to) +static int hostfs_symlink (struct user_namespace *mnt_userns,struct inode *ino, +struct dentry *dentry,const char *to) {char *file;int err;
@@ -667,7 +667,8 @@ static int hostfs_symlink(struct inode *ino, struct dentry *dentry,return err; } -static int hostfs_mkdir (struct inode *ino,struct dentry *dentry,umode_t mode) +static int hostfs_mkdir (struct user_namespace *mnt_userns,struct inode *ino, +struct dentry *dentry,umode_t mode) {char *file;int err;
@@ -691,7 +692,8 @@ static int hostfs_rmdir(struct inode *ino, struct dentry *dentry)return err; } -static int hostfs_mknod (struct inode *dir,struct dentry *dentry,umode_t mode,dev_t dev) +static int hostfs_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t dev) {struct inode *inode;char *name;
@@ -729,7 +731,8 @@ static int hostfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode,return err; } -static int hostfs_rename2 (struct inode *old_dir,struct dentry *old_dentry, +static int hostfs_rename2 (struct user_namespace *mnt_userns, +struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry,unsigned int flags) {
@@ -757,7 +760,8 @@ static int hostfs_rename2(struct inode *old_dir, struct dentry *old_dentry,return err; } -static int hostfs_permission (struct inode *ino,int desired) +static int hostfs_permission (struct user_namespace *mnt_userns, +struct inode *ino,int desired) {char *name;int r =0 , w =0 , x =0 , err;
@@ -783,7 +787,8 @@ static int hostfs_permission(struct inode *ino, int desired)return err; } -static int hostfs_setattr (struct dentry *dentry,struct iattr *attr) +static int hostfs_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);struct hostfs_iattr attrs;
fs/hpfs/hpfs_fn.h +1 -1
@@ -280,7 +280,7 @@ void hpfs_init_inode(struct inode *);void hpfs_read_inode (struct inode *);void hpfs_write_inode (struct inode *);void hpfs_write_inode_nolock (struct inode *); -int hpfs_setattr (struct dentry *,struct iattr *); +int hpfs_setattr (struct user_namespace *,struct dentry *,struct iattr *);void hpfs_write_if_changed (struct inode *);void hpfs_evict_inode (struct inode *);
fs/hpfs/inode.c +2 -1
@@ -257,7 +257,8 @@ void hpfs_write_inode_nolock(struct inode *i)brelse (bh); } -int hpfs_setattr (struct dentry *dentry,struct iattr *attr) +int hpfs_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *attr) {struct inode *inode =d_inode (dentry);int error = -EINVAL ;
fs/hpfs/namei.c +12 -8
@@ -20,7 +20,8 @@ static void hpfs_update_directory_times(struct inode *dir)hpfs_write_inode_nolock (dir); } -static int hpfs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int hpfs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {const unsigned char *name = dentry->d_name.name;unsigned len = dentry->d_name.len;
@@ -128,7 +129,8 @@ static int hpfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)return err; } -static int hpfs_create (struct inode *dir,struct dentry *dentry,umode_t mode,bool excl) +static int hpfs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {const unsigned char *name = dentry->d_name.name;unsigned len = dentry->d_name.len;
@@ -215,7 +217,8 @@ static int hpfs_create(struct inode *dir, struct dentry *dentry, umode_t mode, breturn err; } -static int hpfs_mknod (struct inode *dir,struct dentry *dentry,umode_t mode,dev_t rdev) +static int hpfs_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {const unsigned char *name = dentry->d_name.name;unsigned len = dentry->d_name.len;
@@ -289,7 +292,8 @@ static int hpfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dereturn err; } -static int hpfs_symlink (struct inode *dir,struct dentry *dentry,const char *symlink) +static int hpfs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symlink) {const unsigned char *name = dentry->d_name.name;unsigned len = dentry->d_name.len;
@@ -506,10 +510,10 @@ static int hpfs_symlink_readpage(struct file *file, struct page *page)const struct address_space_operations hpfs_symlink_aops = { .readpage = hpfs_symlink_readpage }; - -static int hpfs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) + +static int hpfs_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {const unsigned char *old_name = old_dentry->d_name.name;unsigned old_len = old_dentry->d_name.len;
fs/hugetlbfs/inode.c +14 -11
@@ -751,7 +751,8 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,return error; } -static int hugetlbfs_setattr (struct dentry *dentry,struct iattr *attr) +static int hugetlbfs_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);struct hstate *h =hstate_inode (inode);
@@ -898,33 +899,35 @@ static int do_hugetlbfs_mknod(struct inode *dir,return error; } -static int hugetlbfs_mknod (struct inode *dir, -struct dentry *dentry,umode_t mode,dev_t dev) +static int hugetlbfs_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t dev) {return do_hugetlbfs_mknod (dir, dentry, mode, dev, false); } -static int hugetlbfs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +static int hugetlbfs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) { -int retval =hugetlbfs_mknod (dir, dentry, mode |S_IFDIR ,0 ); +int retval =hugetlbfs_mknod (&init_user_ns, dir, dentry, mode |S_IFDIR ,0 );if (!retval)inc_nlink (dir);return retval; } -static int hugetlbfs_create (struct inode *dir,struct dentry *dentry,umode_t mode,bool excl) +static int hugetlbfs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) { -return hugetlbfs_mknod (dir, dentry, mode |S_IFREG ,0 ); +return hugetlbfs_mknod (&init_user_ns, dir, dentry, mode |S_IFREG ,0 ); } -static int hugetlbfs_tmpfile (struct inode *dir, -struct dentry *dentry,umode_t mode) +static int hugetlbfs_tmpfile (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {return do_hugetlbfs_mknod (dir, dentry, mode |S_IFREG ,0 , true); } -static int hugetlbfs_symlink (struct inode *dir, -struct dentry *dentry,const char *symname) +static int hugetlbfs_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {struct inode *inode;int error = -ENOSPC ;
fs/jffs2/acl.c +2 -1
@@ -226,7 +226,8 @@ static int __jffs2_set_acl(struct inode *inode, int xprefix, struct posix_acl *areturn rc; } -int jffs2_set_acl (struct inode *inode,struct posix_acl *acl,int type) +int jffs2_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type) {int rc, xprefix;
fs/jffs2/acl.h +2 -1
@@ -28,7 +28,8 @@ struct jffs2_acl_header {#ifdef CONFIG_JFFS2_FS_POSIX_ACL struct posix_acl *jffs2_get_acl (struct inode *inode,int type); -int jffs2_set_acl (struct inode *inode,struct posix_acl *acl,int type); +int jffs2_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type);extern int jffs2_init_acl_pre (struct inode *,struct inode *,umode_t *);extern int jffs2_init_acl_post (struct inode *);
fs/jffs2/dir.c +18 -14
@@ -24,17 +24,18 @@static int jffs2_readdir (struct file *,struct dir_context *); -static int jffs2_create (struct inode *,struct dentry *,umode_t , -bool ); +static int jffs2_create (struct user_namespace *,struct inode *, +struct dentry *,umode_t ,bool );static struct dentry *jffs2_lookup (struct inode *,struct dentry *,unsigned int );static int jffs2_link (struct dentry *,struct inode *,struct dentry *);static int jffs2_unlink (struct inode *,struct dentry *); -static int jffs2_symlink (struct inode *,struct dentry *,const char *); -static int jffs2_mkdir (struct inode *,struct dentry *,umode_t ); +static int jffs2_symlink (struct user_namespace *,struct inode *, +struct dentry *,const char *); +static int jffs2_mkdir (struct user_namespace *,struct inode *,struct dentry *,umode_t );static int jffs2_rmdir (struct inode *,struct dentry *); -static int jffs2_mknod (struct inode *,struct dentry *,umode_t ,dev_t ); -static int jffs2_rename (struct inode *,struct dentry *, +static int jffs2_mknod (struct user_namespace *,struct inode *,struct dentry *,umode_t ,dev_t ); +static int jffs2_rename (struct user_namespace *,struct inode *,struct dentry *,struct inode *,struct dentry *,unsigned int );
@@ -157,8 +158,8 @@ static int jffs2_readdir(struct file *file, struct dir_context *ctx)/***********************************************************************/ -static int jffs2_create (struct inode *dir_i,struct dentry *dentry, -umode_t mode,bool excl) +static int jffs2_create (struct user_namespace *mnt_userns,struct inode *dir_i, +struct dentry *dentry,umode_t mode,bool excl) {struct jffs2_raw_inode *ri;struct jffs2_inode_info *f, *dir_f;
@@ -276,7 +277,8 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de/***********************************************************************/ -static int jffs2_symlink (struct inode *dir_i,struct dentry *dentry,const char *target) +static int jffs2_symlink (struct user_namespace *mnt_userns,struct inode *dir_i, +struct dentry *dentry,const char *target) {struct jffs2_inode_info *f, *dir_f;struct jffs2_sb_info *c;
@@ -438,7 +440,8 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char } -static int jffs2_mkdir (struct inode *dir_i,struct dentry *dentry,umode_t mode) +static int jffs2_mkdir (struct user_namespace *mnt_userns,struct inode *dir_i, +struct dentry *dentry,umode_t mode) {struct jffs2_inode_info *f, *dir_f;struct jffs2_sb_info *c;
@@ -609,7 +612,8 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)return ret; } -static int jffs2_mknod (struct inode *dir_i,struct dentry *dentry,umode_t mode,dev_t rdev) +static int jffs2_mknod (struct user_namespace *mnt_userns,struct inode *dir_i, +struct dentry *dentry,umode_t mode,dev_t rdev) {struct jffs2_inode_info *f, *dir_f;struct jffs2_sb_info *c;
@@ -756,9 +760,9 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t modereturn ret; } -static int jffs2_rename (struct inode *old_dir_i,struct dentry *old_dentry, -struct inode *new_dir_i,struct dentry *new_dentry, -unsigned int flags) +static int jffs2_rename (struct user_namespace *mnt_userns,struct inode *old_dir_i, +struct dentry *old_dentry,struct inode *new_dir_i, +struct dentry *new_dentry,unsigned int flags) {int ret;struct jffs2_sb_info *c =JFFS2_SB_INFO (old_dir_i->i_sb);
fs/jffs2/fs.c +2 -1
@@ -190,7 +190,8 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)return 0 ; } -int jffs2_setattr (struct dentry *dentry,struct iattr *iattr) +int jffs2_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *iattr) {struct inode *inode =d_inode (dentry);int rc;
fs/jffs2/os-linux.h +1 -1
@@ -164,7 +164,7 @@ long jffs2_ioctl(struct file *, unsigned int, unsigned long);extern const struct inode_operations jffs2_symlink_inode_operations;/* fs.c */ -int jffs2_setattr (struct dentry *,struct iattr *); +int jffs2_setattr (struct user_namespace *,struct dentry *,struct iattr *);int jffs2_do_setattr (struct inode *,struct iattr *);struct inode *jffs2_iget (struct super_block *,unsigned long );void jffs2_evict_inode (struct inode *);
fs/jfs/acl.c +2 -1
@@ -91,7 +91,8 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int type,return rc; } -int jfs_set_acl (struct inode *inode,struct posix_acl *acl,int type) +int jfs_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type) {int rc;tid_t tid;
fs/jfs/file.c +2 -1
@@ -85,7 +85,8 @@ static int jfs_release(struct inode *inode, struct file *file)return 0 ; } -int jfs_setattr (struct dentry *dentry,struct iattr *iattr) +int jfs_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *iattr) {struct inode *inode =d_inode (dentry);int rc;
fs/jfs/jfs_acl.h +2 -1
@@ -8,7 +8,8 @@#ifdef CONFIG_JFS_POSIX_ACL struct posix_acl *jfs_get_acl (struct inode *inode,int type); -int jfs_set_acl (struct inode *inode,struct posix_acl *acl,int type); +int jfs_set_acl (struct user_namespace *mnt_userns,struct inode *inode, +struct posix_acl *acl,int type);int jfs_init_acl (tid_t ,struct inode *,struct inode *);#else
fs/jfs/jfs_inode.h +1 -1
@@ -26,7 +26,7 @@ extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid, int fh_len, int fh_type);extern void jfs_set_inode_flags (struct inode *);extern int jfs_get_block (struct inode *,sector_t ,struct buffer_head *,int ); -extern int jfs_setattr (struct dentry *,struct iattr *); +extern int jfs_setattr (struct user_namespace *,struct dentry *,struct iattr *);extern const struct address_space_operations jfs_aops;extern const struct inode_operations jfs_dir_inode_operations;
fs/jfs/namei.c +11 -10
@@ -59,8 +59,8 @@ static inline void free_ea_wmap(struct inode *inode)* RETURN: Errors from subroutines * */ -static int jfs_create (struct inode *dip,struct dentry *dentry,umode_t mode, -bool excl) +static int jfs_create (struct user_namespace *mnt_userns,struct inode *dip, +struct dentry *dentry,umode_t mode,bool excl) {int rc =0 ;tid_t tid;/* transaction id */
@@ -192,7 +192,8 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, umode_t mode,* note: * EACCES: user needs search+write permission on the parent directory */ -static int jfs_mkdir (struct inode *dip,struct dentry *dentry,umode_t mode) +static int jfs_mkdir (struct user_namespace *mnt_userns,struct inode *dip, +struct dentry *dentry,umode_t mode) {int rc =0 ;tid_t tid;/* transaction id */
@@ -868,8 +869,8 @@ static int jfs_link(struct dentry *old_dentry,* an intermediate result whose length exceeds PATH_MAX [XPG4.2] */ -static int jfs_symlink (struct inode *dip,struct dentry *dentry, -const char *name) +static int jfs_symlink (struct user_namespace *mnt_userns,struct inode *dip, +struct dentry *dentry,const char *name) {int rc;tid_t tid;
@@ -1058,9 +1059,9 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry,* * FUNCTION: rename a file or directory */ -static int jfs_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int jfs_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {struct btstack btstack;ino_t ino;
@@ -1344,8 +1345,8 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry,* * FUNCTION: Create a special file (device) */ -static int jfs_mknod (struct inode *dir,struct dentry *dentry, -umode_t mode,dev_t rdev) +static int jfs_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {struct jfs_inode_info *jfs_ip;struct btstack btstack;
fs/kernfs/dir.c +4 -3
@@ -1110,8 +1110,8 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir,return ret; } -static int kernfs_iop_mkdir (struct inode *dir,struct dentry *dentry, -umode_t mode) +static int kernfs_iop_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct kernfs_node *parent = dir->i_private;struct kernfs_syscall_ops *scops =kernfs_root (parent)->syscall_ops;
@@ -1147,7 +1147,8 @@ static int kernfs_iop_rmdir(struct inode *dir, struct dentry *dentry)return ret; } -static int kernfs_iop_rename (struct inode *old_dir,struct dentry *old_dentry, +static int kernfs_iop_rename (struct user_namespace *mnt_userns, +struct inode *old_dir,struct dentry *old_dentry,struct inode *new_dir,struct dentry *new_dentry,unsigned int flags) {
fs/kernfs/inode.c +6 -3
@@ -112,7 +112,8 @@ int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr)return ret; } -int kernfs_iop_setattr (struct dentry *dentry,struct iattr *iattr) +int kernfs_iop_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *iattr) {struct inode *inode =d_inode (dentry);struct kernfs_node *kn = inode->i_private;
@@ -183,7 +184,8 @@ static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)set_nlink (inode, kn->dir.subdirs +2 ); } -int kernfs_iop_getattr (const struct path *path,struct kstat *stat, +int kernfs_iop_getattr (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int query_flags) {struct inode *inode =d_inode (path->dentry);
@@ -272,7 +274,8 @@ void kernfs_evict_inode(struct inode *inode)kernfs_put (kn); } -int kernfs_iop_permission (struct inode *inode,int mask) +int kernfs_iop_permission (struct user_namespace *mnt_userns, +struct inode *inode,int mask) {struct kernfs_node *kn;
fs/kernfs/kernfs-internal.h +6 -3
@@ -89,9 +89,12 @@ extern struct kmem_cache *kernfs_node_cache, *kernfs_iattrs_cache;*/ extern const struct xattr_handler *kernfs_xattr_handlers[];void kernfs_evict_inode (struct inode *inode); -int kernfs_iop_permission (struct inode *inode,int mask); -int kernfs_iop_setattr (struct dentry *dentry,struct iattr *iattr); -int kernfs_iop_getattr (const struct path *path,struct kstat *stat, +int kernfs_iop_permission (struct user_namespace *mnt_userns, +struct inode *inode,int mask); +int kernfs_iop_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *iattr); +int kernfs_iop_getattr (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int query_flags);ssize_t kernfs_iop_listxattr (struct dentry *dentry,char *buf,size_t size);int __kernfs_setattr (struct kernfs_node *kn,const struct iattr *iattr);
fs/libfs.c +15 -16
@@ -27,8 +27,9 @@#include "internal.h" -int simple_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int query_flags) +int simple_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask, +unsigned int query_flags) {struct inode *inode =d_inode (path->dentry);generic_fillattr (&init_user_ns, inode, stat);
@@ -447,9 +448,9 @@ int simple_rmdir(struct inode *dir, struct dentry *dentry) }EXPORT_SYMBOL (simple_rmdir); -int simple_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +int simple_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {struct inode *inode =d_inode (old_dentry);int they_are_dirs =d_is_dir (old_dentry);
@@ -492,18 +493,19 @@ EXPORT_SYMBOL(simple_rename);* on simple regular filesystems. Anything that needs to change on-disk * or wire state on size changes needs its own setattr method. */ -int simple_setattr (struct dentry *dentry,struct iattr *iattr) +int simple_setattr (struct user_namespace *mnt_userns,struct dentry *dentry, +struct iattr *iattr) {struct inode *inode =d_inode (dentry);int error; - error =setattr_prepare (&init_user_ns, dentry, iattr); + error =setattr_prepare (mnt_userns, dentry, iattr);if (error)return error;if (iattr->ia_valid &ATTR_SIZE )truncate_setsize (inode, iattr->ia_size); -setattr_copy (&init_user_ns, inode, iattr); +setattr_copy (mnt_userns, inode, iattr);mark_inode_dirty (inode);return 0 ; }
@@ -1300,7 +1302,8 @@ static struct dentry *empty_dir_lookup(struct inode *dir, struct dentry *dentry,return ERR_PTR (-ENOENT ); } -static int empty_dir_getattr (const struct path *path,struct kstat *stat, +static int empty_dir_getattr (struct user_namespace *mnt_userns, +const struct path *path,struct kstat *stat,u32 request_mask,unsigned int query_flags) {struct inode *inode =d_inode (path->dentry);
@@ -1308,7 +1311,8 @@ static int empty_dir_getattr(const struct path *path, struct kstat *stat,return 0 ; } -static int empty_dir_setattr (struct dentry *dentry,struct iattr *attr) +static int empty_dir_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *attr) {return -EPERM ; }
@@ -1318,14 +1322,9 @@ static ssize_t empty_dir_listxattr(struct dentry *dentry, char *list, size_t sizreturn -EOPNOTSUPP ; } -static int empty_dir_permission (struct inode *inode,int mask) -{ -return generic_permission (&init_user_ns, inode, mask); -} -static const struct inode_operations empty_dir_inode_operations = { .lookup = empty_dir_lookup, - .permission = empty_dir_permission, + .permission = generic_permission, .setattr = empty_dir_setattr, .getattr = empty_dir_getattr, .listxattr = empty_dir_listxattr,
fs/minix/file.c +2 -1
@@ -22,7 +22,8 @@ const struct file_operations minix_file_operations = { .splice_read = generic_file_splice_read, }; -static int minix_setattr (struct dentry *dentry,struct iattr *attr) +static int minix_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);int error;
fs/minix/inode.c +2 -2
@@ -652,8 +652,8 @@ static int minix_write_inode(struct inode *inode, struct writeback_control *wbc)return err; } -int minix_getattr (const struct path *path,struct kstat *stat, -u32 request_mask,unsigned int flags) +int minix_getattr (struct user_namespace *mnt_userns,const struct path *path, +struct kstat *stat,u32 request_mask,unsigned int flags) {struct super_block *sb = path->dentry->d_sb;struct inode *inode =d_inode (path->dentry);
fs/minix/minix.h +2 -1
@@ -51,7 +51,8 @@ extern unsigned long minix_count_free_inodes(struct super_block *sb);extern int minix_new_block (struct inode * inode);extern void minix_free_block (struct inode *inode,unsigned long block);extern unsigned long minix_count_free_blocks (struct super_block *sb); -extern int minix_getattr (const struct path *,struct kstat *,u32 ,unsigned int ); +extern int minix_getattr (struct user_namespace *,const struct path *, +struct kstat *,u32 ,unsigned int );extern int minix_prepare_chunk (struct page *page,loff_t pos,unsigned len);extern void V1_minix_truncate (struct inode *);
fs/minix/namei.c +14 -10
@@ -33,7 +33,8 @@ static struct dentry *minix_lookup(struct inode * dir, struct dentry *dentry, unreturn d_splice_alias (inode, dentry); } -static int minix_mknod (struct inode * dir,struct dentry *dentry,umode_t mode,dev_t rdev) +static int minix_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {int error;struct inode *inode;
@@ -51,7 +52,8 @@ static int minix_mknod(struct inode * dir, struct dentry *dentry, umode_t mode,return error; } -static int minix_tmpfile (struct inode *dir,struct dentry *dentry,umode_t mode) +static int minix_tmpfile (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {int error;struct inode *inode =minix_new_inode (dir, mode, &error);
@@ -63,14 +65,14 @@ static int minix_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)return error; } -static int minix_create (struct inode *dir,struct dentry *dentry,umode_t mode, -bool excl) +static int minix_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) { -return minix_mknod (dir, dentry, mode,0 ); +return minix_mknod (mnt_userns, dir, dentry, mode,0 ); } -static int minix_symlink (struct inode * dir,struct dentry *dentry, -const char * symname) +static int minix_symlink (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,const char *symname) {int err = -ENAMETOOLONG ;int i =strlen (symname)+1 ;
@@ -109,7 +111,8 @@ static int minix_link(struct dentry * old_dentry, struct inode * dir,return add_nondir (dentry, inode); } -static int minix_mkdir (struct inode * dir,struct dentry *dentry,umode_t mode) +static int minix_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct inode * inode;int err;
@@ -181,8 +184,9 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)return err; } -static int minix_rename (struct inode * old_dir,struct dentry *old_dentry, -struct inode * new_dir,struct dentry *new_dentry, +static int minix_rename (struct user_namespace *mnt_userns, +struct inode *old_dir,struct dentry *old_dentry, +struct inode *new_dir,struct dentry *new_dentry,unsigned int flags) {struct inode * old_inode =d_inode (old_dentry);
fs/namei.c +28 -23
196 lines not on this page · raw message
fs/nfs/dir.c +14 -9
@@ -2095,8 +2095,8 @@ EXPORT_SYMBOL_GPL(nfs_instantiate);* that the operation succeeded on the server, but an error in the * reply path made it appear to have failed. */ -int nfs_create (struct inode *dir,struct dentry *dentry, -umode_t mode,bool excl) +int nfs_create (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,bool excl) {struct iattr attr;int open_flags = excl ?O_CREAT |O_EXCL :O_CREAT ;
@@ -2124,7 +2124,8 @@ EXPORT_SYMBOL_GPL(nfs_create);* See comments for nfs_proc_create regarding failed operations. */ int -nfs_mknod (struct inode *dir,struct dentry *dentry,umode_t mode,dev_t rdev) +nfs_mknod (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode,dev_t rdev) {struct iattr attr;int status;
@@ -2150,7 +2151,8 @@ EXPORT_SYMBOL_GPL(nfs_mknod);/* * See comments for nfs_proc_create regarding failed operations. */ -int nfs_mkdir (struct inode *dir,struct dentry *dentry,umode_t mode) +int nfs_mkdir (struct user_namespace *mnt_userns,struct inode *dir, +struct dentry *dentry,umode_t mode) {struct iattr attr;int error;
@@ -2295,7 +2297,8 @@ EXPORT_SYMBOL_GPL(nfs_unlink);* now have a new file handle and can instantiate an in-core NFS inode * and move the raw page into its mapping. */ -int nfs_symlink (struct inode *dir,struct dentry *dentry,const char *symname) +int nfs_symlink(struct user_namespace *mnt_userns, struct inode *dir,
Lines of this file are not shown. View the raw message.
fs/xfs/xfs_iops.c +30 -22
52 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.30.0
Part of the diff is not shown here. View the raw message.
Re: [PATCH v5 32/42] fs: make helpers idmap mount aware
Looks good,
_______________________________________________
Containers mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/containers
PATCH v5 33/42 apparmor: handle idmapped mounts
In reply to Christian BraunerThe i_uid and i_gid are only ever used when logging for AppArmor. This is already broken in a bunch of places where the global root id is reported instead of the i_uid or i_gid of the file. Nonetheless, be kind and log the mapped inode if we're coming from an idmapped mount. If the initial user namespace is passed nothing changes so non-idmapped mounts will see identical behavior as before.
---
/* v2 */
unchanged
/* v3 */
unchanged
/* v4 */
- Serge Hallyn <[email protected]>:
- Use "mnt_userns" to refer to a vfsmount's userns everywhere to make terminology consistent.
/* v5 */
base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837
- Christoph Hellwig <[email protected]>:
- Use new file_userns_helper().
--- security/apparmor/domain.c | 9 ++++++--- security/apparmor/file.c | 5 ++++- security/apparmor/lsm.c | 12 ++++++++---- 3 files changed, 18 insertions(+), 8 deletions(-)
security/apparmor/domain.c +6 -3
@@ -10,12 +10,14 @@#include <linux/errno.h> #include <linux/fdtable.h> +#include <linux/fs.h> #include <linux/file.h> #include <linux/mount.h> #include <linux/syscalls.h> #include <linux/tracehook.h> #include <linux/personality.h> #include <linux/xattr.h> +#include <linux/user_namespace.h> #include "include/audit.h" #include "include/apparmorfs.h"
@@ -858,8 +860,10 @@ int apparmor_bprm_creds_for_exec(struct linux_binprm *bprm)const char *info =NULL ;int error =0 ;bool unsafe = false; +struct user_namespace *mnt_userns =file_user_ns (bprm->file); +kuid_t i_uid =i_uid_into_mnt (mnt_userns,file_inode (bprm->file));struct path_cond cond = { -file_inode (bprm->file)->i_uid, + i_uid,file_inode (bprm->file)->i_mode };
@@ -967,8 +971,7 @@ int apparmor_bprm_creds_for_exec(struct linux_binprm *bprm) error =fn_for_each (label, profile,aa_audit_file (profile, &nullperms,OP_EXEC ,MAY_EXEC , bprm->filename,NULL , new, -file_inode (bprm->file)->i_uid, info, - error)); + i_uid, info, error));aa_put_label (new); goto done; }
security/apparmor/file.c +4 -1
@@ -11,6 +11,8 @@#include <linux/tty.h> #include <linux/fdtable.h> #include <linux/file.h> +#include <linux/fs.h> +#include <linux/mount.h> #include "include/apparmor.h" #include "include/audit.h"
@@ -508,8 +510,9 @@ static int __file_path_perm(const char *op, struct aa_label *label, {struct aa_profile *profile;struct aa_perms perms = {}; +struct user_namespace *mnt_userns =file_user_ns (file);struct path_cond cond = { - .uid =file_inode (file)->i_uid, + .uid =i_uid_into_mnt (mnt_userns,file_inode (file)), .mode =file_inode (file)->i_mode };char *buffer;
security/apparmor/lsm.c +8 -4
@@ -224,7 +224,8 @@ static int common_perm(const char *op, const struct path *path, u32 mask,*/ static int common_perm_cond (const char *op,const struct path *path,u32 mask) { -struct path_cond cond = {d_backing_inode (path->dentry)->i_uid, +struct user_namespace *mnt_userns =mnt_user_ns (path->mnt); +struct path_cond cond = {i_uid_into_mnt (mnt_userns,d_backing_inode (path->dentry)),d_backing_inode (path->dentry)->i_mode };
@@ -266,12 +267,13 @@ static int common_perm_rm(const char *op, const struct path *dir, struct dentry *dentry, u32 mask) {struct inode *inode =d_backing_inode (dentry); +struct user_namespace *mnt_userns =mnt_user_ns (dir->mnt);struct path_cond cond = { };if (!inode || !path_mediated_fs (dentry))return 0 ; - cond.uid = inode->i_uid; + cond.uid =i_uid_into_mnt (mnt_userns, inode); cond.mode = inode->i_mode;return common_perm_dir_dentry (op, dir, dentry, mask, &cond);
@@ -361,11 +363,12 @@ static int apparmor_path_rename(const struct path *old_dir, struct dentry *old_d label =begin_current_label_crit_section ();if (!unconfined (label)) { +struct user_namespace *mnt_userns =mnt_user_ns (old_dir->mnt);struct path old_path = { .mnt = old_dir->mnt, .dentry = old_dentry };struct path new_path = { .mnt = new_dir->mnt, .dentry = new_dentry }; -struct path_cond cond = {d_backing_inode (old_dentry)->i_uid, +struct path_cond cond = {i_uid_into_mnt (mnt_userns,d_backing_inode (old_dentry)),d_backing_inode (old_dentry)->i_mode };
@@ -420,8 +423,9 @@ static int apparmor_file_open(struct file *file) label =aa_get_newest_cred_label (file->f_cred);if (!unconfined (label)) { +struct user_namespace *mnt_userns =file_user_ns (file);struct inode *inode =file_inode (file); -struct path_cond cond = { inode->i_uid, inode->i_mode }; +struct path_cond cond = {i_uid_into_mnt (mnt_userns, inode), inode->i_mode }; error =aa_path_perm (OP_OPEN , label, &file->f_path,0 ,aa_map_file_to_perms (file), &cond);
Signature · 6 lines
2.30.0 _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
PATCH v5 34/42 ima: handle idmapped mounts
In reply to Christian BraunerIMA does sometimes access the inode's i_uid and compares it against the rules' fowner. Enable IMA to handle idmapped mounts by passing down the mount's user namespace. We simply make use of the helpers we introduced before. If the initial user namespace is passed nothing changes so non-idmapped mounts will see identical behavior as before.
---
/* v2 */
unchanged
/* v3 */
unchanged
/* v4 */
- Serge Hallyn <[email protected]>:
- Use "mnt_userns" to refer to a vfsmount's userns everywhere to make terminology consistent.
/* v5 */
base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837
- Christoph Hellwig <[email protected]>:
- Use new file_userns_helper().
--- fs/attr.c | 2 +- fs/namei.c | 4 +-- include/linux/ima.h | 17 +++++++---- security/integrity/ima/ima.h | 19 +++++++----- security/integrity/ima/ima_api.c | 10 ++++--- security/integrity/ima/ima_appraise.c | 14 +++++---- security/integrity/ima/ima_asymmetric_keys.c | 2 +- security/integrity/ima/ima_main.c | 31 ++++++++++++-------- security/integrity/ima/ima_policy.c | 19 +++++++----- security/integrity/ima/ima_queue_keys.c | 2 +- 10 files changed, 72 insertions(+), 48 deletions(-)
fs/attr.c +1 -1
@@ -399,7 +399,7 @@ int notify_change(struct user_namespace *mnt_userns, struct dentry *dentry,if (!error) {fsnotify_change (dentry, ia_valid); -ima_inode_post_setattr (dentry); +ima_inode_post_setattr (mnt_userns, dentry);evm_inode_post_setattr (dentry, ia_valid); }
fs/namei.c +2 -2
@@ -3425,7 +3425,7 @@ struct dentry *vfs_tmpfile(struct user_namespace *mnt_userns, inode->i_state |=I_LINKABLE ;spin_unlock (&inode->i_lock); } -ima_post_create_tmpfile (inode); +ima_post_create_tmpfile (mnt_userns, inode);return child; out_err:
@@ -3753,7 +3753,7 @@ static long do_mknodat(int dfd, const char __user *filename, umode_t mode, error =vfs_create (mnt_userns, path.dentry->d_inode, dentry, mode, true);if (!error) -ima_post_path_mknod (dentry); +ima_post_path_mknod (mnt_userns, dentry);break ;case S_IFCHR :case S_IFBLK : error = vfs_mknod(mnt_userns, path.dentry->d_inode,
include/linux/ima.h +11 -6
@@ -16,7 +16,7 @@ struct linux_binprm;#ifdef CONFIG_IMA extern int ima_bprm_check (struct linux_binprm *bprm);extern int ima_file_check (struct file *file,int mask); -extern void ima_post_create_tmpfile (struct inode *inode); +extern void ima_post_create_tmpfile (struct user_namespace *mnt_userns,struct inode *inode);extern void ima_file_free (struct file *file);extern int ima_file_mmap (struct file *file,unsigned long prot);extern int ima_file_mprotect (struct vm_area_struct *vma,unsigned long prot);
@@ -27,7 +27,8 @@ extern int ima_read_file(struct file *file, enum kernel_read_file_id id, bool contents);extern int ima_post_read_file (struct file *file,void *buf,loff_t size,enum kernel_read_file_id id); -extern void ima_post_path_mknod (struct dentry *dentry); +extern void ima_post_path_mknod (struct user_namespace *mnt_userns, +struct dentry *dentry);extern int ima_file_hash (struct file *file,char *buf,size_t buf_size);extern int ima_inode_hash (struct inode *inode,char *buf,size_t buf_size);extern void ima_kexec_cmdline (int kernel_fd,const void *buf,int size);
@@ -68,7 +69,8 @@ static inline int ima_file_check(struct file *file, int mask)return 0 ; } -static inline void ima_post_create_tmpfile (struct inode *inode) +static inline void ima_post_create_tmpfile (struct user_namespace *mnt_userns, +struct inode *inode) { }
@@ -112,7 +114,8 @@ static inline int ima_post_read_file(struct file *file, void *buf, loff_t size,return 0 ; } -static inline void ima_post_path_mknod (struct dentry *dentry) +static inline void ima_post_path_mknod (struct user_namespace *mnt_userns, +struct dentry *dentry) {return ; }
@@ -153,7 +156,8 @@ static inline void ima_post_key_create_or_update(struct key *keyring,#ifdef CONFIG_IMA_APPRAISE extern bool is_ima_appraise_enabled (void ); -extern void ima_inode_post_setattr (struct dentry *dentry); +extern void ima_inode_post_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry);extern int ima_inode_setxattr (struct dentry *dentry,const char *xattr_name,const void *xattr_value,size_t xattr_value_len);extern int ima_inode_removexattr (struct dentry *dentry,const char *xattr_name);
@@ -163,7 +167,8 @@ static inline bool is_ima_appraise_enabled(void)return 0 ; } -static inline void ima_inode_post_setattr (struct dentry *dentry) +static inline void ima_inode_post_setattr (struct user_namespace *mnt_userns, +struct dentry *dentry) {return ; }
security/integrity/ima/ima.h +12 -7
@@ -253,8 +253,9 @@ static inline void ima_process_queued_keys(void) {}#endif /* CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS */ /* LIM API function definitions */ -int ima_get_action (struct inode *inode,const struct cred *cred,u32 secid, -int mask,enum ima_hooks func,int *pcr, +int ima_get_action (struct user_namespace *mnt_userns,struct inode *inode, +const struct cred *cred,u32 secid,int mask, +enum ima_hooks func,int *pcr,struct ima_template_desc **template_desc,const char *keyring);int ima_must_measure (struct inode *inode,int mask,enum ima_hooks func);
@@ -266,7 +267,8 @@ void ima_store_measurement(struct integrity_iint_cache *iint, struct file *file,struct evm_ima_xattr_data *xattr_value, int xattr_len, const struct modsig *modsig, int pcr, struct ima_template_desc *template_desc); -void process_buffer_measurement (struct inode *inode,const void *buf,int size, +void process_buffer_measurement (struct user_namespace *mnt_userns, +struct inode *inode,const void *buf,int size,const char *eventname,enum ima_hooks func,int pcr,const char *keyring); void ima_audit_measurement(struct integrity_iint_cache *iint,
@@ -281,8 +283,9 @@ void ima_free_template_entry(struct ima_template_entry *entry);const char *ima_d_path (const struct path *path,char **pathbuf,char *filename);/* IMA policy related functions */ -int ima_match_policy (struct inode *inode,const struct cred *cred,u32 secid, -enum ima_hooks func,int mask,int flags,int *pcr, +int ima_match_policy (struct user_namespace *mnt_userns,struct inode *inode, +const struct cred *cred,u32 secid,enum ima_hooks func, +int mask,int flags,int *pcr,struct ima_template_desc **template_desc,const char *keyring);void ima_init_policy (void );
@@ -313,7 +316,8 @@ int ima_appraise_measurement(enum ima_hooks func, struct file *file, const unsigned char *filename, struct evm_ima_xattr_data *xattr_value, int xattr_len, const struct modsig *modsig); -int ima_must_appraise (struct inode *inode,int mask,enum ima_hooks func); +int ima_must_appraise (struct user_namespace *mnt_userns,struct inode *inode, +int mask,enum ima_hooks func);void ima_update_xattr (struct integrity_iint_cache *iint,struct file *file);enum integrity_status ima_get_cache_status (struct integrity_iint_cache *iint,enum ima_hooks func);
@@ -340,7 +344,8 @@ static inline int ima_appraise_measurement(enum ima_hooks func,return INTEGRITY_UNKNOWN ; } -static inline int ima_must_appraise (struct inode *inode,int mask, +static inline int ima_must_appraise (struct user_namespace *mnt_userns, +struct inode *inode,int mask,enum ima_hooks func) {return 0 ;
security/integrity/ima/ima_api.c +6 -4
@@ -162,6 +162,7 @@ void ima_add_violation(struct file *file, const unsigned char *filename,/** * ima_get_action - appraise & measure decision based on policy. +* @mnt_userns: user namespace of the mount the inode was found from * @inode: pointer to the inode associated with the object being validated * @cred: pointer to credentials structure to validate * @secid: secid of the task being validated
@@ -183,8 +184,9 @@ void ima_add_violation(struct file *file, const unsigned char *filename,* Returns IMA_MEASURE, IMA_APPRAISE mask. * */ -int ima_get_action (struct inode *inode,const struct cred *cred,u32 secid, -int mask,enum ima_hooks func,int *pcr, +int ima_get_action (struct user_namespace *mnt_userns,struct inode *inode, +const struct cred *cred,u32 secid,int mask, +enum ima_hooks func,int *pcr,struct ima_template_desc **template_desc,const char *keyring) {
@@ -192,8 +194,8 @@ int ima_get_action(struct inode *inode, const struct cred *cred, u32 secid, flags &= ima_policy_flag; -return ima_match_policy (inode, cred, secid, func, mask, flags, pcr, - template_desc, keyring); +return ima_match_policy (mnt_userns, inode, cred, secid, func, mask, flags, + pcr, template_desc, keyring); }/*
security/integrity/ima/ima_appraise.c +8 -6
@@ -68,7 +68,8 @@ bool is_ima_appraise_enabled(void)* * Return 1 to appraise or hash */ -int ima_must_appraise (struct inode *inode,int mask,enum ima_hooks func) +int ima_must_appraise (struct user_namespace *mnt_userns,struct inode *inode, +int mask,enum ima_hooks func) {u32 secid;
@@ -76,8 +77,8 @@ int ima_must_appraise(struct inode *inode, int mask, enum ima_hooks func)return 0 ;security_task_getsecid (current, &secid); -return ima_match_policy (inode,current_cred (), secid, func, mask, -IMA_APPRAISE |IMA_HASH ,NULL ,NULL ,NULL ); +return ima_match_policy (mnt_userns, inode,current_cred (), secid, func, + mask,IMA_APPRAISE |IMA_HASH ,NULL ,NULL ,NULL ); } static int ima_fix_xattr(struct dentry *dentry,
@@ -350,7 +351,7 @@ int ima_check_blacklist(struct integrity_iint_cache *iint, rc =is_binary_blacklisted (digest, digestsize);if ((rc == -EPERM ) && (iint->flags &IMA_MEASURE )) -process_buffer_measurement (NULL , digest, digestsize, +process_buffer_measurement (NULL ,NULL , digest, digestsize,"blacklisted-hash" ,NONE , pcr,NULL ); }
@@ -501,6 +502,7 @@ void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file)/** * ima_inode_post_setattr - reflect file metadata changes +* @mnt_userns: user namespace of the mount the inode was found from * @dentry: pointer to the affected dentry * * Changes to a dentry's metadata might result in needing to appraise.
@@ -508,7 +510,7 @@ void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file)* This function is called from notify_change(), which expects the caller * to lock the inode's i_mutex. */ -void ima_inode_post_setattr (struct dentry *dentry) +void ima_inode_post_setattr (struct user_namespace *mnt_userns,struct dentry *dentry) {struct inode *inode =d_backing_inode (dentry);struct integrity_iint_cache *iint;
@@ -518,7 +520,7 @@ void ima_inode_post_setattr(struct dentry *dentry) || !(inode->i_opflags & IOP_XATTR))return ; - action =ima_must_appraise (inode,MAY_ACCESS ,POST_SETATTR ); + action =ima_must_appraise (mnt_userns, inode,MAY_ACCESS ,POST_SETATTR );if (!action)__vfs_removexattr (&init_user_ns, dentry,XATTR_NAME_IMA ); iint =integrity_iint_find (inode);
security/integrity/ima/ima_asymmetric_keys.c +1 -1
@@ -58,7 +58,7 @@ void ima_post_key_create_or_update(struct key *keyring, struct key *key,* if the IMA policy is configured to measure a key linked * to the given keyring. */ -process_buffer_measurement (NULL , payload, payload_len, +process_buffer_measurement (NULL ,NULL , payload, payload_len, keyring->description,KEY_CHECK ,0 , keyring->description); }
security/integrity/ima/ima_main.c +19 -12
@@ -218,8 +218,8 @@ static int process_measurement(struct file *file, const struct cred *cred,* bitmask based on the appraise/audit/measurement policy. * Included is the appraise submask. */ - action =ima_get_action (inode, cred, secid, mask, func, &pcr, - &template_desc,NULL ); + action =ima_get_action (file_user_ns (file), inode, cred, secid, mask, + func, &pcr, &template_desc,NULL ); violation_check = ((func ==FILE_CHECK || func ==MMAP_CHECK ) && (ima_policy_flag &IMA_MEASURE ));if (!action && !violation_check)
@@ -431,8 +431,9 @@ int ima_file_mprotect(struct vm_area_struct *vma, unsigned long prot)security_task_getsecid (current, &secid); inode =file_inode (vma->vm_file); - action =ima_get_action (inode,current_cred (), secid,MAY_EXEC , -MMAP_CHECK , &pcr, &template,0 ); + action =ima_get_action (file_user_ns (vma->vm_file), inode, +current_cred (), secid,MAY_EXEC ,MMAP_CHECK , + &pcr, &template,0 );/* Is the mmap'ed file in policy? */ if (!(action & (IMA_MEASURE |IMA_APPRAISE_SUBMASK )))
@@ -592,18 +593,20 @@ EXPORT_SYMBOL_GPL(ima_inode_hash);/** * ima_post_create_tmpfile - mark newly created tmpfile as new +* @mnt_userns: user namespace of the mount the inode was found from * @file : newly created tmpfile * * No measuring, appraising or auditing of newly created tmpfiles is needed. * Skip calling process_measurement(), but indicate which newly, created * tmpfiles are in policy. */ -void ima_post_create_tmpfile (struct inode *inode) +void ima_post_create_tmpfile (struct user_namespace *mnt_userns, +struct inode *inode) {struct integrity_iint_cache *iint;int must_appraise; - must_appraise =ima_must_appraise (inode,MAY_ACCESS ,FILE_CHECK ); + must_appraise =ima_must_appraise (mnt_userns, inode,MAY_ACCESS ,FILE_CHECK );if (!must_appraise)return ;
@@ -619,18 +622,19 @@ void ima_post_create_tmpfile(struct inode *inode)/** * ima_post_path_mknod - mark as a new inode +* @mnt_userns: user namespace of the mount the inode was found from * @dentry: newly created dentry * * Mark files created via the mknodat syscall as new, so that the * file data can be written later. */ -void ima_post_path_mknod (struct dentry *dentry) +void ima_post_path_mknod (struct user_namespace *mnt_userns,struct dentry *dentry) {struct integrity_iint_cache *iint;struct inode *inode = dentry->d_inode;int must_appraise; - must_appraise =ima_must_appraise (inode,MAY_ACCESS ,FILE_CHECK ); + must_appraise =ima_must_appraise (mnt_userns, inode,MAY_ACCESS ,FILE_CHECK );if (!must_appraise)return ;
@@ -810,6 +814,7 @@ int ima_post_load_data(char *buf, loff_t size,/* * process_buffer_measurement - Measure the buffer to ima log. +* @mnt_userns: user namespace of the mount the inode was found from * @inode: inode associated with the object being measured (NULL for KEY_CHECK) * @buf: pointer to the buffer that needs to be added to the log. * @size: size of buffer(in bytes).
@@ -820,7 +825,8 @@ int ima_post_load_data(char *buf, loff_t size,* * Based on policy, the buffer is measured into the ima log. */ -void process_buffer_measurement (struct inode *inode,const void *buf,int size, +void process_buffer_measurement (struct user_namespace *mnt_userns, +struct inode *inode,const void *buf,int size,const char *eventname,enum ima_hooks func,int pcr,const char *keyring) {
@@ -860,7 +866,7 @@ void process_buffer_measurement(struct inode *inode, const void *buf, int size,*/ if (func) {security_task_getsecid (current, &secid); - action =ima_get_action (inode,current_cred (), secid,0 , func, + action =ima_get_action (mnt_userns, inode,current_cred (), secid,0 , func, &pcr, &template, keyring);if (!(action &IMA_MEASURE ))return ;
@@ -919,8 +925,9 @@ void ima_kexec_cmdline(int kernel_fd, const void *buf, int size)if (!f.file)return ; -process_buffer_measurement (file_inode (f.file), buf, size, -"kexec-cmdline" ,KEXEC_CMDLINE ,0 ,NULL ); +process_buffer_measurement (file_user_ns (f.file),file_inode (f.file), + buf, size,"kexec-cmdline" ,KEXEC_CMDLINE ,0 , +NULL );fdput (f); }
security/integrity/ima/ima_policy.c +11 -8
@@ -488,6 +488,7 @@ static bool ima_match_keyring(struct ima_rule_entry *rule,/** * ima_match_rules - determine whether an inode matches the policy rule. * @rule: a pointer to a rule +* @mnt_userns: user namespace of the mount the inode was found from * @inode: a pointer to an inode * @cred: a pointer to a credentials structure for user validation * @secid: the secid of the task to be validated
@@ -497,10 +498,10 @@ static bool ima_match_keyring(struct ima_rule_entry *rule,* * Returns true on rule match, false on failure. */ -static bool ima_match_rules (struct ima_rule_entry *rule,struct inode *inode, +static bool ima_match_rules (struct ima_rule_entry *rule, +struct user_namespace *mnt_userns,struct inode *inode,const struct cred *cred,u32 secid, -enum ima_hooks func,int mask, -const char *keyring) +enum ima_hooks func,int mask,const char *keyring) {int i;
@@ -539,7 +540,7 @@ static bool ima_match_rules(struct ima_rule_entry *rule, struct inode *inode, }if ((rule->flags &IMA_FOWNER ) && - !rule->fowner_op (inode->i_uid, rule->fowner)) + !rule->fowner_op (i_uid_into_mnt (mnt_userns, inode), rule->fowner))return false;for (i =0 ; i <MAX_LSM_RULES ; i++) {int rc =0 ;
@@ -602,6 +603,7 @@ static int get_subaction(struct ima_rule_entry *rule, enum ima_hooks func)/** * ima_match_policy - decision based on LSM and other conditions +* @mnt_userns: user namespace of the mount the inode was found from * @inode: pointer to an inode for which the policy decision is being made * @cred: pointer to a credentials structure for which the policy decision is * being made
@@ -620,8 +622,9 @@ static int get_subaction(struct ima_rule_entry *rule, enum ima_hooks func)* list when walking it. Reads are many orders of magnitude more numerous * than writes so ima_match_policy() is classical RCU candidate. */ -int ima_match_policy (struct inode *inode,const struct cred *cred,u32 secid, -enum ima_hooks func,int mask,int flags,int *pcr, +int ima_match_policy (struct user_namespace *mnt_userns,struct inode *inode, +const struct cred *cred,u32 secid,enum ima_hooks func, +int mask,int flags,int *pcr,struct ima_template_desc **template_desc,const char *keyring) {
@@ -637,8 +640,8 @@ int ima_match_policy(struct inode *inode, const struct cred *cred, u32 secid,if (!(entry->action & actmask))continue ; -if (!ima_match_rules (entry, inode, cred, secid, func, mask, - keyring)) +if (!ima_match_rules (entry, mnt_userns, inode, cred, secid, func, + mask, keyring))continue ; action |= entry->flags &IMA_ACTION_FLAGS ;
security/integrity/ima/ima_queue_keys.c +1 -1
@@ -158,7 +158,7 @@ void ima_process_queued_keys(void)list_for_each_entry_safe (entry, tmp, &ima_keys, list) {if (!timer_expired) - process_buffer_measurement(NULL, entry->payload, + process_buffer_measurement(NULL, NULL, entry->payload, entry->payload_len, entry->keyring_name, KEY_CHECK, 0,
Signature · 1 line
2.30.0
PATCH v5 35/42 fat: handle idmapped mounts
In reply to Christian BraunerLet fat handle idmapped mounts. This allows to have the same fat mount appear in multiple locations with different id mappings. This allows to expose a vfat formatted USB stick to multiple user with different ids on the host or in user namespaces allowing for dac permissions:
mount -o uid=1000,gid=1000 /dev/sdb /mnt
u1001@f2-vm:/lower1$ ls -ln /mnt/ total 4 -rwxr-xr-x 1 1000 1000 4 Oct 28 03:44 aaa -rwxr-xr-x 1 1000 1000 0 Oct 28 01:09 bbb -rwxr-xr-x 1 1000 1000 0 Oct 28 01:10 ccc -rwxr-xr-x 1 1000 1000 0 Oct 28 03:46 ddd -rwxr-xr-x 1 1000 1000 0 Oct 28 04:01 eee
mount-idmapped --map-mount b:1000:1001:1
u1001@f2-vm:/lower1$ ls -ln /lower1/ total 4 -rwxr-xr-x 1 1001 1001 4 Oct 28 03:44 aaa -rwxr-xr-x 1 1001 1001 0 Oct 28 01:09 bbb -rwxr-xr-x 1 1001 1001 0 Oct 28 01:10 ccc -rwxr-xr-x 1 1001 1001 0 Oct 28 03:46 ddd -rwxr-xr-x 1 1001 1001 0 Oct 28 04:01 eee
u1001@f2-vm:/lower1$ touch /lower1/fff
u1001@f2-vm:/lower1$ ls -ln /lower1/fff -rwxr-xr-x 1 1001 1001 0 Oct 28 04:03 /lower1/fff
u1001@f2-vm:/lower1$ ls -ln /mnt/fff -rwxr-xr-x 1 1000 1000 0 Oct 28 04:03 /mnt/fff
---
/* v2 */
unchanged
/* v3 */
unchanged
/* v4 */
- Mauricio Vásquez Bernal <[email protected]>:
- Fix mount example in commit message.
- Serge Hallyn <[email protected]>:
- Use "mnt_userns" to refer to a vfsmount's userns everywhere to make terminology consistent.
/* v5 */
base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837
--- fs/fat/file.c | 15 ++++++++------- fs/fat/namei_msdos.c | 2 +- fs/fat/namei_vfat.c | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-)
fs/fat/file.c +8 -7
@@ -398,7 +398,7 @@ int fat_getattr(struct user_namespace *mnt_userns, const struct path *path, struct kstat *stat, u32 request_mask, unsigned int flags) { struct inode *inode = d_inode(path->dentry); -generic_fillattr (&init_user_ns, inode, stat); +generic_fillattr (mnt_userns, inode, stat); stat->blksize =MSDOS_SB (inode->i_sb)->cluster_size;if (MSDOS_SB (inode->i_sb)->options.nfs ==FAT_NFS_NOSTALE_RO ) {
@@ -447,12 +447,13 @@ static int fat_sanitize_mode(const struct msdos_sb_info *sbi,return 0 ; } -static int fat_allow_set_time (struct msdos_sb_info *sbi,struct inode *inode) +static int fat_allow_set_time (struct user_namespace *mnt_userns, +struct msdos_sb_info *sbi,struct inode *inode) {umode_t allow_utime = sbi->options.allow_utime; -if (!uid_eq (current_fsuid (), inode->i_uid)) { -if (in_group_p (inode->i_gid)) +if (!uid_eq (current_fsuid (),i_uid_into_mnt (mnt_userns, inode))) { +if (in_group_p (i_gid_into_mnt (mnt_userns, inode))) allow_utime >>=3 ;if (allow_utime &MAY_WRITE )return 1 ;
@@ -477,11 +478,11 @@ int fat_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,/* Check for setting the inode time. */ ia_valid = attr->ia_valid;if (ia_valid &TIMES_SET_FLAGS ) { -if (fat_allow_set_time (sbi, inode)) +if (fat_allow_set_time (mnt_userns, sbi, inode)) attr->ia_valid &= ~TIMES_SET_FLAGS ; } - error =setattr_prepare (&init_user_ns, dentry, attr); + error =setattr_prepare (mnt_userns, dentry, attr); attr->ia_valid = ia_valid;if (error) {if (sbi->options.quiet)
@@ -551,7 +552,7 @@ int fat_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,fat_truncate_time (inode, &attr->ia_mtime,S_MTIME ); attr->ia_valid &= ~(ATTR_ATIME |ATTR_CTIME |ATTR_MTIME ); -setattr_copy (&init_user_ns, inode, attr); +setattr_copy (mnt_userns, inode, attr);mark_inode_dirty (inode); out:return error;
fs/fat/namei_msdos.c +1 -1
@@ -667,7 +667,7 @@ static struct file_system_type msdos_fs_type = { .name = "msdos", .mount = msdos_mount, .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV, + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, };MODULE_ALIAS_FS ("msdos" );
fs/fat/namei_vfat.c +1 -1
@@ -1063,7 +1063,7 @@ static struct file_system_type vfat_fs_type = { .name = "vfat", .mount = vfat_mount, .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV, + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, };MODULE_ALIAS_FS ("vfat" );
Signature · 6 lines
2.30.0 _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
PATCH v5 36/42 ext4: support idmapped mounts
In reply to Christian BraunerEnable idmapped mounts for ext4. All dedicated helpers we need for this exist. The vfs will have already made sure that the caller's fsids are valid when mapped according to the mount's user namespace and that they and have a mapping in the filesystem's s_user_ns.
So map the caller's fsids according to the mount's user namespace when initializing a new inode. The inode_init_owner() helper will already take care of this for the common case. If the initial user namespace is passed nothing changes so non-idmapped mounts will see identical behavior as before.
It is also noteworthy that the idmapped mount implementation allows us to cleanly handle ioctls() too.
Let's create simple example where we idmap an ext4 filesystem:
root@f2-vm:~# truncate -s 5G ext4.img
root@f2-vm:~# mkfs.ext4 ./ext4.img
mke2fs 1.45.5 (07-Jan-2020)
Discarding device blocks: done
Creating filesystem with 1310720 4k blocks and 327680 inodes
Filesystem UUID: 3fd91794-c6ca-4b0f-9964-289a000919cf
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736 Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
root@f2-vm:~# losetup -f --show ./ext4.img /dev/loop0
root@f2-vm:~# mount /dev/loop0 /mnt
root@f2-vm:~# ls -al /mnt/ total 24 drwxr-xr-x 3 root root 4096 Oct 28 13:34 . drwxr-xr-x 30 root root 4096 Oct 28 13:22 .. drwx------ 2 root root 16384 Oct 28 13:34 lost+found
# Let's create an idmapped mount at /idmapped1 where we map uid and gid # 0 to uid and gid 1000
root@f2-vm:/# ./mount-idmapped --map-mount b:0:1000:1 /mnt/ /idmapped1/
root@f2-vm:/# ls -al /idmapped1/ total 24 drwxr-xr-x 3 ubuntu ubuntu 4096 Oct 28 13:34 . drwxr-xr-x 30 root root 4096 Oct 28 13:22 .. drwx------ 2 ubuntu ubuntu 16384 Oct 28 13:34 lost+found
# Let's create an idmapped mount at /idmapped2 where we map uid and gid # 0 to uid and gid 2000
root@f2-vm:/# ./mount-idmapped --map-mount b:0:2000:1 /mnt/ /idmapped2/
root@f2-vm:/# ls -al /idmapped2/ total 24 drwxr-xr-x 3 2000 2000 4096 Oct 28 13:34 . drwxr-xr-x 31 root root 4096 Oct 28 13:39 .. drwx------ 2 2000 2000 16384 Oct 28 13:34 lost+found
Let's create another example where we idmap the rootfs filesystem without a mapping for uid 0 and gid 0:
# Create an idmapped mount of for a full POSIX range of rootfs under
# /mnt but without a mapping for uid 0 to reduce attack surface
root@f2-vm:/# ./mount-idmapped --map-mount b:1:1:65536 / /mnt/
# Since we don't have a mapping for uid and gid 0 all files owned by
# uid and gid 0 should show up as uid and gid 65534: root@f2-vm:/# ls -al /mnt/ total 664 drwxr-xr-x 31 nobody nogroup 4096 Oct 28 13:39 . drwxr-xr-x 31 root root 4096 Oct 28 13:39 .. lrwxrwxrwx 1 nobody nogroup 7 Aug 25 07:44 bin -> usr/bin drwxr-xr-x 4 nobody nogroup 4096 Oct 28 13:17 boot drwxr-xr-x 2 nobody nogroup 4096 Aug 25 07:48 dev drwxr-xr-x 81 nobody nogroup 4096 Oct 28 04:00 etc drwxr-xr-x 4 nobody nogroup 4096 Oct 28 04:00 home lrwxrwxrwx 1 nobody nogroup 7 Aug 25 07:44 lib -> usr/lib lrwxrwxrwx 1 nobody nogroup 9 Aug 25 07:44 lib32 -> usr/lib32 lrwxrwxrwx 1 nobody nogroup 9 Aug 25 07:44 lib64 -> usr/lib64 lrwxrwxrwx 1 nobody nogroup 10 Aug 25 07:44 libx32 -> usr/libx32 drwx------ 2 nobody nogroup 16384 Aug 25 07:47 lost+found drwxr-xr-x 2 nobody nogroup 4096 Aug 25 07:44 media drwxr-xr-x 31 nobody nogroup 4096 Oct 28 13:39 mnt drwxr-xr-x 2 nobody nogroup 4096 Aug 25 07:44 opt drwxr-xr-x 2 nobody nogroup 4096 Apr 15 2020 proc drwx--x--x 6 nobody nogroup 4096 Oct 28 13:34 root drwxr-xr-x 2 nobody nogroup 4096 Aug 25 07:46 run lrwxrwxrwx 1 nobody nogroup 8 Aug 25 07:44 sbin -> usr/sbin drwxr-xr-x 2 nobody nogroup 4096 Aug 25 07:44 srv drwxr-xr-x 2 nobody nogroup 4096 Apr 15 2020 sys drwxrwxrwt 10 nobody nogroup 4096 Oct 28 13:19 tmp drwxr-xr-x 14 nobody nogroup 4096 Oct 20 13:00 usr drwxr-xr-x 12 nobody nogroup 4096 Aug 25 07:45 var
# Since we do have a mapping for uid and gid 1000 all files owned by
# uid and gid 1000 should simply show up as uid and gid 1000: root@f2-vm:/# ls -al /mnt/home/ubuntu/ total 40 drwxr-xr-x 3 ubuntu ubuntu 4096 Oct 28 00:43 . drwxr-xr-x 4 nobody nogroup 4096 Oct 28 04:00 .. -rw------- 1 ubuntu ubuntu 2936 Oct 28 12:26 .bash_history -rw-r--r-- 1 ubuntu ubuntu 220 Feb 25 2020 .bash_logout -rw-r--r-- 1 ubuntu ubuntu 3771 Feb 25 2020 .bashrc -rw-r--r-- 1 ubuntu ubuntu 807 Feb 25 2020 .profile -rw-r--r-- 1 ubuntu ubuntu 0 Oct 16 16:11 .sudo_as_admin_successful -rw------- 1 ubuntu ubuntu 1144 Oct 28 00:43 .viminfo
---
/* v2 */
unchanged
/* v3 */
unchanged
/* v4 */
- Mauricio Vásquez Bernal <[email protected]>:
- Fix spelling mistake in ext4's new idmapped mount config option.
- Christoph Hellwig <[email protected]>:
- Drop the config option. If ever want an administrator to disable this feature we can simply introduce a sysctl.
- Serge Hallyn <[email protected]>:
- Use "mnt_userns" to refer to a vfsmount's userns everywhere to make terminology consistent.
/* v5 */
base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837
- Christoph Hellwig <[email protected]>:
- Use new file_userns_helper().
- Christian Brauner <[email protected]>:
- Improve commit message.
--- fs/ext4/acl.c | 2 +- fs/ext4/ext4.h | 13 +++++++------ fs/ext4/ialloc.c | 7 ++++--- fs/ext4/inode.c | 11 ++++++----- fs/ext4/ioctl.c | 19 +++++++++++-------- fs/ext4/namei.c | 30 ++++++++++++++++-------------- fs/ext4/super.c | 2 +- 7 files changed, 46 insertions(+), 38 deletions(-)
fs/ext4/acl.c +1 -1
@@ -246,7 +246,7 @@ ext4_set_acl(struct user_namespace *mnt_userns, struct inode *inode,ext4_fc_start_update (inode);if ((type ==ACL_TYPE_ACCESS ) && acl) { - error =posix_acl_update_mode (&init_user_ns, inode, &mode, &acl); + error =posix_acl_update_mode (mnt_userns, inode, &mode, &acl);if (error) goto out_stop;if (mode != inode->i_mode)
fs/ext4/ext4.h +7 -6
@@ -2755,18 +2755,19 @@ extern int ext4fs_dirhash(const struct inode *dir, const char *name, int len,/* ialloc.c */ extern int ext4_mark_inode_used (struct super_block *sb,int ino); -extern struct inode *__ext4_new_inode (handle_t *,struct inode *,umode_t , +extern struct inode *__ext4_new_inode (struct user_namespace *,handle_t *, +struct inode *,umode_t ,const struct qstr *qstr,__u32 goal,uid_t *owner,__u32 i_flags,int handle_type,unsigned int line_no,int nblocks); -#define ext4_new_inode (handle, dir, mode, qstr, goal, owner, i_flags) \ - __ext4_new_inode((handle), (dir), (mode), (qstr), (goal), (owner), \ - i_flags, 0, 0, 0) -#define ext4_new_inode_start_handle (dir, mode, qstr, goal, owner, \ +#define ext4_new_inode (handle, dir, mode, qstr, goal, owner, i_flags) \ + __ext4_new_inode(&init_user_ns, (handle), (dir), (mode), (qstr), \ + (goal), (owner), i_flags, 0, 0, 0) +#define ext4_new_inode_start_handle (mnt_userns, dir, mode, qstr, goal, owner, \ type, nblocks) \ - __ext4_new_inode(NULL, (dir), (mode), (qstr), (goal), (owner), \ + __ext4_new_inode((mnt_userns), NULL, (dir), (mode), (qstr), (goal), (owner), \ 0, (type), __LINE__, (nblocks))
fs/ext4/ialloc.c +4 -3
@@ -919,7 +919,8 @@ static int ext4_xattr_credits_for_new_inode(struct inode *dir, mode_t mode,* For other inodes, search forward from the parent directory's block * group to find a free inode. */ -struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir, +struct inode *__ext4_new_inode(struct user_namespace *mnt_userns, + handle_t *handle, struct inode *dir, umode_t mode, const struct qstr *qstr, __u32 goal, uid_t *owner, __u32 i_flags, int handle_type, unsigned int line_no,
@@ -969,10 +970,10 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,i_gid_write (inode, owner[1 ]); }else if (test_opt (sb,GRPID )) { inode->i_mode = mode; - inode->i_uid =current_fsuid (); + inode->i_uid =fsuid_into_mnt (mnt_userns); inode->i_gid = dir->i_gid; }else -inode_init_owner (&init_user_ns, inode, dir, mode); +inode_init_owner (mnt_userns, inode, dir, mode);if (ext4_has_feature_project (sb) &&ext4_test_inode_flag (dir,EXT4_INODE_PROJINHERIT ))
fs/ext4/inode.c +6 -5
@@ -20,6 +20,7 @@*/ #include <linux/fs.h> +#include <linux/mount.h> #include <linux/time.h> #include <linux/highuid.h> #include <linux/pagemap.h>
@@ -5334,7 +5335,7 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, ATTR_GID | ATTR_TIMES_SET))))return -EPERM ; - error =setattr_prepare (&init_user_ns, dentry, attr); + error =setattr_prepare (mnt_userns, dentry, attr);if (error)return error;
@@ -5509,7 +5510,7 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, }if (!error) { -setattr_copy (&init_user_ns, inode, attr); +setattr_copy (mnt_userns, inode, attr);mark_inode_dirty (inode); }
@@ -5521,7 +5522,7 @@ int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,ext4_orphan_del (NULL , inode);if (!error && (ia_valid &ATTR_MODE )) - rc =posix_acl_chmod (&init_user_ns, inode, inode->i_mode); + rc =posix_acl_chmod (mnt_userns, inode, inode->i_mode); err_out:if (error)
@@ -5568,7 +5569,7 @@ int ext4_getattr(struct user_namespace *mnt_userns, const struct path *path,STATX_ATTR_NODUMP | STATX_ATTR_VERITY); -generic_fillattr (&init_user_ns, inode, stat); +generic_fillattr (mnt_userns, inode, stat);return 0 ; }
@@ -5579,7 +5580,7 @@ int ext4_file_getattr(struct user_namespace *mnt_userns,struct inode *inode =d_inode (path->dentry);u64 delalloc_blocks; -ext4_getattr (&init_user_ns, path, stat, request_mask, query_flags); +ext4_getattr (mnt_userns, path, stat, request_mask, query_flags);/* * If there is inline data in the inode, the inode will normally not
fs/ext4/ioctl.c +11 -8
@@ -107,10 +107,12 @@ void ext4_reset_inode_seed(struct inode *inode)* important fields of the inodes. * * @sb: the super block of the filesystem +* @mnt_userns: user namespace of the mount the inode was found from * @inode: the inode to swap with EXT4_BOOT_LOADER_INO * */ static long swap_inode_boot_loader (struct super_block *sb, +struct user_namespace *mnt_userns,struct inode *inode) {handle_t *handle;
@@ -139,7 +141,7 @@ static long swap_inode_boot_loader(struct super_block *sb, }if (IS_RDONLY (inode) ||IS_APPEND (inode) ||IS_IMMUTABLE (inode) || - !inode_owner_or_capable (&init_user_ns, inode) || !capable (CAP_SYS_ADMIN )) { + !inode_owner_or_capable (mnt_userns, inode) || !capable (CAP_SYS_ADMIN )) { err = -EPERM ; goto journal_err_out; }
@@ -814,6 +816,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)struct inode *inode =file_inode (filp);struct super_block *sb = inode->i_sb;struct ext4_inode_info *ei =EXT4_I (inode); +struct user_namespace *mnt_userns =file_user_ns (filp);unsigned int flags;ext4_debug ("cmd = %u, arg = %lu\n" , cmd, arg);
@@ -829,7 +832,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)case FS_IOC_SETFLAGS : {int err; -if (!inode_owner_or_capable (&init_user_ns, inode)) +if (!inode_owner_or_capable (mnt_userns, inode))return -EACCES ;if (get_user (flags, (int __user *) arg))
@@ -871,7 +874,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)__u32 generation;int err; -if (!inode_owner_or_capable (&init_user_ns, inode)) +if (!inode_owner_or_capable (mnt_userns, inode))return -EPERM ;if (ext4_has_metadata_csum (inode->i_sb)) {
@@ -1010,7 +1013,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)case EXT4_IOC_MIGRATE : {int err; -if (!inode_owner_or_capable (&init_user_ns, inode)) +if (!inode_owner_or_capable (mnt_userns, inode))return -EACCES ; err =mnt_want_write_file (filp);
@@ -1032,7 +1035,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)case EXT4_IOC_ALLOC_DA_BLKS : {int err; -if (!inode_owner_or_capable (&init_user_ns, inode)) +if (!inode_owner_or_capable (mnt_userns, inode))return -EACCES ; err =mnt_want_write_file (filp);
@@ -1051,7 +1054,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) err =mnt_want_write_file (filp);if (err)return err; - err =swap_inode_boot_loader (sb, inode); + err =swap_inode_boot_loader (sb, mnt_userns, inode);mnt_drop_write_file (filp);return err; }
@@ -1214,7 +1217,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)case EXT4_IOC_CLEAR_ES_CACHE : { -if (!inode_owner_or_capable (&init_user_ns, inode)) +if (!inode_owner_or_capable (mnt_userns, inode))return -EACCES ;ext4_clear_inode_es (inode);return 0 ;
@@ -1260,7 +1263,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)return -EFAULT ;/* Make sure caller has proper permission */ -if (!inode_owner_or_capable (&init_user_ns, inode)) +if (!inode_owner_or_capable (mnt_userns, inode))return -EACCES ;if (fa.fsx_xflags & ~EXT4_SUPPORTED_FS_XFLAGS )
fs/ext4/namei.c +16 -14
@@ -2610,8 +2610,8 @@ static int ext4_create(struct user_namespace *mnt_userns, struct inode *dir, credits = (EXT4_DATA_TRANS_BLOCKS (dir->i_sb) +EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 ); retry: - inode =ext4_new_inode_start_handle (dir, mode, &dentry->d_name,0 , -NULL ,EXT4_HT_DIR , credits); + inode =ext4_new_inode_start_handle (mnt_userns, dir, mode, &dentry->d_name, +0 ,NULL ,EXT4_HT_DIR , credits); handle =ext4_journal_current_handle (); err =PTR_ERR (inode);if (!IS_ERR (inode)) {
@@ -2645,8 +2645,8 @@ static int ext4_mknod(struct user_namespace *mnt_userns, struct inode *dir, credits = (EXT4_DATA_TRANS_BLOCKS (dir->i_sb) +EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 ); retry: - inode =ext4_new_inode_start_handle (dir, mode, &dentry->d_name,0 , -NULL ,EXT4_HT_DIR , credits); + inode =ext4_new_inode_start_handle (mnt_userns, dir, mode, &dentry->d_name, +0 ,NULL ,EXT4_HT_DIR , credits); handle =ext4_journal_current_handle (); err =PTR_ERR (inode);if (!IS_ERR (inode)) {
@@ -2677,7 +2677,7 @@ static int ext4_tmpfile(struct user_namespace *mnt_userns, struct inode *dir,return err; retry: - inode = ext4_new_inode_start_handle(dir, mode, + inode = ext4_new_inode_start_handle(mnt_userns, dir, mode, NULL, 0, NULL, EXT4_HT_DIR, EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb) +
@@ -2792,7 +2792,7 @@ static int ext4_mkdir(struct user_namespace *mnt_userns, struct inode *dir, credits = (EXT4_DATA_TRANS_BLOCKS (dir->i_sb) +EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 ); retry: - inode =ext4_new_inode_start_handle (dir,S_IFDIR | mode, + inode =ext4_new_inode_start_handle (mnt_userns, dir,S_IFDIR | mode, &dentry->d_name,0 ,NULL ,EXT4_HT_DIR , credits); handle =ext4_journal_current_handle ();
@@ -3329,7 +3329,7 @@ static int ext4_symlink(struct user_namespace *mnt_userns, struct inode *dir,EXT4_INDEX_EXTRA_TRANS_BLOCKS +3 ; } - inode =ext4_new_inode_start_handle (dir,S_IFLNK |S_IRWXUGO , + inode =ext4_new_inode_start_handle (mnt_userns, dir,S_IFLNK |S_IRWXUGO , &dentry->d_name,0 ,NULL ,EXT4_HT_DIR , credits); handle =ext4_journal_current_handle ();
@@ -3661,7 +3661,8 @@ static void ext4_update_dir_count(handle_t *handle, struct ext4_renament *ent) } } -static struct inode *ext4_whiteout_for_rename (struct ext4_renament *ent, +static struct inode *ext4_whiteout_for_rename (struct user_namespace *mnt_userns, +struct ext4_renament *ent,int credits,handle_t **h) {struct inode *wh;
@@ -3675,7 +3676,8 @@ static struct inode *ext4_whiteout_for_rename(struct ext4_renament *ent, credits += (EXT4_MAXQUOTAS_TRANS_BLOCKS (ent->dir->i_sb) +EXT4_XATTR_TRANS_BLOCKS +4 ); retry: - wh =ext4_new_inode_start_handle (ent->dir,S_IFCHR |WHITEOUT_MODE , + wh =ext4_new_inode_start_handle (mnt_userns, ent->dir, +S_IFCHR |WHITEOUT_MODE , &ent->dentry->d_name,0 ,NULL ,EXT4_HT_DIR , credits);
@@ -3702,9 +3704,9 @@ static struct inode *ext4_whiteout_for_rename(struct ext4_renament *ent,* while new_{dentry,inode) refers to the destination dentry/inode * This comes from rename(const char *oldpath, const char *newpath) */ -static int ext4_rename (struct inode *old_dir,struct dentry *old_dentry, -struct inode *new_dir,struct dentry *new_dentry, -unsigned int flags) +static int ext4_rename (struct user_namespace *mnt_userns,struct inode *old_dir, +struct dentry *old_dentry,struct inode *new_dir, +struct dentry *new_dentry,unsigned int flags) {handle_t *handle =NULL ;struct ext4_renament old = {
@@ -3788,7 +3790,7 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, goto end_rename; } }else { - whiteout =ext4_whiteout_for_rename (&old, credits, &handle); + whiteout =ext4_whiteout_for_rename (mnt_userns, &old, credits, &handle);if (IS_ERR (whiteout)) { retval =PTR_ERR (whiteout); whiteout =NULL ;
@@ -4103,7 +4105,7 @@ static int ext4_rename2(struct user_namespace *mnt_userns, new_dir, new_dentry); } -return ext4_rename (old_dir, old_dentry, new_dir, new_dentry, flags); +return ext4_rename (mnt_userns, old_dir, old_dentry, new_dir, new_dentry, flags); }/*
fs/ext4/super.c +1 -1
@@ -6608,7 +6608,7 @@ static struct file_system_type ext4_fs_type = { .name = "ext4", .mount = ext4_mount, .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV, + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, };MODULE_ALIAS_FS ("ext4" );
Signature · 6 lines
2.30.0 _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
PATCH v5 37/42 xfs: support idmapped mounts
In reply to Christian BraunerFrom: Christoph Hellwig <[email protected]>
Enable idmapped mounts for xfs. This basically just means passing down the user_namespace argument from the VFS methods down to where it is passed to helper.
---
/* v2 */
patch not present
/* v3 */
patch not present
/* v4 */
patch not present
/* v5 */
patch introduced
base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837
--- fs/xfs/xfs_acl.c | 2 +- fs/xfs/xfs_file.c | 4 +++- fs/xfs/xfs_inode.c | 26 +++++++++++++++++-------- fs/xfs/xfs_inode.h | 16 +++++++++------ fs/xfs/xfs_ioctl.c | 23 ++++++++++++---------- fs/xfs/xfs_iops.c | 46 +++++++++++++++++++++++++------------------- fs/xfs/xfs_iops.h | 3 ++- fs/xfs/xfs_qm.c | 3 ++- fs/xfs/xfs_super.c | 2 +- fs/xfs/xfs_symlink.c | 5 +++-- fs/xfs/xfs_symlink.h | 5 +++-- 11 files changed, 82 insertions(+), 53 deletions(-)
fs/xfs/xfs_acl.c +1 -1
@@ -253,7 +253,7 @@ xfs_set_acl(struct user_namespace *mnt_userns, struct inode *inode,return error;if (type ==ACL_TYPE_ACCESS ) { - error =posix_acl_update_mode (&init_user_ns, inode, &mode, &acl); + error =posix_acl_update_mode (mnt_userns, inode, &mode, &acl);if (error)return error; set_mode = true;
fs/xfs/xfs_file.c +3 -1
@@ -29,6 +29,7 @@#include <linux/backing-dev.h> #include <linux/mman.h> #include <linux/fadvise.h> +#include <linux/mount.h> static const struct vm_operations_struct xfs_file_vm_ops;
@@ -994,7 +995,8 @@ xfs_file_fallocate( iattr.ia_valid =ATTR_SIZE ; iattr.ia_size = new_size; - error =xfs_vn_setattr_size (file_dentry (file), &iattr); + error =xfs_vn_setattr_size (file_user_ns (file), +file_dentry (file), &iattr);if (error) goto out_unlock; }
fs/xfs/xfs_inode.c +18 -8
@@ -766,6 +766,7 @@ xfs_inode_inherit_flags2(*/ static int xfs_init_new_inode( + struct user_namespace *mnt_userns, struct xfs_trans *tp, struct xfs_inode *pip, xfs_ino_t ino,
@@ -806,7 +807,7 @@ xfs_init_new_inode( inode =VFS_I (ip); inode->i_mode = mode;set_nlink (inode, nlink); - inode->i_uid =current_fsuid (); + inode->i_uid =fsuid_into_mnt (mnt_userns); inode->i_rdev = rdev; ip->i_d.di_projid = prid;
@@ -815,7 +816,7 @@ xfs_init_new_inode(if ((VFS_I (pip)->i_mode &S_ISGID ) &&S_ISDIR (mode)) inode->i_mode |=S_ISGID ; }else { - inode->i_gid =current_fsgid (); + inode->i_gid =fsgid_into_mnt (mnt_userns); }/*
@@ -824,7 +825,8 @@ xfs_init_new_inode(* (and only if the irix_sgid_inherit compatibility variable is set). */ if (irix_sgid_inherit && - (inode->i_mode &S_ISGID ) && !in_group_p (inode->i_gid)) + (inode->i_mode &S_ISGID ) && + !in_group_p (i_gid_into_mnt (mnt_userns, inode))) inode->i_mode &= ~S_ISGID ; ip->i_d.di_size =0 ;
@@ -901,6 +903,7 @@ xfs_init_new_inode(*/ int xfs_dir_ialloc( + struct user_namespace *mnt_userns, struct xfs_trans **tpp, struct xfs_inode *dp, umode_t mode,
@@ -933,7 +936,8 @@ xfs_dir_ialloc(return error;ASSERT (ino !=NULLFSINO ); -return xfs_init_new_inode (*tpp, dp, ino, mode, nlink, rdev, prid, ipp); +return xfs_init_new_inode (mnt_userns, *tpp, dp, ino, mode, nlink, rdev, + prid, ipp); }/*
@@ -973,6 +977,7 @@ xfs_bumplink( int xfs_create( + struct user_namespace *mnt_userns, xfs_inode_t *dp, struct xfs_name *name, umode_t mode,
@@ -1047,7 +1052,8 @@ xfs_create(* entry pointing to them, but a directory also the "." entry * pointing to itself. */ - error =xfs_dir_ialloc (&tp, dp, mode, is_dir ?2 :1 , rdev, prid, &ip); + error =xfs_dir_ialloc (mnt_userns, &tp, dp, mode, is_dir ?2 :1 , rdev, + prid, &ip);if (error) goto out_trans_cancel;
@@ -1128,6 +1134,7 @@ xfs_create(int xfs_create_tmpfile ( +struct user_namespace *mnt_userns,struct xfs_inode *dp,umode_t mode,struct xfs_inode **ipp)
@@ -1169,7 +1176,7 @@ xfs_create_tmpfile(if (error) goto out_trans_cancel; - error =xfs_dir_ialloc (&tp, dp, mode,0 ,0 , prid, &ip); + error =xfs_dir_ialloc (mnt_userns, &tp, dp, mode,0 ,0 , prid, &ip);if (error) goto out_trans_cancel;
@@ -2977,13 +2984,15 @@ xfs_cross_rename(*/ static int xfs_rename_alloc_whiteout ( +struct user_namespace *mnt_userns,struct xfs_inode *dp,struct xfs_inode **wip) {struct xfs_inode *tmpfile;int error; - error =xfs_create_tmpfile (dp,S_IFCHR |WHITEOUT_MODE , &tmpfile); + error =xfs_create_tmpfile (mnt_userns, dp,S_IFCHR |WHITEOUT_MODE , + &tmpfile);if (error)return error;
@@ -3005,6 +3014,7 @@ xfs_rename_alloc_whiteout(*/ int xfs_rename( + struct user_namespace *mnt_userns, struct xfs_inode *src_dp, struct xfs_name *src_name, struct xfs_inode *src_ip,
@@ -3036,7 +3046,7 @@ xfs_rename(*/ if (flags &RENAME_WHITEOUT ) {ASSERT (!(flags & (RENAME_NOREPLACE |RENAME_EXCHANGE ))); - error =xfs_rename_alloc_whiteout (target_dp, &wip); + error =xfs_rename_alloc_whiteout (mnt_userns, target_dp, &wip);if (error)return error;
fs/xfs/xfs_inode.h +10 -6
@@ -369,15 +369,18 @@ int xfs_release(struct xfs_inode *ip);void xfs_inactive (struct xfs_inode *ip);int xfs_lookup (struct xfs_inode *dp,struct xfs_name *name,struct xfs_inode **ipp,struct xfs_name *ci_name); -int xfs_create (struct xfs_inode *dp,struct xfs_name *name, +int xfs_create (struct user_namespace *mnt_userns, +struct xfs_inode *dp,struct xfs_name *name,umode_t mode,dev_t rdev,struct xfs_inode **ipp); -int xfs_create_tmpfile (struct xfs_inode *dp,umode_t mode, +int xfs_create_tmpfile (struct user_namespace *mnt_userns, +struct xfs_inode *dp,umode_t mode,struct xfs_inode **ipp);int xfs_remove (struct xfs_inode *dp,struct xfs_name *name,struct xfs_inode *ip);int xfs_link (struct xfs_inode *tdp,struct xfs_inode *sip,struct xfs_name *target_name); -int xfs_rename (struct xfs_inode *src_dp,struct xfs_name *src_name, +int xfs_rename (struct user_namespace *mnt_userns, +struct xfs_inode *src_dp,struct xfs_name *src_name,struct xfs_inode *src_ip,struct xfs_inode *target_dp,struct xfs_name *target_name,struct xfs_inode *target_ip,unsigned int flags);
@@ -407,9 +410,10 @@ void xfs_lock_two_inodes(struct xfs_inode *ip0, uint ip0_mode,xfs_extlen_t xfs_get_extsz_hint (struct xfs_inode *ip);xfs_extlen_t xfs_get_cowextsz_hint (struct xfs_inode *ip); -int xfs_dir_ialloc (struct xfs_trans **tpp,struct xfs_inode *dp,umode_t mode, -xfs_nlink_t nlink,dev_t dev,prid_t prid, -struct xfs_inode **ipp); +int xfs_dir_ialloc (struct user_namespace *mnt_userns, +struct xfs_trans **tpp,struct xfs_inode *dp, +umode_t mode,xfs_nlink_t nlink,dev_t dev, +prid_t prid,struct xfs_inode **ipp);static inline int xfs_itruncate_extents(
fs/xfs/xfs_ioctl.c +13 -10
@@ -693,7 +693,8 @@ xfs_ioc_space( iattr.ia_valid =ATTR_SIZE ; iattr.ia_size = bf->l_start; - error =xfs_vn_setattr_size (file_dentry (filp), &iattr); + error =xfs_vn_setattr_size (file_user_ns (filp),file_dentry (filp), + &iattr);if (error) goto out_unlock;
@@ -1275,8 +1276,9 @@ xfs_ioctl_setattr_prepare_dax(*/ static struct xfs_trans *xfs_ioctl_setattr_get_trans ( -struct xfs_inode *ip) +struct file *file) { +struct xfs_inode *ip =XFS_I (file_inode (file));struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp;int error = -EROFS ;
@@ -1300,7 +1302,7 @@ xfs_ioctl_setattr_get_trans(* The user ID of the calling process must be equal to the file owner * ID, except in cases where the CAP_FSETID capability is applicable. */ -if (!inode_owner_or_capable (&init_user_ns,VFS_I (ip))) { +if (!inode_owner_or_capable (file_user_ns (file),VFS_I (ip))) { error = -EPERM ; goto out_cancel; }
@@ -1428,9 +1430,11 @@ xfs_ioctl_setattr_check_projid( STATIC intxfs_ioctl_setattr ( -xfs_inode_t *ip, +struct file *file,struct fsxattr *fa) { +struct user_namespace *mnt_userns =file_user_ns (file); +struct xfs_inode *ip =XFS_I (file_inode (file));struct fsxattr old_fa;struct xfs_mount *mp = ip->i_mount;struct xfs_trans *tp;
@@ -1462,7 +1466,7 @@ xfs_ioctl_setattr(xfs_ioctl_setattr_prepare_dax (ip, fa); - tp =xfs_ioctl_setattr_get_trans (ip); + tp =xfs_ioctl_setattr_get_trans (file);if (IS_ERR (tp)) { code =PTR_ERR (tp); goto error_free_dquots;
@@ -1502,7 +1506,7 @@ xfs_ioctl_setattr(*/ if ((VFS_I (ip)->i_mode & (S_ISUID |S_ISGID )) && - !capable_wrt_inode_uidgid (&init_user_ns,VFS_I (ip),CAP_FSETID )) + !capable_wrt_inode_uidgid (mnt_userns,VFS_I (ip),CAP_FSETID ))VFS_I (ip)->i_mode &= ~(S_ISUID |S_ISGID );/* Change the ownerships and register project quota modifications */
@@ -1549,7 +1553,6 @@ xfs_ioctl_setattr( STATIC intxfs_ioc_fssetxattr ( -xfs_inode_t *ip,struct file *filp,void __user *arg) {
@@ -1562,7 +1565,7 @@ xfs_ioc_fssetxattr( error =mnt_want_write_file (filp);if (error)return error; - error =xfs_ioctl_setattr (ip, &fa); + error =xfs_ioctl_setattr (filp, &fa);mnt_drop_write_file (filp);return error; }
@@ -1608,7 +1611,7 @@ xfs_ioc_setxflags(xfs_ioctl_setattr_prepare_dax (ip, &fa); - tp =xfs_ioctl_setattr_get_trans (ip); + tp =xfs_ioctl_setattr_get_trans (filp);if (IS_ERR (tp)) { error =PTR_ERR (tp); goto out_drop_write;
@@ -2144,7 +2147,7 @@ xfs_file_ioctl(case XFS_IOC_FSGETXATTRA :return xfs_ioc_fsgetxattr (ip,1 , arg);case XFS_IOC_FSSETXATTR : -return xfs_ioc_fssetxattr (ip, filp, arg); +return xfs_ioc_fssetxattr (filp, arg);case XFS_IOC_GETXFLAGS :return xfs_ioc_getxflags (ip, arg);case XFS_IOC_SETXFLAGS :
fs/xfs/xfs_iops.c +26 -20
154 lines not on this page · raw message
fs/xfs/xfs_iops.h +2 -1
@@ -14,6 +14,7 @@ extern const struct file_operations xfs_dir_file_operations;extern ssize_t xfs_vn_listxattr (struct dentry *,char *data,size_t size);extern void xfs_setattr_time (struct xfs_inode *ip,struct iattr *iattr); -extern int xfs_vn_setattr_size (struct dentry *dentry,struct iattr *vap); +int xfs_vn_setattr_size (struct user_namespace *mnt_userns, +struct dentry *dentry,struct iattr *vap);#endif /* __XFS_IOPS_H__ */
fs/xfs/xfs_qm.c +2 -1
@@ -787,7 +787,8 @@ xfs_qm_qino_alloc(return error;if (need_alloc) { - error =xfs_dir_ialloc (&tp,NULL ,S_IFREG ,1 ,0 ,0 , ipp); + error =xfs_dir_ialloc (&init_user_ns, &tp,NULL ,S_IFREG ,1 ,0 , +0 , ipp);if (error) {xfs_trans_cancel (tp);return error;
fs/xfs/xfs_super.c +1 -1
@@ -1912,7 +1912,7 @@ static struct file_system_type xfs_fs_type = { .init_fs_context = xfs_init_fs_context, .parameters = xfs_fs_parameters, .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV, + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, };MODULE_ALIAS_FS ("xfs" );
fs/xfs/xfs_symlink.c +3 -2
@@ -134,6 +134,7 @@ xfs_readlink( int xfs_symlink( + struct user_namespace *mnt_userns, struct xfs_inode *dp, struct xfs_name *link_name, const char *target_path,
@@ -223,8 +224,8 @@ xfs_symlink(/* * Allocate an inode for the symlink. */ - error =xfs_dir_ialloc (&tp, dp,S_IFLNK | (mode & ~S_IFMT ),1 ,0 , - prid, &ip); + error =xfs_dir_ialloc (mnt_userns, &tp, dp,S_IFLNK | (mode & ~S_IFMT ), +1 ,0 , prid, &ip);if (error) goto out_trans_cancel;
fs/xfs/xfs_symlink.h +3 -2
@@ -7,8 +7,9 @@/* Kernel only symlink definitions */ -int xfs_symlink (struct xfs_inode *dp,struct xfs_name *link_name, -const char *target_path,umode_t mode,struct xfs_inode **ipp); +int xfs_symlink (struct user_namespace *mnt_userns,struct xfs_inode *dp, +struct xfs_name *link_name,const char *target_path, +umode_t mode,struct xfs_inode **ipp);int xfs_readlink_bmap_ilocked (struct xfs_inode *ip,char *link);int xfs_readlink (struct xfs_inode *ip,char *link);int xfs_inactive_symlink (struct xfs_inode *ip);
Signature · 6 lines
2.30.0 _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
Re: [PATCH v5 37/42] xfs: support idmapped mounts
Quoted 7 lines · Christian Brauner
From: Christoph Hellwig <[email protected]>
Enable idmapped mounts for xfs. This basically just means passing down the
user_namespaceargument from the VFS methods down to where it is passed to helper.Signed-off-by Christoph Hellwig <[email protected]>
....
Quoted 18 lines
fs/xfs/xfs_iops.c +2
-1@@ -654,6 +658,7 @@ xfs_vn_change_ok(*/ static int xfs_setattr_nonsize ( +struct user_namespace *mnt_userns,struct xfs_inode *ip,struct iattr *iattr) {@@ -813,7 +818,7 @@ xfs_setattr_nonsize(* Posix ACL code seems to care about this issue either. */ if (mask &ATTR_MODE ) { - error =posix_acl_chmod (&init_user_ns, inode, inode->i_mode); + error =posix_acl_chmod (mnt_userns, inode, inode->i_mode);if (error)return error; }
fs/xfs/xfs_iops.c xfs_setattr_size( · line 876
Quoted 5 lines
fs/xfs/xfs_iops.c +1
-1@@ -868,7 +873,7 @@ xfs_setattr_size(* Use the regular setattr path to update the timestamps. */ iattr->ia_valid &= ~ATTR_SIZE ; -return xfs_setattr_nonsize (ip, iattr); +return xfs_setattr_nonsize (&init_user_ns, ip, iattr);
Shouldn't that be passing mnt_userns?
Quoted 12 lines
fs/xfs/xfs_iops.c +1
-0}/* @@ -1037,6 +1042,7 @@ xfs_setattr_size(int xfs_vn_setattr_size ( +struct user_namespace *mnt_userns,struct dentry *dentry,struct iattr *iattr) {
fs/xfs/xfs_iops.c xfs_vn_setattr_size( · line 1057
Quoted 8 lines
fs/xfs/xfs_iops.c +1
-1@@ -1045,7 +1051,7 @@ xfs_vn_setattr_size(trace_xfs_setattr (ip); - error =xfs_vn_change_ok (dentry, iattr); + error =xfs_vn_change_ok (mnt_userns, dentry, iattr);if (error)return error;return xfs_setattr_size (ip, iattr);
And this passing mnt_userns down into xfs_setattr_size()? Seems like a bit of a landmine...
Cheers,
Dave.
Signature · 6 lines
Dave Chinner [email protected] _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
Re: [PATCH v5 37/42] xfs: support idmapped mounts
Quoted 26 lines · Dave Chinner
Quoted 7 lines · Christian Brauner
From: Christoph Hellwig <[email protected]>
Enable idmapped mounts for xfs. This basically just means passing down the
user_namespaceargument from the VFS methods down to where it is passed to helper.Signed-off-by Christoph Hellwig <[email protected]>....
Quoted 17 lines
fs/xfs/xfs_iops.c +2
-1@@ -654,6 +658,7 @@ xfs_vn_change_ok(*/ static int xfs_setattr_nonsize ( +struct user_namespace *mnt_userns,struct xfs_inode *ip,struct iattr *iattr) {@@ -813,7 +818,7 @@ xfs_setattr_nonsize(* Posix ACL code seems to care about this issue either. */ if (mask &ATTR_MODE ) { - error =posix_acl_chmod (&init_user_ns, inode, inode->i_mode); + error =posix_acl_chmod (mnt_userns, inode, inode->i_mode);if (error)return error; }
Quoted 8 lines
fs/xfs/xfs_iops.c xfs_setattr_size( · line 876
Quoted 6 lines
fs/xfs/xfs_iops.c +1
-1@@ -868,7 +873,7 @@ xfs_setattr_size(* Use the regular setattr path to update the timestamps. */ iattr->ia_valid &= ~ATTR_SIZE ; -return xfs_setattr_nonsize (ip, iattr); +return xfs_setattr_nonsize (&init_user_ns, ip, iattr);Shouldn't that be passing
mnt_userns?
Hey Dave,
Thanks for taking a look.
This is the time updating codepath.
xfs_setattr_size();
-> xfs_setattr_nonsize(&init_user_ns);
The xfs_setattr_size() helper will assert:
ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|
ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0);
While the
xfs_setattr_nonsize() helper will further assert:
ASSERT((mask & ATTR_SIZE) == 0);
so xfs_setattr_nonsize() in this callpath is only used to update the
if (!(iattr->ia_valid & (ATTR_CTIME|ATTR_MTIME)))
return 0;
so there's no interactions with idmappings in any way. Simply passing mnt_userns might be clearer though.
But if this would be using the wrong idmapping the xfstest suite I added would've immediately caught that and failed.
But this specific codepath can also be reliably hit from userspace by doing ftruncate(fd, 0) so just to be extra sure I added truncate tests to the xfstests now for both the idmapped and non-idmapped case.
Christian
Re: [PATCH v5 37/42] xfs: support idmapped mounts
Quoted 36 lines · Christian Brauner
Quoted 26 lines · Dave Chinner
Quoted 7 lines · Christian Brauner
From: Christoph Hellwig <[email protected]>
Enable idmapped mounts for xfs. This basically just means passing down the
user_namespaceargument from the VFS methods down to where it is passed to helper.Signed-off-by Christoph Hellwig <[email protected]>....
Quoted 17 lines
fs/xfs/xfs_iops.c +2
-1@@ -654,6 +658,7 @@ xfs_vn_change_ok(*/ static int xfs_setattr_nonsize ( +struct user_namespace *mnt_userns,struct xfs_inode *ip,struct iattr *iattr) {@@ -813,7 +818,7 @@ xfs_setattr_nonsize(* Posix ACL code seems to care about this issue either. */ if (mask &ATTR_MODE ) { - error =posix_acl_chmod (&init_user_ns, inode, inode->i_mode); + error =posix_acl_chmod (mnt_userns, inode, inode->i_mode);if (error)return error; }Quoted 8 lines
fs/xfs/xfs_iops.c xfs_setattr_size( · line 876
Quoted 6 lines
fs/xfs/xfs_iops.c +1
-1@@ -868,7 +873,7 @@ xfs_setattr_size(* Use the regular setattr path to update the timestamps. */ iattr->ia_valid &= ~ATTR_SIZE ; -return xfs_setattr_nonsize (ip, iattr); +return xfs_setattr_nonsize (&init_user_ns, ip, iattr);Shouldn't that be passing
mnt_userns?
Quoted 5 lines
Hey Dave,
Thanks for taking a look.
This is the time updating codepath.
Yes, I understand the code path, that's why I asked the question and commented that it's a landmine. That is, if in future we ever need to do anything that is is in any way namespace related in the truncate path, the wrong thing will happen because we are passing the wrong namespace into that function.
Please just pass down the correct namespace for the operation even though we don't currently require it for the operations being performed in that path.
Cheers,
Dave.
Signature · 6 lines
Dave Chinner [email protected] _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
Re: [PATCH v5 37/42] xfs: support idmapped mounts
In reply to Dave ChinnerQuoted 9 lines · Dave Chinner
Quoted 9 lines
fs/xfs/xfs_iops.c +1
-1@@ -813,7 +818,7 @@ xfs_setattr_nonsize(* Posix ACL code seems to care about this issue either. */ if (mask &ATTR_MODE ) { - error =posix_acl_chmod (&init_user_ns, inode, inode->i_mode); + error =posix_acl_chmod (mnt_userns, inode, inode->i_mode);if (error)return error; }
Quoted 8 lines
fs/xfs/xfs_iops.c xfs_setattr_size( · line 876
Quoted 6 lines
fs/xfs/xfs_iops.c +1
-1@@ -868,7 +873,7 @@ xfs_setattr_size(* Use the regular setattr path to update the timestamps. */ iattr->ia_valid &= ~ATTR_SIZE ; -return xfs_setattr_nonsize (ip, iattr); +return xfs_setattr_nonsize (&init_user_ns, ip, iattr);Shouldn't that be passing
mnt_userns?
As Christian already explained we an't hit this with anything related to uids/gids, the only thing that will be updated are the timestamps, as also mentioned in the comment that only makes it partially into the diff context.
Quoted 10 lines
fs/xfs/xfs_iops.c xfs_vn_setattr_size( · line 1057
Quoted 7 lines
fs/xfs/xfs_iops.c +1
-1trace_xfs_setattr (ip); - error =xfs_vn_change_ok (dentry, iattr); + error =xfs_vn_change_ok (mnt_userns, dentry, iattr);fs/xfs/xfs_iops.c +0
-0if (error)return error;return xfs_setattr_size (ip, iattr);And this passing
mnt_usernsdown intoxfs_setattr_size()? Seems like a bit of a landmine...
That being said we could just pass down the argument, even if it doesn't make much sense for the size update.
PATCH v5 38/42 ecryptfs: do not mount on top of idmapped mounts
In reply to Christian BraunerPrevent ecryptfs from being mounted on top of idmapped mounts until we have ported it to handle this case and added proper testing for it.
---
/* v2 */
patch introduced
/* v3 */
- David Howells <[email protected]>:
- Adapt check after removing mnt_idmapped() helper.
/* v4 */
unchanged
/* v5 */
base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837
- Christoph Hellwig <[email protected]>:
- Use new file_userns_helper().
--- fs/ecryptfs/main.c | 6 ++++++ 1 file changed, 6 insertions(+)
fs/ecryptfs/main.c +6 -0
@@ -531,6 +531,12 @@ static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags goto out_free; } +if (mnt_user_ns (path.mnt) != &init_user_ns) { + rc = -EINVAL ; +printk (KERN_ERR "Mounting on idmapped mounts currently disallowed\n" ); + goto out_free; + } +if (check_ruid && !uid_eq (d_inode (path.dentry)->i_uid,current_uid ())) { rc = -EPERM ; printk(KERN_ERR "Mount of device (uid: %d) not owned by "
Signature · 6 lines
2.30.0 _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
PATCH v5 39/42 overlayfs: do not mount on top of idmapped mounts
In reply to Christian BraunerPrevent overlayfs from being mounted on top of idmapped mounts until we have ported it to handle this case and added proper testing for it.
---
/* v2 */
patch introduced
/* v3 */
- Amir Goldstein <[email protected]>:
- Move check for idmapped lower layers into ovl_mount_dir_noesc().
- David Howells <[email protected]>:
- Adapt check after removing mnt_idmapped() helper.
/* v4 */
unchanged
/* v5 */
base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837
--- fs/overlayfs/super.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/overlayfs/super.c +4 -0
@@ -856,6 +856,10 @@ static int ovl_mount_dir_noesc(const char *name, struct path *path)pr_err ("filesystem on '%s' not supported\n" , name); goto out_put; } +if (mnt_user_ns (path->mnt) != &init_user_ns) { +pr_err ("idmapped layers are currently not supported\n" ); + goto out_put; + }if (!d_is_dir (path->dentry)) {pr_err ("'%s' not a directory\n" , name); goto out_put;
Signature · 1 line
2.30.0
PATCH v5 40/42 fs: introduce MOUNT_ATTR_IDMAP
In reply to Christian BraunerIntroduce a new mount bind mount property to allow idmapping mounts. The MOUNT_ATTR_IDMAP flag can be set via the new mount_setattr() syscall together with a file descriptor referring to a user namespace.
The user namespace referenced by the namespace file descriptor will be attached to the bind mount. All interactions with the filesystem going through that mount will be idmapped according to the mapping specified in the user namespace attached to it.
Using user namespaces to mark mounts means we can reuse all the existing infrastructure in the kernel that already exists to handle idmappings and can also use this for permission checking to allow unprivileged user to create idmapped mounts in the future.
Idmapping a mount is decoupled from the caller's user and mount namespace. This means idmapped mounts can be created in the initial user namespace which is an important use-case for systemd-homed, portable usb-sticks between systems, sharing data between the initial user namespace and unprivileged containers, and other use-cases that have been brought up. For example, assume a home directory where all files are owned by uid and gid 1000 and the home directory is brought to a new laptop where the user has id 12345. The system administrator can simply create a mount of this home directory with a mapping of 1000:12345:1 and other mappings to indicate the ids should be kept. (With this it is e.g. also possible to create idmapped mounts on the host with an identity mapping 1:1:100000 where the root user is not mapped. A user with root access that e.g. has been pivot rooted into such a mount on the host will be not be able to execute, read, write, or create files as root.)
Given that idmapping a mount is decoupled from the caller's user namespace a sufficiently privileged process such as a container manager can set up a shifted mount for the container and the container can simply pivot root to it. There's no need for the container to do anything. The mount will appear correctly mapped independent of the user namespace the container uses. This means we don't need to mark a mount as idmappable.
In order to create an idmapped mount the caller must currently be privileged in the user namespace of the superblock the mount belongs to. Currently, once a mount has been idmapped we don't allow it to change its mapping. This can be changed in the future if the use-cases arise.
---
/* v2 */
- Christoph Hellwig <[email protected]>:
- Drop kconfig option to make vfs idmappings unconditional.
- Move introduction of MOUNT_ATTR_IDMAP to the end of the series after all internal changes have been done.
- Move MOUNT_ATTR_IDMAP handling from build_mount_kattr() to separate build_mount_idmapped() helper.
- Move MNT_IDMAPPED handling from do_mount_setattr() into separate do_mount_idmap() helper.
- Use more helpers instead of one big function for mount attribute changes.
- Mauricio Vásquez Bernal <[email protected]>:
- Recalculate flags before checking can_change_locked_flags().
/* v3 */
- David Howells <[email protected]>:
- Use smp_load_acquire() and smp_store_release() in mnt_user_ns() and do_idmap_mount().
- Remove all references to MNT_IDMAPPED now that the flag has been removed.
/* v4 */
- Serge Hallyn <[email protected]>:
- Use "mnt_userns" to refer to a vfsmount's userns everywhere to make terminology consistent.
/* v5 */
base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837
--- fs/namespace.c | 121 +++++++++++++++++++++++++++++++++++-- fs/proc_namespace.c | 3 + include/linux/fs.h | 2 +- include/linux/mount.h | 3 +- include/uapi/linux/mount.h | 3 + 5 files changed, 125 insertions(+), 7 deletions(-)
fs/namespace.c +116 -5
@@ -25,6 +25,7 @@#include <linux/proc_ns.h> #include <linux/magic.h> #include <linux/memblock.h> +#include <linux/proc_fs.h> #include <linux/task_work.h> #include <linux/sched/task.h> #include <uapi/linux/mount.h>
@@ -79,6 +80,7 @@ struct mount_kattr {unsigned int propagation;unsigned int lookup_flags;bool recurse; +struct user_namespace *mnt_userns; };/* /sys/fs */
@@ -3474,7 +3476,7 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name, (MOUNT_ATTR_RDONLY |MOUNT_ATTR_NOSUID |MOUNT_ATTR_NODEV | \ MOUNT_ATTR_NOEXEC | MOUNT_ATTR__ATIME | MOUNT_ATTR_NODIRATIME) -#define MOUNT_SETATTR_VALID_FLAGS FSMOUNT_VALID_FLAGS +#define MOUNT_SETATTR_VALID_FLAGS (FSMOUNT_VALID_FLAGS | MOUNT_ATTR_IDMAP)#define MOUNT_SETATTR_PROPAGATION_FLAGS \ (MS_UNBINDABLE | MS_PRIVATE | MS_SLAVE | MS_SHARED)
@@ -3842,6 +3844,32 @@ static unsigned int recalc_flags(struct mount_kattr *kattr, struct mount *mnt)return flags; } +static int can_idmap_mount (const struct mount_kattr *kattr,struct mount *mnt) +{ +struct vfsmount *m = &mnt->mnt; + +if (!kattr->mnt_userns) +return 0 ; + +/* +* Once a mount has been idmapped we don't allow it to change its +* mapping. It makes things simpler and callers can just create +* another bind-mount they can idmap if they want to. +*/ +if (mnt_user_ns (m) != &init_user_ns) +return -EPERM ; + +/* The underlying filesystem doesn't support idmapped mounts yet. */ +if (!(m->mnt_sb->s_type->fs_flags &FS_ALLOW_IDMAP )) +return -EINVAL ; + +/* We're not controlling the superblock. */ +if (!ns_capable (m->mnt_sb->s_user_ns,CAP_SYS_ADMIN )) +return -EPERM ; + +return 0 ; +} +static struct mount *mount_setattr_prepare (struct mount_kattr *kattr,struct mount *mnt,int *err) {
@@ -3866,6 +3894,10 @@ static struct mount *mount_setattr_prepare(struct mount_kattr *kattr, goto out; } + *err =can_idmap_mount (kattr, m); +if (*err) + goto out; + last = m; if ((kattr->attr_set & MNT_READONLY) &&
@@ -3880,6 +3912,18 @@ static struct mount *mount_setattr_prepare(struct mount_kattr *kattr,return last; } +static void do_idmap_mount (const struct mount_kattr *kattr,struct mount *mnt) +{ +struct user_namespace *mnt_userns; + +if (!kattr->mnt_userns) +return ; + + mnt_userns =get_user_ns (kattr->mnt_userns); +/* Pairs with smp_load_acquire() in mnt_user_ns(). */ +smp_store_release (&mnt->mnt.mnt_userns, mnt_userns); +} +static void mount_setattr_commit (struct mount_kattr *kattr,struct mount *mnt,struct mount *last,int err)
@@ -3890,6 +3934,7 @@ static void mount_setattr_commit(struct mount_kattr *kattr,if (!err) {unsigned int flags; +do_idmap_mount (kattr, m); flags =recalc_flags (kattr, m);WRITE_ONCE (m->mnt.mnt_flags, flags); }
@@ -3962,7 +4007,65 @@ static int do_mount_setattr(struct path *path, struct mount_kattr *kattr)return err; } -static int build_mount_kattr (const struct mount_attr *attr, +static int build_mount_idmapped (const struct mount_attr *attr,size_t usize, +struct mount_kattr *kattr,unsigned int flags) +{ +int err =0 ; +struct ns_common *ns; +struct user_namespace *mnt_userns; +struct file *file; + +if (!((attr->attr_set | attr->attr_clr) &MOUNT_ATTR_IDMAP )) +return 0 ; + +/* +* We currently do not support clearing an idmapped mount. If this ever +* is a use-case we can revisit this but for now let's keep it simple +* and not allow it. +*/ +if (attr->attr_clr &MOUNT_ATTR_IDMAP ) +return -EINVAL ; + +if (usize <MOUNT_ATTR_SIZE_VER1 ) +return -EINVAL ; + +if (attr->userns_fd >INT_MAX ) +return -EINVAL ; + + file =fget (attr->userns_fd); +if (!file) +return -EBADF ; + +if (!proc_ns_file (file)) { + err = -EINVAL ; + goto out_fput; + } + + ns =get_proc_ns (file_inode (file)); +if (ns->ops->type !=CLONE_NEWUSER ) { + err = -EINVAL ; + goto out_fput; + } + +/* +* The init_user_ns is used to indicate that a vfsmount is not idmapped. +* This is simpler than just having to treat NULL as unmapped. Users +* wanting to idmap a mount to init_user_ns can just use a namespace +* with an identity mapping. +*/ + mnt_userns = container_of(ns, struct user_namespace, ns); +if (mnt_userns == &init_user_ns) { + err = -EPERM ; + goto out_fput; + } + kattr->mnt_userns =get_user_ns (mnt_userns); + +out_fput: +fput (file); +return err; +} + +static int build_mount_kattr (const struct mount_attr *attr,size_t usize,struct mount_kattr *kattr,unsigned int flags) {unsigned int lookup_flags =LOOKUP_AUTOMOUNT |LOOKUP_FOLLOW ;
@@ -4026,7 +4129,13 @@ static int build_mount_kattr(const struct mount_attr *attr,return -EINVAL ; } -return 0 ; +return build_mount_idmapped (attr, usize, kattr, flags); +} + +static void finish_mount_kattr (struct mount_kattr *kattr) +{ +put_user_ns (kattr->mnt_userns); + kattr->mnt_userns =NULL ; } SYSCALL_DEFINE5(mount_setattr, int, dfd, const char __user *, path,
@@ -4038,7 +4147,8 @@ SYSCALL_DEFINE5(mount_setattr, int, dfd, const char __user *, path,struct mount_attr attr;struct mount_kattr kattr; -BUILD_BUG_ON (sizeof (struct mount_attr ) !=MOUNT_ATTR_SIZE_VER0 ); +BUILD_BUG_ON (sizeof (struct mount_attr ) <MOUNT_ATTR_SIZE_VER0 ); +BUILD_BUG_ON (sizeof (struct mount_attr ) !=MOUNT_ATTR_SIZE_VER1 ); if (flags & ~(AT_EMPTY_PATH | AT_RECURSIVE |
@@ -4064,7 +4174,7 @@ SYSCALL_DEFINE5(mount_setattr, int, dfd, const char __user *, path, attr.propagation == 0)return 0 ; - err =build_mount_kattr (&attr, &kattr, flags); + err =build_mount_kattr (&attr, usize, &kattr, flags);if (err)return err;
@@ -4073,6 +4183,7 @@ SYSCALL_DEFINE5(mount_setattr, int, dfd, const char __user *, path,return err; err =do_mount_setattr (&target, &kattr); +finish_mount_kattr (&kattr);path_put (&target);return err; }
fs/proc_namespace.c +3 -0
@@ -79,6 +79,9 @@ static void show_mnt_opts(struct seq_file *m, struct vfsmount *mnt)if (mnt->mnt_flags & fs_infop->flag)seq_puts (m, fs_infop->str); } + +if (mnt_user_ns (mnt) != &init_user_ns) +seq_puts (m,",idmapped" ); }static inline void mangle (struct seq_file *m,const char *s)
include/linux/fs.h +1 -1
@@ -2296,7 +2296,7 @@ struct file_system_type {#define FS_HAS_SUBTYPE 4#define FS_USERNS_MOUNT 8/* Can be mounted by userns root */ #define FS_DISALLOW_NOTIFY_PERM 16/* Disable fanotify permission events */ -#define FS_ALLOW_IDMAP 32/* FS has been updated to handle vfs idmappings. */ +#define FS_ALLOW_IDMAP 32/* FS has been updated to handle vfs idmappings. */ #define FS_THP_SUPPORT 8192/* Remove once all fs converted */ #define FS_RENAME_DOES_D_MOVE 32768/* FS will handle d_move() during rename() internally. */ int (*init_fs_context)(struct fs_context *);
include/linux/mount.h +2 -1
@@ -77,7 +77,8 @@ struct vfsmount {static inline struct user_namespace *mnt_user_ns (const struct vfsmount *mnt) { -return mnt->mnt_userns; +/* Pairs with smp_store_release() in do_idmap_mount(). */ +return smp_load_acquire (&mnt->mnt_userns); }struct file ;/* forward dec */
include/uapi/linux/mount.h +3 -0
@@ -119,6 +119,7 @@ enum fsconfig_command {#define MOUNT_ATTR_NOATIME 0x00000010/* - Do not update access times. */ #define MOUNT_ATTR_STRICTATIME 0x00000020/* - Always perform atime updates */ #define MOUNT_ATTR_NODIRATIME 0x00000080/* Do not update directory access times */ +#define MOUNT_ATTR_IDMAP 0x00100000/* Idmap this mount to @userns in mount_attr. */ /* * mount_setattr()
@@ -127,9 +128,11 @@ struct mount_attr {__u64 attr_set;__u64 attr_clr;__u64 propagation; + __u64 userns_fd; };/* List of all mount_attr versions. */ #define MOUNT_ATTR_SIZE_VER0 24/* sizeof first published struct */ +#define MOUNT_ATTR_SIZE_VER1 32/* sizeof second published struct */ #endif /* _UAPI_LINUX_MOUNT_H */
Signature · 6 lines
2.30.0 _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
Re: [PATCH v5 40/42] fs: introduce MOUNT_ATTR_IDMAP
Generally looks good, but wouldn't it make sense to introduce the userns_fd in version 0 of the mount_attr structure instead of having two versions from the start?
_______________________________________________
Containers mailing list [email protected]
https://lists.linuxfoundation.org/mailman/listinfo/containers
Re: [PATCH v5 40/42] fs: introduce MOUNT_ATTR_IDMAP
Quoted 3 lines · Christoph Hellwig
Generally looks good, but wouldn't it make sense to introduce the
userns_fdin version 0 of themount_attrstructure instead of having two versions from the start?
I agree.
_______________________________________________
Containers mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/containers
PATCH v5 41/42 tests: extend mount_setattr tests
In reply to Christian BraunerExtend the mount_setattr test-suite to include tests for idmapped mounts. Note, the main test-suite ist part of xfstests and is pretty huge. These tests here just make sure that the syscalls bits work correctly.
---
/* v2 */
patch introduced
/* v3 */
- Christoph Hellwig <[email protected]>, Darrick J. Wong <[email protected]>:
- Port main test-suite to xfstests.
/* v4 */
unchanged
/* v5 */
base-commit: 7c53f6b671f4aba70ff15e1b05148b10d58c2837
--- .../mount_setattr/mount_setattr_test.c | 483 ++++++++++++++++++ 1 file changed, 483 insertions(+)
tools/testing/selftests/mount_setattr/mount_setattr_test.c +483 -0
@@ -108,15 +108,57 @@ struct mount_attr {__u64 attr_set;__u64 attr_clr;__u64 propagation; +__u64 userns_fd; };#endif +#ifndef __NR_open_tree +#if defined __alpha__ +#define __NR_open_tree 538 +#elif defined _MIPS_SIM +#if _MIPS_SIM == _MIPS_SIM_ABI32/* o32 */ +#define __NR_open_tree 4428 +#endif +#if _MIPS_SIM == _MIPS_SIM_NABI32/* n32 */ +#define __NR_open_tree 6428 +#endif +#if _MIPS_SIM == _MIPS_SIM_ABI64/* n64 */ +#define __NR_open_tree 5428 +#endif +#elif defined __ia64__ +#define __NR_open_tree (428 + 1024) +#else +#define __NR_open_tree 428 +#endif +#endif + +#ifndef MOUNT_ATTR_IDMAP +#define MOUNT_ATTR_IDMAP 0x00100000 +#endif +static inline int sys_mount_setattr (int dfd,const char *path,unsigned int flags,struct mount_attr *attr,size_t size) {return syscall (__NR_mount_setattr, dfd, path, flags, attr, size); } +#ifndef OPEN_TREE_CLONE +#define OPEN_TREE_CLONE 1 +#endif + +#ifndef OPEN_TREE_CLOEXEC +#define OPEN_TREE_CLOEXEC O_CLOEXEC +#endif + +#ifndef AT_RECURSIVE +#define AT_RECURSIVE 0x8000/* Apply to the entire subtree */ +#endif + +static inline int sys_open_tree (int dfd,const char *filename,unsigned int flags) +{ +return syscall (__NR_open_tree, dfd, filename, flags); +} +static ssize_t write_nointr (int fd,const void *buf,size_t count) {ssize_t ret;
@@ -938,4 +980,445 @@ TEST_F(mount_setattr, wrong_mount_namespace)ASSERT_EQ (errno,EINVAL ); } +FIXTURE (mount_setattr_idmapped) { +}; + +FIXTURE_SETUP (mount_setattr_idmapped) +{ +int img_fd = -EBADF ; + +ASSERT_EQ (unshare (CLONE_NEWNS ),0 ); + +ASSERT_EQ (mount (NULL ,"/" ,NULL ,MS_REC |MS_PRIVATE ,0 ),0 ); + + (void )umount2 ("/mnt" ,MNT_DETACH ); + (void )umount2 ("/tmp" ,MNT_DETACH ); + +ASSERT_EQ (mount ("testing" ,"/tmp" ,"tmpfs" ,MS_NOATIME |MS_NODEV , +"size=100000,mode=700" ),0 ); + +ASSERT_EQ (mkdir ("/tmp/B" ,0777 ),0 ); +ASSERT_EQ (mknodat (-EBADF ,"/tmp/B/b" ,S_IFREG |0644 ,0 ),0 ); +ASSERT_EQ (chown ("/tmp/B/b" ,0 ,0 ),0 ); + +ASSERT_EQ (mount ("testing" ,"/tmp/B" ,"tmpfs" ,MS_NOATIME |MS_NODEV , +"size=100000,mode=700" ),0 ); + +ASSERT_EQ (mkdir ("/tmp/B/BB" ,0777 ),0 ); +ASSERT_EQ (mknodat (-EBADF ,"/tmp/B/BB/b" ,S_IFREG |0644 ,0 ),0 ); +ASSERT_EQ (chown ("/tmp/B/BB/b" ,0 ,0 ),0 ); + +ASSERT_EQ (mount ("testing" ,"/tmp/B/BB" ,"tmpfs" ,MS_NOATIME |MS_NODEV , +"size=100000,mode=700" ),0 ); + +ASSERT_EQ (mount ("testing" ,"/mnt" ,"tmpfs" ,MS_NOATIME |MS_NODEV , +"size=100000,mode=700" ),0 ); + +ASSERT_EQ (mkdir ("/mnt/A" ,0777 ),0 ); + +ASSERT_EQ (mount ("testing" ,"/mnt/A" ,"tmpfs" ,MS_NOATIME |MS_NODEV , +"size=100000,mode=700" ),0 ); + +ASSERT_EQ (mkdir ("/mnt/A/AA" ,0777 ),0 ); + +ASSERT_EQ (mount ("/tmp" ,"/mnt/A/AA" ,NULL ,MS_BIND |MS_REC ,NULL ),0 ); + +ASSERT_EQ (mkdir ("/mnt/B" ,0777 ),0 ); + +ASSERT_EQ (mount ("testing" ,"/mnt/B" ,"ramfs" , +MS_NOATIME |MS_NODEV |MS_NOSUID ,0 ),0 ); + +ASSERT_EQ (mkdir ("/mnt/B/BB" ,0777 ),0 ); + +ASSERT_EQ (mount ("testing" ,"/tmp/B/BB" ,"devpts" , +MS_RELATIME |MS_NOEXEC |MS_RDONLY ,0 ),0 ); + +ASSERT_EQ (mkdir ("/mnt/C" ,0777 ),0 ); +ASSERT_EQ (mkdir ("/mnt/D" ,0777 ),0 ); + img_fd =openat (-EBADF ,"/mnt/C/ext4.img" ,O_CREAT |O_WRONLY ,0600 ); +ASSERT_GE (img_fd,0 ); +ASSERT_EQ (ftruncate (img_fd,1024 *2048 ),0 ); +ASSERT_EQ (system ("mkfs.ext4 -q /mnt/C/ext4.img" ),0 ); +ASSERT_EQ (system ("mount -o loop -t ext4 /mnt/C/ext4.img /mnt/D/" ),0 ); +ASSERT_EQ (close (img_fd),0 ); +} + +FIXTURE_TEARDOWN (mount_setattr_idmapped) +{ + (void )umount2 ("/mnt/A" ,MNT_DETACH ); + (void )umount2 ("/tmp" ,MNT_DETACH ); +} + +/** +* Validate that negative fd values are rejected. +*/ +TEST_F(mount_setattr_idmapped, invalid_fd_negative) +{ +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + .userns_fd = -EBADF , + }; + +if (!mount_setattr_supported ()) +SKIP (return,"mount_setattr syscall not supported" ); + + ASSERT_NE(sys_mount_setattr(-1, "/", 0, &attr, sizeof(attr)), 0) { +TH_LOG ("failure: created idmapped mount with negative fd" ); + } +} + +/** +* Validate that excessively large fd values are rejected. +*/ +TEST_F(mount_setattr_idmapped, invalid_fd_large) +{ +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + .userns_fd =INT64_MAX , + }; + +if (!mount_setattr_supported ()) +SKIP (return,"mount_setattr syscall not supported" ); + + ASSERT_NE(sys_mount_setattr(-1, "/", 0, &attr, sizeof(attr)), 0) { +TH_LOG ("failure: created idmapped mount with too large fd value" ); + } +} + +/** +* Validate that closed fd values are rejected. +*/ +TEST_F(mount_setattr_idmapped, invalid_fd_closed) +{ +int fd; +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + }; + +if (!mount_setattr_supported ()) +SKIP (return,"mount_setattr syscall not supported" ); + + fd =open ("/dev/null" ,O_RDONLY |O_CLOEXEC ); +ASSERT_GE (fd,0 ); +ASSERT_GE (close (fd),0 ); + + attr.userns_fd = fd; + ASSERT_NE(sys_mount_setattr(-1, "/", 0, &attr, sizeof(attr)), 0) { +TH_LOG ("failure: created idmapped mount with closed fd" ); + } +} + +/** +* Validate that the initial user namespace is rejected. +*/ +TEST_F(mount_setattr_idmapped, invalid_fd_initial_userns) +{ +int open_tree_fd = -EBADF ; +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + }; + +if (!mount_setattr_supported ()) +SKIP (return,"mount_setattr syscall not supported" ); + + open_tree_fd =sys_open_tree (-EBADF ,"/mnt/D" , +AT_NO_AUTOMOUNT | +AT_SYMLINK_NOFOLLOW | +OPEN_TREE_CLOEXEC |OPEN_TREE_CLONE ); +ASSERT_GE (open_tree_fd,0 ); + + attr.userns_fd =open ("/proc/1/ns/user" ,O_RDONLY |O_CLOEXEC ); +ASSERT_GE (attr.userns_fd,0 ); +ASSERT_NE (sys_mount_setattr (open_tree_fd,"" ,AT_EMPTY_PATH , &attr,sizeof (attr)),0 ); +ASSERT_EQ (errno,EPERM ); +ASSERT_EQ (close (attr.userns_fd),0 ); +ASSERT_EQ (close (open_tree_fd),0 ); +} + +static int map_ids (pid_t pid,unsigned long nsid,unsigned long hostid, +unsigned long range) +{ +char map[100 ], procfile[256 ]; + +snprintf (procfile,sizeof (procfile),"/proc/%d/uid_map" , pid); +snprintf (map,sizeof (map),"%lu %lu %lu" , nsid, hostid, range); +if (write_file (procfile, map,strlen (map))) +return -1 ; + + +snprintf (procfile,sizeof (procfile),"/proc/%d/gid_map" , pid); +snprintf (map,sizeof (map),"%lu %lu %lu" , nsid, hostid, range); +if (write_file (procfile, map,strlen (map))) +return -1 ; + +return 0 ; +} + +#define __STACK_SIZE (8 * 1024 * 1024) +static pid_t do_clone (int (*fn)(void *),void *arg,int flags) +{ +void *stack; + + stack =malloc (__STACK_SIZE); +if (!stack) +return -ENOMEM ; + +#ifdef __ia64__ +return __clone2 (fn, stack, __STACK_SIZE, flags |SIGCHLD , arg,NULL ); +#else +return clone (fn, stack + __STACK_SIZE, flags |SIGCHLD , arg,NULL ); +#endif +} + +static int get_userns_fd_cb (void *data) +{ +return kill (getpid (),SIGSTOP ); +} + +static int wait_for_pid (pid_t pid) +{ +int status, ret; + +again: + ret =waitpid (pid, &status,0 ); +if (ret ==-1 ) { +if (errno ==EINTR ) + goto again; + +return -1 ; + } + +if (!WIFEXITED (status)) +return -1 ; + +return WEXITSTATUS (status); +} + +static int get_userns_fd (unsigned long nsid,unsigned long hostid,unsigned long range) +{ +int ret; +pid_t pid; +char path[256 ]; + + pid =do_clone (get_userns_fd_cb,NULL ,CLONE_NEWUSER ); +if (pid <0 ) +return -errno; + + ret =map_ids (pid, nsid, hostid, range); +if (ret <0 ) +return ret; + +snprintf (path,sizeof (path),"/proc/%d/ns/user" , pid); + ret =open (path,O_RDONLY |O_CLOEXEC ); +kill (pid,SIGKILL ); +wait_for_pid (pid); +return ret; +} + +/** +* Validate that an attached mount in our mount namespace can be idmapped. +* (The kernel enforces that the mount's mount namespace and the caller's mount +* namespace match.) +*/ +TEST_F(mount_setattr_idmapped, attached_mount_inside_current_mount_namespace) +{ +int open_tree_fd = -EBADF ; +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + }; + +if (!mount_setattr_supported ()) +SKIP (return,"mount_setattr syscall not supported" ); + + open_tree_fd =sys_open_tree (-EBADF ,"/mnt/D" , +AT_EMPTY_PATH | +AT_NO_AUTOMOUNT | +AT_SYMLINK_NOFOLLOW | +OPEN_TREE_CLOEXEC ); +ASSERT_GE (open_tree_fd,0 ); + + attr.userns_fd =get_userns_fd (0 ,10000 ,10000 ); +ASSERT_GE (attr.userns_fd,0 ); +ASSERT_EQ (sys_mount_setattr (open_tree_fd,"" ,AT_EMPTY_PATH , &attr,sizeof (attr)),0 ); +ASSERT_EQ (close (attr.userns_fd),0 ); +ASSERT_EQ (close (open_tree_fd),0 ); +} + +/** +* Validate that idmapping a mount is rejected if the mount's mount namespace +* and our mount namespace don't match. +* (The kernel enforces that the mount's mount namespace and the caller's mount +* namespace match.) +*/ +TEST_F(mount_setattr_idmapped, attached_mount_outside_current_mount_namespace) +{ +int open_tree_fd = -EBADF ; +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + }; + +if (!mount_setattr_supported ()) +SKIP (return,"mount_setattr syscall not supported" ); + + open_tree_fd =sys_open_tree (-EBADF ,"/mnt/D" , +AT_EMPTY_PATH | +AT_NO_AUTOMOUNT | +AT_SYMLINK_NOFOLLOW | +OPEN_TREE_CLOEXEC ); +ASSERT_GE (open_tree_fd,0 ); + +ASSERT_EQ (unshare (CLONE_NEWNS ),0 ); + + attr.userns_fd =get_userns_fd (0 ,10000 ,10000 ); +ASSERT_GE (attr.userns_fd,0 ); +ASSERT_NE (sys_mount_setattr (open_tree_fd,"" ,AT_EMPTY_PATH , &attr, +sizeof (attr)),0 ); +ASSERT_EQ (close (attr.userns_fd),0 ); +ASSERT_EQ (close (open_tree_fd),0 ); +} + +/** +* Validate that an attached mount in our mount namespace can be idmapped. +*/ +TEST_F(mount_setattr_idmapped, detached_mount_inside_current_mount_namespace) +{ +int open_tree_fd = -EBADF ; +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + }; + +if (!mount_setattr_supported ()) +SKIP (return,"mount_setattr syscall not supported" ); + + open_tree_fd =sys_open_tree (-EBADF ,"/mnt/D" , +AT_EMPTY_PATH | +AT_NO_AUTOMOUNT | +AT_SYMLINK_NOFOLLOW | +OPEN_TREE_CLOEXEC | +OPEN_TREE_CLONE ); +ASSERT_GE (open_tree_fd,0 ); + +/* Changing mount properties on a detached mount. */ + attr.userns_fd =get_userns_fd (0 ,10000 ,10000 ); +ASSERT_GE (attr.userns_fd,0 ); +ASSERT_EQ (sys_mount_setattr (open_tree_fd,"" , +AT_EMPTY_PATH , &attr,sizeof (attr)),0 ); +ASSERT_EQ (close (attr.userns_fd),0 ); +ASSERT_EQ (close (open_tree_fd),0 ); +} + +/** +* Validate that a detached mount not in our mount namespace can be idmapped. +*/ +TEST_F(mount_setattr_idmapped, detached_mount_outside_current_mount_namespace) +{ +int open_tree_fd = -EBADF ; +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + }; + +if (!mount_setattr_supported ()) +SKIP (return,"mount_setattr syscall not supported" ); + + open_tree_fd =sys_open_tree (-EBADF ,"/mnt/D" , +AT_EMPTY_PATH | +AT_NO_AUTOMOUNT | +AT_SYMLINK_NOFOLLOW | +OPEN_TREE_CLOEXEC | +OPEN_TREE_CLONE ); +ASSERT_GE (open_tree_fd,0 ); + +ASSERT_EQ (unshare (CLONE_NEWNS ),0 ); + +/* Changing mount properties on a detached mount. */ + attr.userns_fd =get_userns_fd (0 ,10000 ,10000 ); +ASSERT_GE (attr.userns_fd,0 ); +ASSERT_EQ (sys_mount_setattr (open_tree_fd,"" , +AT_EMPTY_PATH , &attr,sizeof (attr)),0 ); +ASSERT_EQ (close (attr.userns_fd),0 ); +ASSERT_EQ (close (open_tree_fd),0 ); +} + +/** +* Validate that currently changing the idmapping of an idmapped mount fails. +*/ +TEST_F(mount_setattr_idmapped, change_idmapping) +{ +int open_tree_fd = -EBADF ; +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + }; + +if (!mount_setattr_supported ()) +SKIP (return,"mount_setattr syscall not supported" ); + + open_tree_fd =sys_open_tree (-EBADF ,"/mnt/D" , +AT_EMPTY_PATH | +AT_NO_AUTOMOUNT | +AT_SYMLINK_NOFOLLOW | +OPEN_TREE_CLOEXEC | +OPEN_TREE_CLONE ); +ASSERT_GE (open_tree_fd,0 ); + + attr.userns_fd =get_userns_fd (0 ,10000 ,10000 ); +ASSERT_GE (attr.userns_fd,0 ); +ASSERT_EQ (sys_mount_setattr (open_tree_fd,"" , +AT_EMPTY_PATH , &attr,sizeof (attr)),0 ); +ASSERT_EQ (close (attr.userns_fd),0 ); + +/* Change idmapping on a detached mount that is already idmapped. */ + attr.userns_fd =get_userns_fd (0 ,20000 ,10000 ); +ASSERT_GE (attr.userns_fd,0 ); +ASSERT_NE (sys_mount_setattr (open_tree_fd,"" ,AT_EMPTY_PATH , &attr,sizeof (attr)),0 ); +ASSERT_EQ (close (attr.userns_fd),0 ); +ASSERT_EQ (close (open_tree_fd),0 ); +} + +static bool expected_uid_gid (int dfd,const char *path,int flags, +uid_t expected_uid,gid_t expected_gid) +{ +int ret; +struct stat st; + + ret =fstatat (dfd, path, &st, flags); +if (ret <0 ) +return false; + +return st.st_uid == expected_uid && st.st_gid == expected_gid; +} + +TEST_F(mount_setattr_idmapped, idmap_mount_tree_invalid) +{ +int open_tree_fd = -EBADF ; +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + }; + +if (!mount_setattr_supported ()) +SKIP (return,"mount_setattr syscall not supported" ); + +ASSERT_EQ (expected_uid_gid (-EBADF ,"/tmp/B/b" ,0 ,0 ,0 ),0 ); +ASSERT_EQ (expected_uid_gid (-EBADF ,"/tmp/B/BB/b" ,0 ,0 ,0 ),0 ); + + open_tree_fd =sys_open_tree (-EBADF ,"/mnt/A" , +AT_RECURSIVE | +AT_EMPTY_PATH | +AT_NO_AUTOMOUNT | +AT_SYMLINK_NOFOLLOW | +OPEN_TREE_CLOEXEC | +OPEN_TREE_CLONE ); +ASSERT_GE (open_tree_fd,0 ); + + attr.userns_fd =get_userns_fd (0 ,10000 ,10000 ); +ASSERT_GE (attr.userns_fd,0 ); +ASSERT_NE (sys_mount_setattr (open_tree_fd,"" ,AT_EMPTY_PATH , &attr,sizeof (attr)),0 ); +ASSERT_EQ (close (attr.userns_fd),0 ); +ASSERT_EQ (close (open_tree_fd),0 ); + +ASSERT_EQ (expected_uid_gid (-EBADF ,"/tmp/B/b" ,0 ,0 ,0 ),0 ); +ASSERT_EQ (expected_uid_gid (-EBADF ,"/tmp/B/BB/b" ,0 ,0 ,0 ),0 ); +ASSERT_EQ (expected_uid_gid (open_tree_fd,"B/b" ,0 ,0 ,0 ),0 ); +ASSERT_EQ (expected_uid_gid (open_tree_fd,"B/BB/b" ,0 ,0 ,0 ),0 ); +} +TEST_HARNESS_MAIN
Signature · 6 lines
2.30.0 _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
Randy Dunlap
reviewerRe: [PATCH v5 41/42] tests: extend mount_setattr tests
Hi,
Quoted 22 lines · Christian Brauner
---
/* v2 */
patch introduced/* v3 */
- Christoph Hellwig <[email protected]>, Darrick J. Wong <[email protected]>:
- Port main test-suite to xfstests./* v4 */
unchanged/* v5 */
base-commit:7c53f6b671f4aba70ff15e1b05148b10d58c2837--- .../mount_setattr/mount_setattr_test.c | 483 ++++++++++++++++++ 1 file changed, 483 insertions(+)tools/testing/selftests/mount_setattr/mount_setattr_test.c +0
-0
tools/testing/selftests/mount_setattr/mount_setattr_test.c struct mount_attr { · line 113
Quoted 6 lines
tools/testing/selftests/mount_setattr/mount_setattr_test.c +1
-0@@ -108,15 +108,57 @@ struct mount_attr {__u64 attr_set;__u64 attr_clr;__u64 propagation; + __u64 userns_fd; };#endif
...
Does "/**" have any special meaning inside tools/testing/ and the selftest framework? (I don't see any other such users.)
If not, can you just use the usual "/*" instead? (multiple locations)
Quoted 5 lines
tools/testing/selftests/mount_setattr/mount_setattr_test.c +5
-0+/** +* Validate that negative fd values are rejected. +*/ +TEST_F(mount_setattr_idmapped, invalid_fd_negative) +{
...
Quoted 7 lines
tools/testing/selftests/mount_setattr/mount_setattr_test.c +7
-0+} + +/** +* Validate that excessively large fd values are rejected. +*/ +TEST_F(mount_setattr_idmapped, invalid_fd_large) +{
...
Quoted 7 lines
tools/testing/selftests/mount_setattr/mount_setattr_test.c +7
-0+} + +/** +* Validate that closed fd values are rejected. +*/ +TEST_F(mount_setattr_idmapped, invalid_fd_closed) +{
...
Quoted 8 lines
tools/testing/selftests/mount_setattr/mount_setattr_test.c +8
-0+ } +} + +/** +* Validate that the initial user namespace is rejected. +*/ +TEST_F(mount_setattr_idmapped, invalid_fd_initial_userns) +{
...
Quoted 17 lines
tools/testing/selftests/mount_setattr/mount_setattr_test.c +17
-0+/** +* Validate that an attached mount in our mount namespace can be idmapped. +* (The kernel enforces that the mount's mount namespace and the caller's mount +* namespace match.) +*/ +TEST_F(mount_setattr_idmapped, attached_mount_inside_current_mount_namespace) +{ +} + +/** +* Validate that idmapping a mount is rejected if the mount's mount namespace +* and our mount namespace don't match. +* (The kernel enforces that the mount's mount namespace and the caller's mount +* namespace match.) +*/ +TEST_F(mount_setattr_idmapped, attached_mount_outside_current_mount_namespace) +{
...
Quoted 7 lines
tools/testing/selftests/mount_setattr/mount_setattr_test.c +7
-0+} + +/** +* Validate that an attached mount in our mount namespace can be idmapped. +*/ +TEST_F(mount_setattr_idmapped, detached_mount_inside_current_mount_namespace) +{
...
Quoted 7 lines
tools/testing/selftests/mount_setattr/mount_setattr_test.c +7
-0+} + +/** +* Validate that a detached mount not in our mount namespace can be idmapped. +*/ +TEST_F(mount_setattr_idmapped, detached_mount_outside_current_mount_namespace) +{
...
tools/testing/selftests/mount_setattr/mount_setattr_test.c TEST_F(mount_setattr, wrong_mount_namespace) · line 1346
Quoted 7 lines
tools/testing/selftests/mount_setattr/mount_setattr_test.c +7
-0+} + +/** +* Validate that currently changing the idmapping of an idmapped mount fails. +*/ +TEST_F(mount_setattr_idmapped, change_idmapping) +{
thanks.
Signature · 7 lines
~Randy You can't do anything without having to do something else first. -- Belefant's Law _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
PATCH v5 42/42 generic/622: add fstests for idmapped mounts
In reply to Christian BraunerAdd a test suite to verify the behavior of idmapped mounts. The test suite also includes a range of vfs tests to verify that no regressions are introduced by idmapped mounts. The following tests are currently available with more to come in the future:
01. posix acls on regular and idmapped mounts
02. create operations in user namespace
03. device node creation in user namespace
04. expected ownership on idmapped mounts
05. fscaps on regular mounts
06. fscaps on idmapped mounts
07. fscaps on idmapped mounts in user namespace
08. fscaps on idmapped mounts in user namespace
with different id mappings
09. mapped fsids
10. unmapped fsids
11. cross mount hardlink
12. cross idmapped mount hardlink
13. hardlinks from idmapped mounts
14. hardlinks from idmapped mounts in user namespace
15. io_uring
16. io_uring in user namespace
17. io_uring from idmapped mounts
18. io_uring from idmapped mounts in user namespace
19. io_uring from idmapped mounts with unmapped ids
20. io_uring from idmapped mounts with unmapped ids in user namespace
21. following protected symlinks on regular mounts
22. following protected symlinks on idmapped mounts
23. following protected symlinks on idmapped mounts in user namespace
24. cross mount rename
25. cross idmapped mount rename
26. rename from idmapped mounts
27. rename from idmapped mounts in user namespace
28. symlink from regular mounts
29. symlink from idmapped mounts
30. symlink from idmapped mounts in user namespace
31. setid binaries on regular mounts
32. setid binaries on idmapped mounts
33. setid binaries on idmapped mounts in user namespace
34. setid binaries on idmapped mounts in user namespace with different id mappings
35. sticky bit unlink operations on regular mounts
36. sticky bit unlink operations on idmapped mounts
37. sticky bit unlink operations on idmapped mounts in user namespace
38. sticky bit rename operations on regular mounts
39. sticky bit rename operations on idmapped mounts
40. sticky bit rename operations on idmapped mounts in user namespace
41. create operations in directories with setgid bit set
42. create operations in directories with setgid bit set on idmapped mounts
43. create operations in directories with setgid bit set on idmapped mounts in user namespace
---
/* v2 */
test-suite part of the kernel selftest framework
/* v3 */
patch introduced (ported form kernel selftest framework)
/* v4 */
- Amir Goldstein <[email protected]>:
- Don't Cc fstests mailing list on the testing patches for now.
- Add setgid creation tests.
/* v5 */
new base: 2080ad637bbb4d2c24c4d63939799dab178eb407
- Christoph Hellwig <[email protected]>:
- Enable xfs testing.
- Improve idmapped mount testing support.
- Christian Brauner <[email protected]>:
- Fix protected symlink tests.
- Introduce xfs specific helpers.
- Expand setgid bit tests to xfs.
--- common/rc | 25 + configure.ac | 2 + include/builddefs.in | 1 + m4/Makefile | 1 + m4/package_libcap.m4 | 4 + src/Makefile | 5 + src/feature.c | 40 +- src/idmapped-mounts/Makefile | 34 + src/idmapped-mounts/idmapped-mounts.c | 8001 +++++++++++++++++++++++++ src/idmapped-mounts/missing.h | 155 + src/idmapped-mounts/utils.c | 134 + src/idmapped-mounts/utils.h | 29 + tests/generic/622 | 43 + tests/generic/622.out | 2 + tests/generic/group | 1 + 15 files changed, 8473 insertions(+), 4 deletions(-) create mode 100644 m4/package_libcap.m4 create mode 100644 src/idmapped-mounts/Makefile create mode 100644 src/idmapped-mounts/idmapped-mounts.c create mode 100644 src/idmapped-mounts/missing.h create mode 100644 src/idmapped-mounts/utils.c create mode 100644 src/idmapped-mounts/utils.h create mode 100755 tests/generic/622 create mode 100644 tests/generic/622.out
common/rc +25 -0
@@ -2003,6 +2003,31 @@ _require_io_uring() esac } +# test whether the mount_setattr syscall is available +_require_mount_setattr() +{ + $here/src/feature -r + case $? in + 0) + ;; + 1) + _notrun "kernel does not support mount_setattr syscall" + ;; + *) + _fail "unexpected error testing for mount_setattr support" + ;; + esac +} + +# test whether idmapped mounts are supported +_require_idmapped_mounts() +{ + IDMAPPED_MOUNTS_TEST=$here/src/idmapped-mounts/idmapped-mounts + [ -x $IDMAPPED_MOUNTS_TEST ] || _notrun "idmapped-mounts utilities required" + + _require_mount_setattr +} + # this test requires that a test program exists under src/ # $1 - command (require) #
configure.ac +2 -0
@@ -63,6 +63,7 @@ AC_PACKAGE_WANT_GDBM AC_PACKAGE_WANT_AIO AC_PACKAGE_WANT_URING AC_PACKAGE_WANT_DMAPI +AC_PACKAGE_WANT_LIBCAP AC_PACKAGE_WANT_LINUX_FIEMAP_H AC_PACKAGE_WANT_FALLOCATE AC_PACKAGE_WANT_OPEN_BY_HANDLE_AT
@@ -73,6 +74,7 @@ AC_PACKAGE_WANT_LIBBTRFSUTIL AC_HAVE_COPY_FILE_RANGE AC_CHECK_FUNCS([renameat2]) +AC_CHECK_TYPES([struct mount_attr], [], [], [[#include <linux/mount.h>]]) AC_CONFIG_HEADER(include/config.h) AC_CONFIG_FILES([include/builddefs])
include/builddefs.in +1 -0
@@ -62,6 +62,7 @@ ENABLE_SHARED = @enable_shared@ HAVE_DB = @have_db@ HAVE_AIO = @have_aio@ HAVE_URING = @have_uring@ +HAVE_LIBCAP = @have_libcap@ HAVE_FALLOCATE = @have_fallocate@ HAVE_OPEN_BY_HANDLE_AT = @have_open_by_handle_at@ HAVE_DMAPI = @have_dmapi@
m4/Makefile +1 -0
@@ -13,6 +13,7 @@ LSRCFILES = \ package_attrdev.m4 \ package_dmapidev.m4 \ package_globals.m4 \ + package_libcap.m4 \ package_libcdev.m4 \ package_liburing.m4 \ package_ncurses.m4 \
m4/package_libcap.m4 new file +4 -0
@@ -0,0 +1,4 @@ +AC_DEFUN([AC_PACKAGE_WANT_LIBCAP], + [ AC_CHECK_HEADERS(sys/capability.h, [ have_libcap=true ], [ have_libcap=false ]) + AC_SUBST(have_libcap) + ])
src/Makefile +5 -0
@@ -70,6 +70,11 @@ ifeq ($(HAVE_URING), true) LLDLIBS += -luring endif +SUBDIRS += idmapped-mounts +ifeq ($(HAVE_LIBCAP), true) +LLDLIBS += -lcap +endif + CFILES = $(TARGETS:=.c) LDIRT = $(TARGETS) fssum
src/feature.c +36 -4
@@ -19,6 +19,7 @@* * Test for machine features * -A test whether AIO syscalls are available +* -r test whether mount_setattr syscall is supported * -R test whether IO_URING syscalls are available * -o report a number of online cpus * -s report pagesize
@@ -30,6 +31,7 @@#include <sys/quota.h> #include <sys/resource.h> #include <signal.h> +#include <syscall.h> #include <unistd.h> #ifdef HAVE_XFS_XQM_H
@@ -44,6 +46,8 @@#include <liburing.h> #endif +#include "idmapped-mounts/missing.h" +#ifndef USRQUOTA #define USRQUOTA 0#endif
@@ -64,7 +68,7 @@ usage(void)fprintf (stderr,"Usage: feature [-v] -<q|u|g|p|U|G|P> <filesystem>\n" );fprintf (stderr," feature [-v] -c <file>\n" );fprintf (stderr," feature [-v] -t <file>\n" ); -fprintf (stderr," feature -A | -R | -o | -s | -w\n" ); +fprintf (stderr," feature -A | -r | -R | -o | -s | -w\n" );exit (1 ); }
@@ -243,6 +247,27 @@ check_uring_support(void)#endif } +static int +check_mount_setattr_support (void ) +{ +int err; +struct mount_attr attr = { + .attr_set =MOUNT_ATTR_IDMAP , + .userns_fd = -EBADF , + }; + +/* mount_setattr() syscall not supported. */ + err =sys_mount_setattr (-EBADF ,"" ,AT_EMPTY_PATH ,NULL ,0 ); +if (err && errno ==ENOSYS ) +return 1 ; + +/* idmapped mounts not supported */ + err =sys_mount_setattr (-EBADF ,"." ,AT_EMPTY_PATH ,NULL ,0 ); +if (err && errno ==E2BIG ) +return 1 ; + +return 0 ; +}int main (int argc,char **argv)
@@ -256,6 +281,7 @@ main(int argc, char **argv)int pflag =0 ;int Pflag =0 ;int qflag =0 ; +int rflag =0 ;int Rflag =0 ;int sflag =0 ;int uflag =0 ;
@@ -264,7 +290,7 @@ main(int argc, char **argv)int oflag =0 ;char *fs =NULL ; -while ((c =getopt (argc, argv,"ActgGopPqRsuUvw" )) !=EOF ) { +while ((c =getopt (argc, argv,"ActgGopPqrRsuUvw" )) !=EOF ) {switch (c) {case 'A' : Aflag++;
@@ -293,6 +319,9 @@ main(int argc, char **argv)case 'q' : qflag++;break ; +case 'r' : + rflag++; +break ;case 'R' : Rflag++;break ;
@@ -321,10 +350,10 @@ main(int argc, char **argv)if (optind != argc-1 )/* need a device */ usage (); fs = argv[argc-1 ]; - }else if (Aflag || Rflag || wflag || sflag || oflag) { + }else if (Aflag || rflag || Rflag || wflag || sflag || oflag) {if (optind != argc)usage (); - }else + }else usage ();if (cflag)
@@ -349,6 +378,9 @@ main(int argc, char **argv)if (Aflag)return (check_aio_support ()); +if (rflag) +return (check_mount_setattr_support ()); +if (Rflag)return (check_uring_support ());
src/idmapped-mounts/Makefile new file +34 -0
@@ -0,0 +1,34 @@ +# SPDX-License-Identifier: GPL-2.0 + +TOPDIR = ../.. +include $(TOPDIR)/include/builddefs + +TARGETS = idmapped-mounts + +CFILES = idmapped-mounts.c utils.c +HFILES = missing.h utils.h +LDIRT = $(TARGETS) + +ifeq ($(HAVE_LIBCAP), true) +LLDLIBS += -lcap +endif + +ifeq ($(HAVE_URING), true) +LLDLIBS += -luring +endif + +default: depend $(TARGETS) + +depend: .dep + +include $(BUILDRULES) + +$(TARGETS): $(CFILES) + @echo " [CC] $@" + $(Q)$(LTLINK) $(CFILES) -o $@ $(CFLAGS) $(LDFLAGS) $(LDLIBS) + +install: + $(INSTALL) -m 755 -d $(PKG_LIB_DIR)/src/idmapped-mounts + $(INSTALL) -m 755 $(TARGETS) $(PKG_LIB_DIR)/src/idmapped-mounts + +-include .dep
src/idmapped-mounts/idmapped-mounts.c new file +8001 -0
2,790 lines not on this page · raw message
src/idmapped-mounts/missing.h new file +155 -0
155 lines not on this page · raw message
src/idmapped-mounts/utils.c new file +134 -0
134 lines not on this page · raw message
tests/generic/622 new file +43 -0
43 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
base-commit: 2080ad637bbb4d2c24c4d63939799dab178eb407
Signature · 1 line
2.30.0
Part of the diff is not shown here. View the raw message.
Quoted 4 lines · Christian Brauner
Hey everyone,
The only major change is the inclusion of hch's patch to port XFS to support idmapped mounts. Thanks to Christoph for doing that work.
Yay :)
Quoted 17 lines
(For a full list of major changes between versions see the end of this
cover letter.
Please also note the large xfstests testsuite in patch 42 that has been kept as part of this series. It verifies correct vfs behavior with and without idmapped mounts including covering newer vfs features such asio_uring.
I currently still plan to target the v5.12 merge window.)With this patchset we make it possible to attach idmappings to mounts, i.e. simply put different bind mounts can expose the same file or directory with different ownership.
Shifting of ownership on a per-mount basis handles a wide range of long standing use-cases. Here are just a few:
- Shifting of a subset of ownership-less filesystems (vfat) for use by multiple users, effectively allowing for DAC on such devices (systemd, Android, ...)
- Allow remapping uid/gid on external filesystems or paths (USB sticks,
Quoted 8 lines
network filesystem, ...) to match the local system's user and groups. (David Howells intends to port AFS as a first candidate.)
- Shifting of a container rootfs or base image without having to mangle every file (runc, Docker, containerd, k8s, LXD, systemd ...)
- Sharing of data between host or privileged containers with unprivileged containers (runC, Docker, containerd, k8s, LXD, ...)
- Data sharing between multiple user namespaces with incompatible maps (LXD, k8s, ...)
That sounds neat. AFAICT, the VFS passes the filesystem a mount userns structure, which is then carried down the call stack to whatever functions actually care about mapping kernel [ug]ids to their ondisk versions?
Does quota still work after this patchset is applied? There isn't any mention of that in the cover letter and I don't see a code patch, so does that mean everything just works? I'm particularly curious about whether there can exist processes with CAP_SYS_ADMIN and an idmapped mount? Syscalls like bulkstat and quotactl present file [ug]ids to programs, but afaict there won't be any translating going on?
(To be fair, bulkstat is an xfs-only thing, but quota control isn't.)
I'll start skimming the patchset...
--D
Quoted 770 lines
There has been significant interest in this patchset as evidenced by user commenting on previous version of this patchset. They include containerd, ChromeOS, systemd, LXD and a range of others. There is already a patchset up for containerd, the default Kubernetes container runtime https://github.com/containerd/containerd/pull/4734
to make use of this. systemd intends to use it in their systemd-homed implementation for portable home directories. ChromeOS wants to make use of it to share data between the host and the Linux containers they run on Chrome- and Pixelbooks.
(Fwiw, for fun and since I wanted to do this for a long time I've ported
my home directory to be completely portable with a simple service file that now mounts my home directory on an ext4 formatted usb stick with an id mapping mapping all files to the random uid I'm assigned at login.)Making it possible to share directories and mounts between users with different uids and gids is itself quite an important use-case in distributed systems environments. It's of course especially useful in general for portable usb sticks, sharing data between multiple users in, and sharing home directories between multiple users. The last example is now elegantly expressed in systemd's homed concept for portable home directories. As mentioned above, idmapped mounts also allow data from the host to be shared with unprivileged containers, between privileged and unprivileged containers simultaneously and in addition also between unprivileged containers with different idmappings whenever they are used to isolate one container completely from another container.
We have implemented and proposed multiple solutions to this before. This included the introduction of fsid mappings, a tiny filesystem I've authored with Seth Forshee that is currently carried in Ubuntu that has shown to be the wrong approach, and the conceptual hack of calling override creds directly in the vfs. In addition, to some of these solutions being hacky none of these solutions have covered all of the above use-cases.
Idmappings become a property of struct vfsmount instead of tying it to a process being inside of a user namespace which has been the case for all other proposed approaches. It also allows to pass down the user namespace into the filesystems which is a clean way instead of violating calling conventions by strapping the user namespace information that is a property of the mount to the caller's credentials or similar hacks. Each mount can have a separate idmapping and idmapped mounts can even be created in the initial user namespace unblocking a range of use-cases.
To this end the vfsmount struct gains a new struct
user_namespacemember. The idmapping of the user namespace becomes the idmapping of the mount. A caller that is privileged with respect to the user namespace of the superblock of the underlying filesystem can create an idmapped mount. In the future, we can enable unprivileged use-cases by checking whether the caller is privileged wrt to the user namespace that an already idmapped mount has been marked with, allowing them to change the idmapping. For now, keep things simple until the need arises. Note, that with syscall interception it is already possible to intercept idmapped mount requests from unprivileged containers and handle them in a sufficiently privileged container manager. Support for this is already available in LXD and will be available in runC where syscall interception is currently in the process of becoming part of the runtime
spec: https://github.com/opencontainers/runtime-spec/pull/1074.The user namespace the mount will be marked with can be specified by passing a file descriptor refering to the user namespace as an argument to the new
mount_setattr()syscall together with the newMOUNT_ATTR_IDMAPflag. By default vfsmounts are marked with the initial user namespace and no behavioral or performance changes are observed. All mapping operations are nops for the initial user namespace. When a file/inode is accessed through an idmapped mount thei_uidandi_gidof the inode will be remapped according to the user namespace the mount has been marked with.In order to support idmapped mounts, filesystems need to be changed and mark themselves with the
FS_ALLOW_IDMAPflag infs_flags. The initial version contains fat, ext4, and xfs including a list of examples. But patches for other filesystems are actively worked on and will be sent out separately. We are here to see this through and there are multiple people involved in converting filesystems. So filesystem developers are not left alone with this and are provided with a large testsuite to verify that their port is correct.There is a simple tool available at
https://github.com/brauner/mount-idmapped that allows to create idmapped mounts so people can play with this patch series. Here are a few illustrations:1. Create a simple idmapped mount of another user's home directory
u1001@f2-vm:/$ sudo ./mount-idmapped --map-mount b:1000:1001:1 /home/ubuntu/ /mnt u1001@f2-vm:/$ ls -al /home/ubuntu/ total 28 drwxr-xr-x 2 ubuntu ubuntu 4096 Oct 28 22:07 . drwxr-xr-x 4 root root 4096 Oct 28 04:00 ..(quoted diff) +0
-6-rw------- 1 ubuntu ubuntu 3154 Oct 28 22:12 .bash_history -rw-r--r-- 1 ubuntu ubuntu 220 Feb 25 2020 .bash_logout -rw-r--r-- 1 ubuntu ubuntu 3771 Feb 25 2020 .bashrc -rw-r--r-- 1 ubuntu ubuntu 807 Feb 25 2020 .profile -rw-r--r-- 1 ubuntu ubuntu 0 Oct 16 16:11 .sudo_as_admin_successful -rw------- 1 ubuntu ubuntu 1144 Oct 28 00:43 .viminfou1001@f2-vm:/$ ls -al /mnt/ total 28 drwxr-xr-x 2 u1001 u1001 4096 Oct 28 22:07 . drwxr-xr-x 29 root root 4096 Oct 28 22:01 ..(quoted diff) +0
-6-rw------- 1 u1001 u1001 3154 Oct 28 22:12 .bash_history -rw-r--r-- 1 u1001 u1001 220 Feb 25 2020 .bash_logout -rw-r--r-- 1 u1001 u1001 3771 Feb 25 2020 .bashrc -rw-r--r-- 1 u1001 u1001 807 Feb 25 2020 .profile -rw-r--r-- 1 u1001 u1001 0 Oct 16 16:11 .sudo_as_admin_successful -rw------- 1 u1001 u1001 1144 Oct 28 00:43 .viminfou1001@f2-vm:/$ touch /mnt/my-file u1001@f2-vm:/$ setfacl -m u:1001:rwx /mnt/my-file u1001@f2-vm:/$ sudo setcap -n 1001 cap_net_raw+ep /mnt/my-file u1001@f2-vm:/$ ls -al /mnt/my-file -rw-rwxr--+ 1 u1001 u1001 0 Oct 28 22:14 /mnt/my-file u1001@f2-vm:/$ ls -al /home/ubuntu/my-file -rw-rwxr--+ 1 ubuntu ubuntu 0 Oct 28 22:14 /home/ubuntu/my-file u1001@f2-vm:/$ getfacl /mnt/my-file getfacl: Removing leading '/' from absolute path names # file: mnt/my-file # owner: u1001 # group: u1001 user::rw- user:u1001:rwx group::rw- mask::rwx other::r-- u1001@f2-vm:/$ getfacl /home/ubuntu/my-file getfacl: Removing leading '/' from absolute path names # file: home/ubuntu/my-file # owner: ubuntu # group: ubuntu user::rw- user:ubuntu:rwx group::rw- mask::rwx other::r--2. Create mapping of the whole ext4 rootfs without a mapping for uid and gid 0
ubuntu@f2-vm:~$ sudo /mount-idmapped --map-mount b:1:1:65536 / /mnt/ ubuntu@f2-vm:~$ findmnt | grep mnt └─/mnt /dev/sda2 ext4 rw,relatime └─/mnt/mnt /dev/sda2 ext4 rw,relatime ubuntu@f2-vm:~$ sudo mkdir /AS-ROOT-CAN-CREATE ubuntu@f2-vm:~$ sudo mkdir /mnt/AS-ROOT-CANT-CREATE mkdir: cannot create directory ‘/mnt/AS-ROOT-CANT-CREATE’: Value too large for defined data type ubuntu@f2-vm:~$ mkdir /mnt/home/ubuntu/AS-USER-1000-CAN-CREATE3. Create a vfat usb mount and expose to user 1001 and 5000
ubuntu@f2-vm:/$ sudo mount /dev/sdb /mnt ubuntu@f2-vm:/$ findmnt | grep mnt └─/mnt /dev/sdb vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro ubuntu@f2-vm:/$ ls -al /mnt total 12 drwxr-xr-x 2 root root 4096 Jan 1 1970 . drwxr-xr-x 34 root root 4096 Oct 28 22:24 ..(quoted diff) +0
-2-rwxr-xr-x 1 root root 4 Oct 28 03:44 aaa -rwxr-xr-x 1 root root 0 Oct 28 01:09 bbbubuntu@f2-vm:/$ sudo /mount-idmapped --map-mount b:0:1001:1 /mnt /mnt-1001/ ubuntu@f2-vm:/$ ls -al /mnt-1001/ total 12 drwxr-xr-x 2 u1001 u1001 4096 Jan 1 1970 . drwxr-xr-x 34 root root 4096 Oct 28 22:24 ..(quoted diff) +0
-2-rwxr-xr-x 1 u1001 u1001 4 Oct 28 03:44 aaa -rwxr-xr-x 1 u1001 u1001 0 Oct 28 01:09 bbbubuntu@f2-vm:/$ sudo /mount-idmapped --map-mount b:0:5000:1 /mnt /mnt-5000/ ubuntu@f2-vm:/$ ls -al /mnt-5000/ total 12 drwxr-xr-x 2 5000 5000 4096 Jan 1 1970 . drwxr-xr-x 34 root root 4096 Oct 28 22:24 ..(quoted diff) +0
-2-rwxr-xr-x 1 5000 5000 4 Oct 28 03:44 aaa -rwxr-xr-x 1 5000 5000 0 Oct 28 01:09 bbb4. Create an idmapped rootfs mount for a container
root@f2-vm:~# ls -al /var/lib/lxc/f2/rootfs/ total 68 drwxr-xr-x 17 20000 20000 4096 Sep 24 07:48 . drwxrwx--- 3 20000 20000 4096 Oct 16 19:26 .. lrwxrwxrwx 1 20000 20000 7 Sep 24 07:43 bin -> usr/bin drwxr-xr-x 2 20000 20000 4096 Apr 15 2020 boot drwxr-xr-x 3 20000 20000 4096 Oct 16 19:26 dev drwxr-xr-x 61 20000 20000 4096 Oct 16 19:26 etc drwxr-xr-x 3 20000 20000 4096 Sep 24 07:45 home lrwxrwxrwx 1 20000 20000 7 Sep 24 07:43 lib -> usr/lib lrwxrwxrwx 1 20000 20000 9 Sep 24 07:43 lib32 -> usr/lib32 lrwxrwxrwx 1 20000 20000 9 Sep 24 07:43 lib64 -> usr/lib64 lrwxrwxrwx 1 20000 20000 10 Sep 24 07:43 libx32 -> usr/libx32 drwxr-xr-x 2 20000 20000 4096 Sep 24 07:43 media drwxr-xr-x 2 20000 20000 4096 Sep 24 07:43 mnt drwxr-xr-x 2 20000 20000 4096 Sep 24 07:43 opt drwxr-xr-x 2 20000 20000 4096 Apr 15 2020 proc drwx------ 2 20000 20000 4096 Sep 24 07:43 root drwxr-xr-x 2 20000 20000 4096 Sep 24 07:45 run lrwxrwxrwx 1 20000 20000 8 Sep 24 07:43 sbin -> usr/sbin drwxr-xr-x 2 20000 20000 4096 Sep 24 07:43 srv drwxr-xr-x 2 20000 20000 4096 Apr 15 2020 sys drwxrwxrwt 2 20000 20000 4096 Sep 24 07:44 tmp drwxr-xr-x 13 20000 20000 4096 Sep 24 07:43 usr drwxr-xr-x 12 20000 20000 4096 Sep 24 07:44 var root@f2-vm:~# /mount-idmapped --map-mount b:20000:10000:100000 /var/lib/lxc/f2/rootfs/ /mnt root@f2-vm:~# ls -al /mnt total 68 drwxr-xr-x 17 10000 10000 4096 Sep 24 07:48 . drwxr-xr-x 34 root root 4096 Oct 28 22:24 .. lrwxrwxrwx 1 10000 10000 7 Sep 24 07:43 bin -> usr/bin drwxr-xr-x 2 10000 10000 4096 Apr 15 2020 boot drwxr-xr-x 3 10000 10000 4096 Oct 16 19:26 dev drwxr-xr-x 61 10000 10000 4096 Oct 16 19:26 etc drwxr-xr-x 3 10000 10000 4096 Sep 24 07:45 home lrwxrwxrwx 1 10000 10000 7 Sep 24 07:43 lib -> usr/lib lrwxrwxrwx 1 10000 10000 9 Sep 24 07:43 lib32 -> usr/lib32 lrwxrwxrwx 1 10000 10000 9 Sep 24 07:43 lib64 -> usr/lib64 lrwxrwxrwx 1 10000 10000 10 Sep 24 07:43 libx32 -> usr/libx32 drwxr-xr-x 2 10000 10000 4096 Sep 24 07:43 media drwxr-xr-x 2 10000 10000 4096 Sep 24 07:43 mnt drwxr-xr-x 2 10000 10000 4096 Sep 24 07:43 opt drwxr-xr-x 2 10000 10000 4096 Apr 15 2020 proc drwx------ 2 10000 10000 4096 Sep 24 07:43 root drwxr-xr-x 2 10000 10000 4096 Sep 24 07:45 run lrwxrwxrwx 1 10000 10000 8 Sep 24 07:43 sbin -> usr/sbin drwxr-xr-x 2 10000 10000 4096 Sep 24 07:43 srv drwxr-xr-x 2 10000 10000 4096 Apr 15 2020 sys drwxrwxrwt 2 10000 10000 4096 Sep 24 07:44 tmp drwxr-xr-x 13 10000 10000 4096 Sep 24 07:43 usr drwxr-xr-x 12 10000 10000 4096 Sep 24 07:44 var root@f2-vm:~# lxc-start f2 # uses /mnt as rootfs root@f2-vm:~# lxc-attach f2 -- cat /proc/1/uid_map 0 10000 10000 root@f2-vm:~# lxc-attach f2 -- cat /proc/1/gid_map 0 10000 10000 root@f2-vm:~# lxc-attach f2 -- ls -al / total 52 drwxr-xr-x 17 root root 4096 Sep 24 07:48 . drwxr-xr-x 17 root root 4096 Sep 24 07:48 .. lrwxrwxrwx 1 root root 7 Sep 24 07:43 bin -> usr/bin drwxr-xr-x 2 root root 4096 Apr 15 2020 boot drwxr-xr-x 5 root root 500 Oct 28 23:39 dev drwxr-xr-x 61 root root 4096 Oct 28 23:39 etc drwxr-xr-x 3 root root 4096 Sep 24 07:45 home lrwxrwxrwx 1 root root 7 Sep 24 07:43 lib -> usr/lib lrwxrwxrwx 1 root root 9 Sep 24 07:43 lib32 -> usr/lib32 lrwxrwxrwx 1 root root 9 Sep 24 07:43 lib64 -> usr/lib64 lrwxrwxrwx 1 root root 10 Sep 24 07:43 libx32 -> usr/libx32 drwxr-xr-x 2 root root 4096 Sep 24 07:43 media drwxr-xr-x 2 root root 4096 Sep 24 07:43 mnt drwxr-xr-x 2 root root 4096 Sep 24 07:43 opt dr-xr-xr-x 232 nobody nogroup 0 Oct 28 23:39 proc drwx------ 2 root root 4096 Oct 28 23:41 root drwxr-xr-x 12 root root 360 Oct 28 23:39 run lrwxrwxrwx 1 root root 8 Sep 24 07:43 sbin -> usr/sbin drwxr-xr-x 2 root root 4096 Sep 24 07:43 srv dr-xr-xr-x 13 nobody nogroup 0 Oct 28 23:39 sys drwxrwxrwt 11 root root 4096 Oct 28 23:40 tmp drwxr-xr-x 13 root root 4096 Sep 24 07:43 usr drwxr-xr-x 12 root root 4096 Sep 24 07:44 var root@f2-vm:~# lxc-attach f2 -- ls -al /my-file -rw-r--r-- 1 root root 0 Oct 28 23:43 /my-file root@f2-vm:~# ls -al /var/lib/lxc/f2/rootfs/my-file -rw-r--r-- 1 20000 20000 0 Oct 28 23:43 /var/lib/lxc/f2/rootfs/my-fileI'd like to say thanks to:
Al for pointing me into the direction to avoid inode alias issues during lookup. David for various discussions around this. Christoph for porting xfs, providing good reviews and for being involved in the original idea. Tycho for helping with this series and on future patches to convert filesystems. Alban Crequy and the Kinvolk peeps located just a few streets away from me in Berlin for providing use-case discussions and writing patches for containerd. Stéphane for his invaluable input on many things and level head and enabling me to work on this. Amir for explaining and discussing aspects of overlayfs with me. I'd like to especially thank Seth Forshee. He provided a lot of good analysis, suggestions, and participated in short-notice discussions in both chat and video for some nitty-gritty technical details.This series can be found and pulled from the three usual locations:
https://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git/log/?h=idmapped_mounts
https://github.com/brauner/linux/tree/idmapped_mounts
https://gitlab.com/brauner/linux/-/commits/idmapped_mounts/* v5 */
- Adress Christoph's feedback.
- Use v5.11-rc3 as new base.
- Add Christoph's xfs port./* v4 */
- Split out several preparatory patches from the initialmount_setattrpatch as requested by Christoph.
- Add new tests for file/directory creation in directories with the setgid bit set. Specifically, verify that the setgid bit is correctly ignored when creating a file with the setgid bit and the parent directory'si_gidisn'tin_group_p()and the caller isn'tcapable_wrt_inode_uidgid()over the parent directory's inode wheninode_init_owner()is called.
Conversely, verify that the setgid bit is set when creating a file with the setgid bit and the parent'si_gidis eitherin_group_p()or the caller iscapable_wrt_inode_uidgid()over the parent directory's inode. In additiona, verify that the setgid bit is always inherited when creating directories.
Test all of this on regular mounts, idmapped mounts, and on idmapped mounts in user namespaces.
- Add new tests to verify that thei_gidof newly created files or directories is correctly set to the parent directory'si_gidwhen the parent directory has the setgid bit set.
- Use "mnt_userns" as the de facto name for a vfsmount's user namespace everywhere as suggested by Serge.
- Reuse existing propagation flags instead of introducing new ones as suggested by Christoph. (This is in line with Linus request to not introduce too many new flags as evidenced by prior discussions on other patchsets such asopenat2().)
- Add first set of Acked-bys from Serge and Reviewed-bys from Christoph.
- Fix commit messages to reflect the fact that we modify existing vfs helpers but do not introduce new ones like we did in the first version. Some commit messages still implied we were adding new helpers.
- Reformat all commit messages to adhere to 73 char length limit and wrap all lines in commits at 80 chars whenever this doesn't hinder legibility.
- Simplify various codepaths with Christoph's suggestions./* v3 */
- The major change is the port of the test-suite from the kernel-internal selftests framework to xfstests as requested by Darrick and Christoph. The test-suite for xfstests is patch 38 in this series. It has been kept as part of this series even though it belongs to xfstests so it's easier to see what is tested and to keep it in-sync.
- Note, the test-suite now has been extended to coverio_uringand idmapped mounts. TheIORING_REGISTER_PERSONALITYfeature allows to register the caller's credentials withio_uringand returns an id associated with these credentials. This is useful for applications that wish to share a ring between separate users/processes. Callers can pass in the credential id in the sqe personality field. If set, that particular sqe will be issued with these credentials. The test-suite now tests that the openat* operations with different registered credentials work correctly and safely on regular mounts, on regular mounts inside user namespaces, on idmapped mounts, and on idmapped mounts inside user namespaces./* v2 */
- The major change is the rework requested by Christoph and others to adapt all relevant helpers andinode_operationsmethods to account for idmapped mounts instead of introducing new helpers and methods specific to idmapped mounts like we did before. We've also moved the overlayfs conversion to handle idmapped mounts into a separate patchset that will be sent out separately after the core changes landed. The converted filesytems in this series include fat and ext4. As per Christoph's request the vfs-wide config option to disable idmapped mounts has been removed. Instead the filesystems can decide whether or not they want to allow idmap mounts through a config option. These config options default to off. Having a config option allows us to gain some confidence in the patchset over multiple kernel releases.
- This version introduces a large test-suite to test current vfs behavior and idmapped mounts behavior. This test-suite is intended to grow over time.
- While while working on adapting this patchset to the requested changes, the runC and containerd crowd was nice enough to adapt containerd to this patchset to make use of idmapped mounts in one of the most widely used container runtimes:
https://github.com/containerd/containerd/pull/4734The solution proposed here has it's origins in multiple discussions during Linux Plumbers 2017 during and after the end of the containers microconference.
To the best of my knowledge this involved Aleksa, Stéphane, Eric, David, James, and myself.The original idea or a variant thereof has been discussed, again to the best of my knowledge, after a Linux conference in St. Petersburg in Russia in 2017 between Christoph, Tycho, and myself.
We've taken the time to implement a working version of this solution over the last weeks to the best of my abilities. Tycho has signed up for this sligthly crazy endeavour as well and he has helped with the conversion of the xattr codepaths and will be involved with others in converting additional filesystems.Thanks!
ChristianChristian Brauner (39):
namespace: takelock_mount_hash()directly when changing flags
mount: make {lock,unlock}_mount_hash() static
namespace: only take read lock indo_reconfigure_mnt()
fs: split out functions to hold writers
fs: addattr_flags_to_mnt_flagshelper
fs: addmount_setattr()
tests: addmount_setattr()selftests
fs: add id translation helpers
mount: attach mappings to mounts
capability: handle idmapped mounts
namei: make permission helpers idmapped mount aware
inode: make init and permission helpers idmapped mount aware
attr: handle idmapped mounts
acl: handle idmapped mounts
fs: addfile_user_ns()helper
commoncap: handle idmapped mounts
stat: handle idmapped mounts
namei: handle idmapped mounts in may_*() helpers
namei: introduce struct renamedata
namei: prepare for idmapped mounts
open: handle idmapped mounts indo_truncate()
open: handle idmapped mounts
af_unix: handle idmapped mounts
utimes: handle idmapped mounts
fcntl: handle idmapped mounts
notify: handle idmapped mounts
init: handle idmapped mounts
ioctl: handle idmapped mounts
would_dump: handle idmapped mounts
exec: handle idmapped mounts
fs: make helpers idmap mount aware
apparmor: handle idmapped mounts
ima: handle idmapped mounts
fat: handle idmapped mounts
ext4: support idmapped mounts
ecryptfs: do not mount on top of idmapped mounts
overlayfs: do not mount on top of idmapped mounts
fs: introduceMOUNT_ATTR_IDMAP
tests: extendmount_setattrtestsChristoph Hellwig (1):
xfs: support idmapped mountsTycho Andersen (1):
xattr: handle idmapped mountsDocumentation/filesystems/locking.rst | 6 +- Documentation/filesystems/porting.rst | 2 + Documentation/filesystems/vfs.rst | 19 +- arch/alpha/kernel/syscalls/syscall.tbl | 1 + arch/arm/tools/syscall.tbl | 1 + arch/arm64/include/asm/unistd32.h | 2 + arch/ia64/kernel/syscalls/syscall.tbl | 1 + arch/m68k/kernel/syscalls/syscall.tbl | 1 + arch/microblaze/kernel/syscalls/syscall.tbl | 1 + arch/mips/kernel/syscalls/syscall_n32.tbl | 1 + arch/mips/kernel/syscalls/syscall_n64.tbl | 1 + arch/mips/kernel/syscalls/syscall_o32.tbl | 1 + arch/parisc/kernel/syscalls/syscall.tbl | 1 + arch/powerpc/kernel/syscalls/syscall.tbl | 1 + arch/powerpc/platforms/cell/spufs/inode.c | 5 +- arch/s390/kernel/syscalls/syscall.tbl | 1 + arch/sh/kernel/syscalls/syscall.tbl | 1 + arch/sparc/kernel/syscalls/syscall.tbl | 1 + arch/x86/entry/syscalls/syscall_32.tbl | 1 + arch/x86/entry/syscalls/syscall_64.tbl | 1 + arch/xtensa/kernel/syscalls/syscall.tbl | 1 + drivers/android/binderfs.c | 6 +- drivers/base/devtmpfs.c | 12 +- fs/9p/acl.c | 8 +- fs/9p/v9fs.h | 3 +- fs/9p/v9fs_vfs.h | 2 +- fs/9p/vfs_inode.c | 36 +- fs/9p/vfs_inode_dotl.c | 39 +- fs/9p/xattr.c | 1 + fs/adfs/adfs.h | 3 +- fs/adfs/inode.c | 5 +- fs/affs/affs.h | 10 +- fs/affs/inode.c | 7 +- fs/affs/namei.c | 15 +- fs/afs/dir.c | 34 +- fs/afs/inode.c | 9 +- fs/afs/internal.h | 7 +- fs/afs/security.c | 2 +- fs/afs/xattr.c | 2 + fs/attr.c | 124 +- fs/autofs/root.c | 13 +- fs/bad_inode.c | 36 +- fs/bfs/dir.c | 12 +- fs/btrfs/acl.c | 5 +- fs/btrfs/ctree.h | 3 +- fs/btrfs/inode.c | 45 +- fs/btrfs/ioctl.c | 25 +- fs/btrfs/tests/btrfs-tests.c | 2 +- fs/btrfs/xattr.c | 2 + fs/cachefiles/interface.c | 4 +- fs/cachefiles/namei.c | 19 +- fs/cachefiles/xattr.c | 16 +- fs/ceph/acl.c | 5 +- fs/ceph/dir.c | 23 +- fs/ceph/inode.c | 17 +- fs/ceph/super.h | 12 +- fs/ceph/xattr.c | 1 + fs/cifs/cifsfs.c | 4 +- fs/cifs/cifsfs.h | 21 +- fs/cifs/dir.c | 8 +- fs/cifs/inode.c | 26 +- fs/cifs/link.c | 3 +- fs/cifs/xattr.c | 1 + fs/coda/coda_linux.h | 6 +- fs/coda/dir.c | 17 +- fs/coda/inode.c | 9 +- fs/coda/pioctl.c | 6 +- fs/configfs/configfs_internal.h | 7 +- fs/configfs/dir.c | 3 +- fs/configfs/inode.c | 5 +- fs/configfs/symlink.c | 5 +- fs/coredump.c | 14 +- fs/crypto/policy.c | 2 +- fs/debugfs/inode.c | 9 +- fs/ecryptfs/crypto.c | 4 +- fs/ecryptfs/inode.c | 80 +- fs/ecryptfs/main.c | 6 + fs/ecryptfs/mmap.c | 4 +- fs/efivarfs/file.c | 2 +- fs/efivarfs/inode.c | 4 +- fs/erofs/inode.c | 7 +- fs/erofs/internal.h | 5 +- fs/exec.c | 12 +- fs/exfat/exfat_fs.h | 8 +- fs/exfat/file.c | 14 +- fs/exfat/namei.c | 14 +- fs/ext2/acl.c | 5 +- fs/ext2/acl.h | 3 +- fs/ext2/ext2.h | 5 +- fs/ext2/ialloc.c | 2 +- fs/ext2/inode.c | 15 +- fs/ext2/ioctl.c | 6 +- fs/ext2/namei.c | 22 +- fs/ext2/xattr_security.c | 1 + fs/ext2/xattr_trusted.c | 1 + fs/ext2/xattr_user.c | 1 + fs/ext4/acl.c | 5 +- fs/ext4/acl.h | 3 +- fs/ext4/ext4.h | 21 +- fs/ext4/ialloc.c | 7 +- fs/ext4/inode.c | 21 +- fs/ext4/ioctl.c | 19 +- fs/ext4/namei.c | 49 +- fs/ext4/super.c | 2 +- fs/ext4/xattr_hurd.c | 1 + fs/ext4/xattr_security.c | 1 + fs/ext4/xattr_trusted.c | 1 + fs/ext4/xattr_user.c | 1 + fs/f2fs/acl.c | 5 +- fs/f2fs/acl.h | 3 +- fs/f2fs/f2fs.h | 7 +- fs/f2fs/file.c | 35 +- fs/f2fs/namei.c | 23 +- fs/f2fs/xattr.c | 4 +- fs/fat/fat.h | 6 +- fs/fat/file.c | 24 +- fs/fat/namei_msdos.c | 12 +- fs/fat/namei_vfat.c | 15 +- fs/fcntl.c | 3 +- fs/fuse/acl.c | 3 +- fs/fuse/dir.c | 45 +- fs/fuse/fuse_i.h | 4 +- fs/fuse/xattr.c | 2 + fs/gfs2/acl.c | 5 +- fs/gfs2/acl.h | 3 +- fs/gfs2/file.c | 4 +- fs/gfs2/inode.c | 59 +- fs/gfs2/inode.h | 3 +- fs/gfs2/xattr.c | 1 + fs/hfs/attr.c | 1 + fs/hfs/dir.c | 13 +- fs/hfs/hfs_fs.h | 2 +- fs/hfs/inode.c | 7 +- fs/hfsplus/dir.c | 25 +- fs/hfsplus/hfsplus_fs.h | 5 +- fs/hfsplus/inode.c | 16 +- fs/hfsplus/ioctl.c | 2 +- fs/hfsplus/xattr.c | 1 + fs/hfsplus/xattr_security.c | 1 + fs/hfsplus/xattr_trusted.c | 1 + fs/hfsplus/xattr_user.c | 1 + fs/hostfs/hostfs_kern.c | 29 +- fs/hpfs/hpfs_fn.h | 2 +- fs/hpfs/inode.c | 7 +- fs/hpfs/namei.c | 20 +- fs/hugetlbfs/inode.c | 31 +- fs/init.c | 27 +- fs/inode.c | 50 +- fs/internal.h | 2 +- fs/jffs2/acl.c | 5 +- fs/jffs2/acl.h | 3 +- fs/jffs2/dir.c | 32 +- fs/jffs2/fs.c | 7 +- fs/jffs2/os-linux.h | 2 +- fs/jffs2/security.c | 1 + fs/jffs2/xattr_trusted.c | 1 + fs/jffs2/xattr_user.c | 1 + fs/jfs/acl.c | 5 +- fs/jfs/file.c | 9 +- fs/jfs/ioctl.c | 2 +- fs/jfs/jfs_acl.h | 3 +- fs/jfs/jfs_inode.c | 2 +- fs/jfs/jfs_inode.h | 2 +- fs/jfs/namei.c | 21 +- fs/jfs/xattr.c | 2 + fs/kernfs/dir.c | 7 +- fs/kernfs/inode.c | 19 +- fs/kernfs/kernfs-internal.h | 9 +- fs/libfs.c | 28 +- fs/minix/bitmap.c | 2 +- fs/minix/file.c | 7 +- fs/minix/inode.c | 6 +- fs/minix/minix.h | 3 +- fs/minix/namei.c | 24 +- fs/mount.h | 10 - fs/namei.c | 513 ++++-- fs/namespace.c | 484 +++++- fs/nfs/dir.c | 25 +- fs/nfs/inode.c | 9 +- fs/nfs/internal.h | 10 +- fs/nfs/namespace.c | 14 +- fs/nfs/nfs3_fs.h | 3 +- fs/nfs/nfs3acl.c | 3 +- fs/nfs/nfs4proc.c | 3 + fs/nfsd/nfs2acl.c | 4 +- fs/nfsd/nfs3acl.c | 4 +- fs/nfsd/nfs4acl.c | 4 +- fs/nfsd/nfs4recover.c | 6 +- fs/nfsd/nfsfh.c | 2 +- fs/nfsd/nfsproc.c | 2 +- fs/nfsd/vfs.c | 47 +- fs/nilfs2/inode.c | 13 +- fs/nilfs2/ioctl.c | 2 +- fs/nilfs2/namei.c | 19 +- fs/nilfs2/nilfs.h | 4 +- fs/notify/fanotify/fanotify_user.c | 2 +- fs/notify/inotify/inotify_user.c | 3 +- fs/ntfs/inode.c | 6 +- fs/ntfs/inode.h | 3 +- fs/ocfs2/acl.c | 5 +- fs/ocfs2/acl.h | 3 +- fs/ocfs2/dlmfs/dlmfs.c | 17 +- fs/ocfs2/file.c | 17 +- fs/ocfs2/file.h | 11 +- fs/ocfs2/ioctl.c | 2 +- fs/ocfs2/namei.c | 21 +- fs/ocfs2/refcounttree.c | 4 +- fs/ocfs2/xattr.c | 3 + fs/omfs/dir.c | 13 +- fs/omfs/file.c | 7 +- fs/omfs/inode.c | 2 +- fs/open.c | 50 +- fs/orangefs/acl.c | 5 +- fs/orangefs/inode.c | 20 +- fs/orangefs/namei.c | 12 +- fs/orangefs/orangefs-kernel.h | 13 +- fs/orangefs/xattr.c | 1 + fs/overlayfs/copy_up.c | 20 +- fs/overlayfs/dir.c | 31 +- fs/overlayfs/file.c | 6 +- fs/overlayfs/inode.c | 26 +- fs/overlayfs/overlayfs.h | 44 +- fs/overlayfs/super.c | 19 +- fs/overlayfs/util.c | 4 +- fs/posix_acl.c | 101 +- fs/proc/base.c | 28 +- fs/proc/fd.c | 5 +- fs/proc/fd.h | 3 +- fs/proc/generic.c | 12 +- fs/proc/internal.h | 5 +- fs/proc/proc_net.c | 5 +- fs/proc/proc_sysctl.c | 15 +- fs/proc/root.c | 5 +- fs/proc_namespace.c | 3 + fs/ramfs/file-nommu.c | 9 +- fs/ramfs/inode.c | 18 +- fs/reiserfs/acl.h | 3 +- fs/reiserfs/inode.c | 7 +- fs/reiserfs/ioctl.c | 4 +- fs/reiserfs/namei.c | 21 +- fs/reiserfs/reiserfs.h | 3 +- fs/reiserfs/xattr.c | 12 +- fs/reiserfs/xattr.h | 3 +- fs/reiserfs/xattr_acl.c | 7 +- fs/reiserfs/xattr_security.c | 3 +- fs/reiserfs/xattr_trusted.c | 3 +- fs/reiserfs/xattr_user.c | 3 +- fs/remap_range.c | 7 +- fs/stat.c | 26 +- fs/sysv/file.c | 7 +- fs/sysv/ialloc.c | 2 +- fs/sysv/itree.c | 6 +- fs/sysv/namei.c | 21 +- fs/sysv/sysv.h | 3 +- fs/tracefs/inode.c | 4 +- fs/ubifs/dir.c | 30 +- fs/ubifs/file.c | 5 +- fs/ubifs/ioctl.c | 2 +- fs/ubifs/ubifs.h | 5 +- fs/ubifs/xattr.c | 1 + fs/udf/file.c | 9 +- fs/udf/ialloc.c | 2 +- fs/udf/namei.c | 24 +- fs/udf/symlink.c | 7 +- fs/ufs/ialloc.c | 2 +- fs/ufs/inode.c | 7 +- fs/ufs/namei.c | 19 +- fs/ufs/ufs.h | 3 +- fs/utimes.c | 4 +- fs/vboxsf/dir.c | 12 +- fs/vboxsf/utils.c | 9 +- fs/vboxsf/vfsmod.h | 8 +- fs/verity/enable.c | 2 +- fs/xattr.c | 136 +- fs/xfs/xfs_acl.c | 5 +- fs/xfs/xfs_acl.h | 3 +- fs/xfs/xfs_file.c | 4 +- fs/xfs/xfs_inode.c | 26 +- fs/xfs/xfs_inode.h | 16 +- fs/xfs/xfs_ioctl.c | 23 +- fs/xfs/xfs_iops.c | 98 +- fs/xfs/xfs_iops.h | 3 +- fs/xfs/xfs_qm.c | 3 +- fs/xfs/xfs_super.c | 2 +- fs/xfs/xfs_symlink.c | 5 +- fs/xfs/xfs_symlink.h | 5 +- fs/xfs/xfs_xattr.c | 3 +- fs/zonefs/super.c | 9 +- include/linux/capability.h | 15 +- include/linux/fs.h | 158 +- include/linux/ima.h | 17 +- include/linux/lsm_hook_defs.h | 15 +- include/linux/lsm_hooks.h | 1 + include/linux/mount.h | 7 + include/linux/nfs_fs.h | 7 +- include/linux/posix_acl.h | 15 +- include/linux/posix_acl_xattr.h | 12 +- include/linux/security.h | 46 +- include/linux/syscalls.h | 4 + include/linux/xattr.h | 30 +- include/uapi/asm-generic/unistd.h | 4 +- include/uapi/linux/mount.h | 17 + ipc/mqueue.c | 8 +- kernel/auditsc.c | 5 +- kernel/bpf/inode.c | 13 +- kernel/capability.c | 14 +- kernel/cgroup/cgroup.c | 2 +- kernel/sys.c | 2 +- mm/madvise.c | 4 +- mm/memcontrol.c | 2 +- mm/mincore.c | 4 +- mm/shmem.c | 48 +- net/socket.c | 6 +- net/unix/af_unix.c | 4 +- security/apparmor/apparmorfs.c | 3 +- security/apparmor/domain.c | 13 +- security/apparmor/file.c | 5 +- security/apparmor/lsm.c | 12 +- security/commoncap.c | 109 +- security/integrity/evm/evm_crypto.c | 11 +- security/integrity/evm/evm_main.c | 4 +- security/integrity/evm/evm_secfs.c | 2 +- security/integrity/ima/ima.h | 19 +- security/integrity/ima/ima_api.c | 10 +- security/integrity/ima/ima_appraise.c | 22 +- security/integrity/ima/ima_asymmetric_keys.c | 2 +- security/integrity/ima/ima_main.c | 31 +- security/integrity/ima/ima_policy.c | 19 +- security/integrity/ima/ima_queue_keys.c | 2 +- security/security.c | 25 +- security/selinux/hooks.c | 22 +- security/smack/smack_lsm.c | 18 +- tools/include/uapi/asm-generic/unistd.h | 4 +- tools/testing/selftests/Makefile | 1 + .../selftests/mount_setattr/.gitignore | 1 + .../testing/selftests/mount_setattr/Makefile | 7 + tools/testing/selftests/mount_setattr/config | 1 + .../mount_setattr/mount_setattr_test.c | 1424 +++++++++++++++++ 338 files changed, 4718 insertions(+), 1731 deletions(-) create mode 100644 tools/testing/selftests/mount_setattr/.gitignore create mode 100644 tools/testing/selftests/mount_setattr/Makefile create mode 100644 tools/testing/selftests/mount_setattr/config create mode 100644 tools/testing/selftests/mount_setattr/mount_setattr_test.c
Quoted 4 lines
base-commit:
7c53f6b671f4aba70ff15e1b05148b10d58c2837Signature · 1 line
2.30.0
_______________________________________________
Containers mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/containers
Quoted 34 lines · Darrick J. Wong
Quoted 4 lines · Christian Brauner
Hey everyone,
The only major change is the inclusion of hch's patch to port XFS to support idmapped mounts. Thanks to Christoph for doing that work.
Yay :)
Quoted 17 lines
(For a full list of major changes between versions see the end of this
cover letter.
Please also note the large xfstests testsuite in patch 42 that has been kept as part of this series. It verifies correct vfs behavior with and without idmapped mounts including covering newer vfs features such asio_uring.
I currently still plan to target the v5.12 merge window.)With this patchset we make it possible to attach idmappings to mounts, i.e. simply put different bind mounts can expose the same file or directory with different ownership.
Shifting of ownership on a per-mount basis handles a wide range of long standing use-cases. Here are just a few:
- Shifting of a subset of ownership-less filesystems (vfat) for use by multiple users, effectively allowing for DAC on such devices (systemd, Android, ...)
- Allow remapping uid/gid on external filesystems or paths (USB sticks,Quoted 8 lines
network filesystem, ...) to match the local system's user and groups. (David Howells intends to port AFS as a first candidate.)
- Shifting of a container rootfs or base image without having to mangle every file (runc, Docker, containerd, k8s, LXD, systemd ...)
- Sharing of data between host or privileged containers with unprivileged containers (runC, Docker, containerd, k8s, LXD, ...)
- Data sharing between multiple user namespaces with incompatible maps (LXD, k8s, ...)
Quoted 4 lines
That sounds neat. AFAICT, the VFS passes the filesystem a mount userns structure, which is then carried down the call stack to whatever functions actually care about mapping kernel [ug]ids to their ondisk versions?
Yes. This requires not too many changes to the actual filesystems as you can see from the xfs conversion that Christoph has done.
Quoted 4 lines
Does quota still work after this patchset is applied? There isn't any mention of that in the cover letter and I don't see a code patch, so does that mean everything just works? I'm particularly curious about
The most interesting quota codepaths I audited are dquot_transfer that transfers quota from one inode to another one during setattr. That happens via a struct iattr which will already contain correctly translated ia_uid and ia_gid values according to the mount the caller is coming from. I'll take another close look at that now and add tests for that if I can find some in xfstests.
Quoted 2 lines
whether there can exist processes with
CAP_SYS_ADMINand an idmapped mount? Syscalls like bulkstat and quotactl present file [ug]ids to
Yes, that should be possible.
Quoted 1 line
programs, but afaict there won't be any translating going on?
quotactl operates on the superblock. So the caller would need a mapping in the user namespace of the superblock. That doesn't need to change. But we could in the future extend this to be on a per-mount basis if this was a desired use-case. I don't think it needs to happen right now though.
Quoted 2 lines
(To be fair, bulkstat is an xfs-only thing, but quota control isn't.)
I'm certain we'll find more things to cover after the first version has landed. :)
We for sure won't cover it all in the first iteration.
Quoted 2 lines
I'll start skimming the patchset...
Thanks!
Christian
_______________________________________________
Containers mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/containers
Quoted 39 lines · Darrick J. Wong
Quoted 4 lines · Christian Brauner
Hey everyone,
The only major change is the inclusion of hch's patch to port XFS to support idmapped mounts. Thanks to Christoph for doing that work.
Yay :)
Quoted 17 lines
(For a full list of major changes between versions see the end of this
cover letter.
Please also note the large xfstests testsuite in patch 42 that has been kept as part of this series. It verifies correct vfs behavior with and without idmapped mounts including covering newer vfs features such asio_uring.
I currently still plan to target the v5.12 merge window.)With this patchset we make it possible to attach idmappings to mounts, i.e. simply put different bind mounts can expose the same file or directory with different ownership.
Shifting of ownership on a per-mount basis handles a wide range of long standing use-cases. Here are just a few:
- Shifting of a subset of ownership-less filesystems (vfat) for use by multiple users, effectively allowing for DAC on such devices (systemd, Android, ...)
- Allow remapping uid/gid on external filesystems or paths (USB sticks,Quoted 8 lines
network filesystem, ...) to match the local system's user and groups. (David Howells intends to port AFS as a first candidate.)
- Shifting of a container rootfs or base image without having to mangle every file (runc, Docker, containerd, k8s, LXD, systemd ...)
- Sharing of data between host or privileged containers with unprivileged containers (runC, Docker, containerd, k8s, LXD, ...)
- Data sharing between multiple user namespaces with incompatible maps (LXD, k8s, ...)That sounds neat. AFAICT, the VFS passes the filesystem a mount userns structure, which is then carried down the call stack to whatever functions actually care about mapping kernel [ug]ids to their ondisk versions?
Quoted 6 lines
Does quota still work after this patchset is applied? There isn't any mention of that in the cover letter and I don't see a code patch, so does that mean everything just works? I'm particularly curious about whether there can exist processes with
CAP_SYS_ADMINand an idmapped mount? Syscalls like bulkstat and quotactl present file [ug]ids to programs, but afaict there won't be any translating going on?
bulkstat is not allowed inside user namespaces. It's an init namespace only thing because it provides unchecked/unbounded access to all inodes in the filesystem, not just those contained within a specific mount container.
Hence I don't think bulkstat output (and other initns+root only filesystem introspection APIs) should be subject to or concerned about idmapping.
Cheers,
Dave.
Signature · 6 lines
Dave Chinner [email protected] _______________________________________________ Containers mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/containers
Quoted 12 lines · Dave Chinner
Quoted 11 lines
That sounds neat. AFAICT, the VFS passes the filesystem a mount userns structure, which is then carried down the call stack to whatever functions actually care about mapping kernel [ug]ids to their ondisk versions?
Does quota still work after this patchset is applied? There isn't any mention of that in the cover letter and I don't see a code patch, so does that mean everything just works? I'm particularly curious about whether there can exist processes with
CAP_SYS_ADMINand an idmapped mount? Syscalls like bulkstat and quotactl present file [ug]ids to programs, but afaict there won't be any translating going on?
Quoted 8 lines
bulkstat is not allowed inside user namespaces. It's an init namespace only thing because it provides unchecked/unbounded access to all inodes in the filesystem, not just those contained within a specific mount container.
Hence I don't think bulkstat output (and other initns+root only filesystem introspection APIs) should be subject to or concerned about idmapping.
That is what the capabilities are designed for and we already check for them.
Theodore Ts'o
maintainerQuoted 3 lines · Christoph Hellwig
That is what the capabilities are designed for and we already check for them.
So perhaps I'm confused, but my understanding is that in the containers world, capabilities are a lot more complicated. There is:
1) The initial namespace capability set
2) The container's user-namespace capability set
3) The namespace in which the file system is mounted --- which is "usually, but not necessarily the initial namespace" and presumably could potentially not necessarily be the current container's user name space, is namespaces can be hierarchically arranged.
Is that correct? If so, how does this patch set change things (if any), and and how does this interact with quota administration operations?
On a related note, ext4 specifies a "reserved user" or "reserved group" which can access the reserved blocks. If we have a file system which is mounted in a namespace running a container which is running RHEL or SLES, and in that container, we have a file system mounted (so it was not mounted in the initial namespace), with id-mapping --- and then there is a further sub-container created with its own user sub-namespace further mapping uids/gids --- will the right thing happen? For that matter, how *is* the "right thing" defined?
Sorry if this is a potentially stupid question, but I find user namespaces and id and capability mapping to be hopefully confusing for my tiny brain. :-)
- Ted
_______________________________________________
Containers mailing list [email protected]
https://lists.linuxfoundation.org/mailman/listinfo/containers
Quoted 18 lines · Theodore Ts'o
Quoted 3 lines · Christoph Hellwig
That is what the capabilities are designed for and we already check for them.
So perhaps I'm confused, but my understanding is that in the containers world, capabilities are a lot more complicated. There is:
1) The initial namespace capability set
2) The container's user-namespace capability set
3) The namespace in which the file system is mounted --- which is "usually, but not necessarily the initial namespace" and presumably could potentially not necessarily be the current container's user name space, is namespaces can be hierarchically arranged.
Quoted 3 lines
Is that correct? If so, how does this patch set change things (if any), and and how does this interact with quota administration operations?
The cases you listed are correct. The patchset doesn't change them. Simply put, the patchset doesn't alter capability checking in any way.
Quoted 9 lines
On a related note, ext4 specifies a "reserved user" or "reserved group" which can access the reserved blocks. If we have a file system which is mounted in a namespace running a container which is running RHEL or SLES, and in that container, we have a file system mounted (so it was not mounted in the initial namespace), with id-mapping --- and then there is a further sub-container created with its own user sub-namespace further mapping uids/gids --- will the right thing happen? For that matter, how *is* the "right thing" defined?
In short, nothing changes. Whatever happened before happens now.
Specifically s_resuid/s_resgid are superblock mount options and so never change on a per-mount basis and thus also aren't affected by idmapped mounts.
Quoted 4 lines
Sorry if this is a potentially stupid question, but I find user namespaces and id and capability mapping to be hopefully confusing for my tiny brain. :-)
No, I really appreciate the questions. :) My brain can most likely handle less. :)
Christian