fs: port to const struct mnt_idmap
Subsystems (74)
Re: [PATCH 24/27] fs: port ->setattr() to pass const mnt_idmap
In reply to Christian BraunerQuoted 8 lines · Christian Brauner
Convert to const struct
mnt_idmap.A mount's idmapping is immutable. The only thing that is allowed to be modified afterwards is the reference count and that is hidden behind
mnt_idmap_get()andmnt_idmap_put(). Everything else only ever reads from the idmapping. This is the same model that struct cred uses and the idmapping is also rather sensitive.
Quoted 7 lines
So make the idmap argument const wherever we can. The conversion is done from the bottom up so callers can continue to pass a non-const pointer to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by Christian Brauner (Amutable) <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 1,513 lines
--- Documentation/filesystems/locking.rst | 2 +- Documentation/filesystems/vfs.rst | 2 +- arch/powerpc/platforms/cell/spufs/inode.c | 2 +- fs/9p/v9fs_vfs.h | 2 +- fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 2 +- fs/adfs/adfs.h | 2 +- fs/adfs/inode.c | 2 +- fs/affs/affs.h | 2 +- fs/affs/inode.c | 2 +- fs/afs/inode.c | 2 +- fs/afs/internal.h | 2 +- fs/anon_inodes.c | 2 +- fs/attr.c | 2 +- fs/bad_inode.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/inode.c | 2 +- fs/ceph/super.h | 2 +- fs/coda/coda_linux.h | 2 +- fs/coda/inode.c | 2 +- fs/configfs/configfs_internal.h | 2 +- fs/configfs/inode.c | 2 +- fs/debugfs/inode.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/efivarfs/inode.c | 2 +- fs/exfat/exfat_fs.h | 2 +- fs/exfat/file.c | 2 +- fs/ext2/ext2.h | 2 +- fs/ext2/inode.c | 2 +- fs/ext4/ext4.h | 2 +- fs/ext4/inode.c | 2 +- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 2 +- fs/fat/fat.h | 2 +- fs/fat/file.c | 2 +- fs/fuse/dir.c | 2 +- fs/gfs2/inode.c | 2 +- fs/hfs/hfs_fs.h | 2 +- fs/hfs/inode.c | 2 +- fs/hfsplus/inode.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/hpfs_fn.h | 2 +- fs/hpfs/inode.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/inode.c | 2 +- fs/internal.h | 2 +- fs/jffs2/fs.c | 2 +- fs/jffs2/os-linux.h | 2 +- fs/jfs/file.c | 2 +- fs/jfs/jfs_inode.h | 2 +- fs/kernfs/inode.c | 2 +- fs/kernfs/kernfs-internal.h | 2 +- fs/libfs.c | 4 ++-- fs/minix/file.c | 2 +- fs/nfs/inode.c | 2 +- fs/nfs/namespace.c | 2 +- fs/nilfs2/inode.c | 2 +- fs/nilfs2/nilfs.h | 2 +- fs/ntfs/file.c | 2 +- fs/ntfs/inode.h | 2 +- fs/ntfs3/file.c | 2 +- fs/ntfs3/ntfs_fs.h | 2 +- fs/ocfs2/dlmfs/dlmfs.c | 2 +- fs/ocfs2/file.c | 2 +- fs/ocfs2/file.h | 2 +- fs/omfs/file.c | 2 +- fs/orangefs/inode.c | 2 +- fs/orangefs/orangefs-kernel.h | 2 +- fs/overlayfs/inode.c | 2 +- fs/overlayfs/overlayfs.h | 2 +- fs/pidfs.c | 2 +- fs/proc/base.c | 2 +- fs/proc/generic.c | 2 +- fs/proc/internal.h | 2 +- fs/proc/proc_sysctl.c | 2 +- fs/ramfs/file-nommu.c | 4 ++-- fs/smb/client/cifsfs.h | 2 +- fs/smb/client/inode.c | 2 +- fs/tracefs/event_inode.c | 2 +- fs/tracefs/inode.c | 2 +- fs/ubifs/file.c | 2 +- fs/ubifs/ubifs.h | 2 +- fs/udf/file.c | 2 +- fs/ufs/inode.c | 2 +- fs/ufs/ufs.h | 2 +- fs/vboxsf/utils.c | 2 +- fs/vboxsf/vfsmod.h | 2 +- fs/xfs/xfs_iops.c | 2 +- fs/zonefs/super.c | 2 +- include/linux/fs.h | 6 +++--- include/linux/lsm_hook_defs.h | 4 ++-- include/linux/nfs_fs.h | 2 +- include/linux/security.h | 8 ++++---- mm/secretmem.c | 2 +- mm/shmem.c | 2 +- net/socket.c | 2 +- security/integrity/evm/evm_main.c | 4 ++-- security/integrity/ima/ima_appraise.c | 2 +- security/security.c | 4 ++-- security/selinux/hooks.c | 2 +- security/smack/smack_lsm.c | 2 +- virt/kvm/guest_memfd.c | 2 +- 102 files changed, 112 insertions(+), 112 deletions(-)Documentation/filesystems/locking.rst +1
-1@@ -76,7 +76,7 @@ prototypes:: void (*truncate) (struct inode *); int (*permission) (const struct mnt_idmap *, struct inode *, int, unsigned int); struct posix_acl * (*get_inode_acl)(struct inode *, int, bool); - int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *); + int (*setattr) (const struct mnt_idmap *, struct dentry *, struct iattr *); int (*getattr) (const struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int); ssize_t (*listxattr) (struct dentry *, char *, size_t); int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);Documentation/filesystems/vfs.rst +1
-1@@ -430,7 +430,7 @@ As of kernel 2.6.22, the following members are defined: struct delayed_call *); int (*permission) (const struct mnt_idmap *, struct inode *, int); struct posix_acl * (*get_inode_acl)(struct inode *, int, bool); - int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *); + int (*setattr) (const struct mnt_idmap *, struct dentry *, struct iattr *); int (*getattr) (const struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int); ssize_t (*listxattr) (struct dentry *, char *, size_t); void (*update_time)(struct inode *inode, enum fs_update_time type,arch/powerpc/platforms/cell/spufs/inode.c +1
-1@@ -92,7 +92,7 @@ spufs_new_inode(struct super_block *sb, umode_t mode) }static int -spufs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +spufs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/9p/v9fs_vfs.h +1
-1@@ -74,7 +74,7 @@ int v9fs_file_open(struct inode *inode, struct file *file);int v9fs_uflags2omode (int uflags,int extended);void v9fs_blank_wstat (struct p9_wstat *wstat); -int v9fs_vfs_setattr_dotl (struct mnt_idmap *idmap, +int v9fs_vfs_setattr_dotl (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr);int v9fs_file_fsync_dotl (struct file *filp,loff_t start,loff_t end,int datasync);fs/9p/vfs_inode.c +1
-1@@ -1014,7 +1014,7 @@ v9fs_vfs_getattr(const struct mnt_idmap *idmap, const struct path *path,* */ -static int v9fs_vfs_setattr (struct mnt_idmap *idmap, +static int v9fs_vfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {int retval, use_dentry =0 ;fs/9p/vfs_inode_dotl.c +1
-1@@ -508,7 +508,7 @@ static int v9fs_mapped_iattr_valid(int iattr_valid)* */ -int v9fs_vfs_setattr_dotl (struct mnt_idmap *idmap, +int v9fs_vfs_setattr_dotl (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {int retval, use_dentry =0 ;fs/adfs/adfs.h +1
-1@@ -144,7 +144,7 @@ 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_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int adfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr);/* map.c */ fs/adfs/inode.c +1
-1@@ -299,7 +299,7 @@ adfs_iget(struct super_block *sb, struct object_info *obj)* later. */ int -adfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) +adfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);struct super_block *sb = inode->i_sb;fs/affs/affs.h +1
-1@@ -184,7 +184,7 @@ extern int affs_rename2(const struct mnt_idmap *idmap,/* inode.c */ extern struct inode *affs_new_inode (struct inode *dir); -extern int affs_setattr (struct mnt_idmap *idmap, +extern int affs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr);extern void affs_evict_inode (struct inode *inode); extern struct inode *affs_iget(struct super_block *sb,fs/affs/inode.c +1
-1@@ -213,7 +213,7 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc) }int -affs_setattr (struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) +affs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);int error;fs/afs/inode.c +1
-1@@ -759,7 +759,7 @@ static const struct afs_operation_ops afs_setattr_operation = {/* * set the attributes of an inode */ -int afs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int afs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) { const unsigned int supported =fs/afs/internal.h +1
-1@@ -1260,7 +1260,7 @@ extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);extern struct inode *afs_root_iget (struct super_block *,struct key *);extern int afs_getattr (const struct mnt_idmap *idmap,const struct path *,struct kstat *,u32 ,unsigned int ); -extern int afs_setattr (struct mnt_idmap *idmap,struct dentry *,struct iattr *); +extern int afs_setattr (const struct mnt_idmap *idmap,struct dentry *,struct iattr *);extern void afs_evict_inode (struct inode *);extern int afs_drop_inode (struct inode *);fs/anon_inodes.c +1
-1@@ -57,7 +57,7 @@ int anon_inode_getattr(const struct mnt_idmap *idmap, const struct path *path,return 0 ; } -int anon_inode_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int anon_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {return -EOPNOTSUPP ;fs/attr.c +1
-1@@ -424,7 +424,7 @@ EXPORT_SYMBOL(may_setattr);* permissions. On non-idmapped mounts or if permission checking is to be * performed on the raw inode simply pass @nop_mnt_idmap. */ -int notify_change (struct mnt_idmap *idmap,struct dentry *dentry, +int notify_change (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr,struct delegated_inode *delegated_inode) {struct inode *inode = dentry->d_inode;fs/bad_inode.c +1
-1@@ -102,7 +102,7 @@ static int bad_inode_getattr(const struct mnt_idmap *idmap,return -EIO ; } -static int bad_inode_setattr (struct mnt_idmap *idmap, +static int bad_inode_setattr (const struct mnt_idmap *idmap,struct dentry *direntry,struct iattr *attrs) {return -EIO ;fs/btrfs/inode.c +1
-1@@ -5479,7 +5479,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)return ret; } -static int btrfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +static int btrfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/ceph/inode.c +1
-1@@ -2921,7 +2921,7 @@ int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,/* * setattr */ -int ceph_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ceph_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/ceph/super.h +1
-1@@ -1175,7 +1175,7 @@ struct ceph_iattr {extern int __ceph_setattr (const struct mnt_idmap *idmap,struct inode *inode,struct iattr *attr,struct ceph_iattr *cia); -extern int ceph_setattr (struct mnt_idmap *idmap, +extern int ceph_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr); extern int ceph_getattr(const struct mnt_idmap *idmap, const struct path *path, struct kstat *stat,fs/coda/coda_linux.h +1
-1@@ -51,7 +51,7 @@ int coda_permission(const struct mnt_idmap *idmap, struct inode *inode,int coda_revalidate_inode (struct inode *);int coda_getattr (const struct mnt_idmap *,const struct path *,struct kstat *,u32 ,unsigned int ); -int coda_setattr (struct mnt_idmap *,struct dentry *,struct iattr *); +int coda_setattr (const struct mnt_idmap *,struct dentry *,struct iattr *);/* this file: helpers */ char *coda_f2s (struct CodaFid *f);fs/coda/inode.c +1
-1@@ -304,7 +304,7 @@ int coda_getattr(const struct mnt_idmap *idmap, const struct path *path,return err; } -int coda_setattr (struct mnt_idmap *idmap,struct dentry *de, +int coda_setattr (const struct mnt_idmap *idmap,struct dentry *de,struct iattr *iattr) {struct inode *inode =d_inode (de);fs/configfs/configfs_internal.h +1
-1@@ -76,7 +76,7 @@ extern int configfs_make_dirent(struct configfs_dirent *, struct dentry *,extern int configfs_dirent_is_ready (struct configfs_dirent *);extern const unsigned char *configfs_get_name (struct configfs_dirent *sd); -extern int configfs_setattr (struct mnt_idmap *idmap, +extern int configfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr);extern struct dentry *configfs_pin_fs (void );fs/configfs/inode.c +1
-1@@ -32,7 +32,7 @@ static const struct inode_operations configfs_inode_operations ={ .setattr = configfs_setattr, }; -int configfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int configfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct inode * inode =d_inode (dentry);fs/debugfs/inode.c +1
-1@@ -42,7 +42,7 @@ static bool debugfs_enabled __ro_after_init = IS_ENABLED(CONFIG_DEBUG_FS_ALLOW_A* 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 mnt_idmap *idmap, +static int debugfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *ia) {int ret;fs/ecryptfs/inode.c +1
-1@@ -869,7 +869,7 @@ ecryptfs_permission(const struct mnt_idmap *idmap, struct inode *inode,* 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 mnt_idmap *idmap, +static int ecryptfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *ia) {struct inode *inode =d_inode (dentry);fs/efivarfs/inode.c +1
-1@@ -170,7 +170,7 @@ efivarfs_fileattr_set(const struct mnt_idmap *idmap, }/* copy of simple_setattr except that it doesn't do i_size updates */ -static int efivarfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +static int efivarfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct inode *inode =d_inode (dentry);fs/exfat/exfat_fs.h +1
-1@@ -555,7 +555,7 @@ int exfat_trim_fs(struct inode *inode, struct fstrim_range *range);/* file.c */ extern const struct file_operations exfat_file_operations;int __exfat_truncate (struct inode *inode); -int exfat_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int exfat_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr); int exfat_getattr(const struct mnt_idmap *idmap, const struct path *path, struct kstat *stat, unsigned int request_mask,fs/exfat/file.c +1
-1@@ -347,7 +347,7 @@ int exfat_fileattr_get(struct dentry *dentry, struct file_kattr *fa)return 0 ; } -int exfat_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int exfat_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct exfat_sb_info *sbi =EXFAT_SB (dentry->d_sb);fs/ext2/ext2.h +1
-1@@ -739,7 +739,7 @@ extern int ext2_sync_inode_metadata(struct inode *, struct writeback_control *);extern void ext2_evict_inode (struct inode *);void ext2_write_failed (struct address_space *mapping,loff_t to);extern int ext2_get_block (struct inode *,sector_t ,struct buffer_head *,int ); -extern int ext2_setattr (struct mnt_idmap *,struct dentry *,struct iattr *); +extern int ext2_setattr (const struct mnt_idmap *,struct dentry *,struct iattr *);extern int ext2_getattr (const struct mnt_idmap *,const struct path *,struct kstat *,u32 ,unsigned int );extern void ext2_set_inode_flags (struct inode *inode);fs/ext2/inode.c +1
-1@@ -1617,7 +1617,7 @@ int ext2_getattr(const struct mnt_idmap *idmap, const struct path *path,return 0 ; } -int ext2_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ext2_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct inode *inode =d_inode (dentry);fs/ext4/ext4.h +1
-1@@ -3179,7 +3179,7 @@ extern struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,extern int ext4_write_inode (struct inode *,struct writeback_control *);extern int ext4_sync_inode_metadata (struct inode *,struct writeback_control *); -extern int ext4_setattr (struct mnt_idmap *,struct dentry *, +extern int ext4_setattr (const struct mnt_idmap *,struct dentry *,struct iattr *);extern u32 ext4_dio_alignment (struct inode *inode); extern int ext4_getattr(const struct mnt_idmap *, const struct path *,fs/ext4/inode.c +1
-1@@ -6006,7 +6006,7 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)* * Called with inode->i_rwsem down. */ -int ext4_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ext4_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/f2fs/f2fs.h +1
-1@@ -3850,7 +3850,7 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock);int f2fs_truncate (struct inode *inode);int f2fs_getattr (const struct mnt_idmap *idmap,const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags); -int f2fs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int f2fs_setattr (const struct mnt_idmap *idmap,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);fs/f2fs/file.c +1
-1@@ -1121,7 +1121,7 @@ static void __setattr_copy(const struct mnt_idmap *idmap,#define __setattr_copy setattr_copy#endif -int f2fs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int f2fs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/fat/fat.h +1
-1@@ -404,7 +404,7 @@ 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 mnt_idmap *idmap,struct dentry *dentry, +extern int fat_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr);extern void fat_truncate_blocks (struct inode *inode,loff_t offset); extern int fat_getattr(const struct mnt_idmap *idmap,fs/fat/file.c +1
-1@@ -514,7 +514,7 @@ static int fat_allow_set_time(const struct mnt_idmap *idmap,/* valid file mode bits */ #define FAT_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXUGO) -int fat_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int fat_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct msdos_sb_info *sbi =MSDOS_SB (dentry->d_sb);fs/fuse/dir.c +1
-1@@ -2324,7 +2324,7 @@ int fuse_do_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,return err; } -static int fuse_setattr (struct mnt_idmap *idmap,struct dentry *entry, +static int fuse_setattr (const struct mnt_idmap *idmap,struct dentry *entry,struct iattr *attr) {struct inode *inode =d_inode (entry);fs/gfs2/inode.c +1
-1@@ -2095,7 +2095,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)* Returns: errno */ -static int gfs2_setattr (struct mnt_idmap *idmap, +static int gfs2_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/hfs/hfs_fs.h +1
-1@@ -212,7 +212,7 @@ extern struct inode *hfs_new_inode(struct inode *dir, const struct qstr *name,extern void hfs_inode_write_fork (struct inode *inode,struct hfs_extent *ext,__be32 *log_size,__be32 *phys_size);extern int hfs_write_inode (struct inode *inode,struct writeback_control *wbc); -extern int hfs_inode_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +extern int hfs_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr); extern void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext, __be32 __log_size, __be32 phys_size,fs/hfs/inode.c +1
-1@@ -643,7 +643,7 @@ static int hfs_file_release(struct inode *inode, struct file *file)return 0 ; } -int hfs_inode_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int hfs_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/hfsplus/inode.c +1
-1@@ -305,7 +305,7 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)return 0 ; } -static int hfsplus_setattr (struct mnt_idmap *idmap, +static int hfsplus_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/hostfs/hostfs_kern.c +1
-1@@ -801,7 +801,7 @@ static int hostfs_permission(const struct mnt_idmap *idmap,return err; } -static int hostfs_setattr (struct mnt_idmap *idmap, +static int hostfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);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 mnt_idmap *,struct dentry *,struct iattr *); +int hpfs_setattr (const struct mnt_idmap *,struct dentry *,struct iattr *);void hpfs_write_if_changed (struct inode *);void hpfs_evict_inode (struct inode *);fs/hpfs/inode.c +1
-1@@ -257,7 +257,7 @@ void hpfs_write_inode_nolock(struct inode *i)brelse (bh); } -int hpfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int hpfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/hugetlbfs/inode.c +1
-1@@ -828,7 +828,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,return error; } -static int hugetlbfs_setattr (struct mnt_idmap *idmap, +static int hugetlbfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/inode.c +1
-1@@ -2356,7 +2356,7 @@ int dentry_needs_remove_privs(const struct mnt_idmap *idmap,return mask; } -static int __remove_privs (struct mnt_idmap *idmap, +static int __remove_privs (const struct mnt_idmap *idmap,struct dentry *dentry,int kill) {struct iattr newattrs;fs/internal.h +1
-1@@ -359,7 +359,7 @@ struct dentry *find_next_child(struct dentry *parent, struct dentry *prev);int anon_inode_getattr (const struct mnt_idmap *idmap,const struct path *path,struct kstat *stat,u32 request_mask,unsigned int query_flags); -int anon_inode_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int anon_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr);void pidfs_get_root (struct path *path);void nsfs_get_root (struct path *path);fs/jffs2/fs.c +1
-1@@ -190,7 +190,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)return 0 ; } -int jffs2_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int jffs2_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct inode *inode =d_inode (dentry);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 mnt_idmap *,struct dentry *,struct iattr *); +int jffs2_setattr (const struct mnt_idmap *,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/file.c +1
-1@@ -89,7 +89,7 @@ static int jfs_release(struct inode *inode, struct file *file)return 0 ; } -int jfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int jfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct inode *inode =d_inode (dentry);fs/jfs/jfs_inode.h +1
-1@@ -28,7 +28,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 mnt_idmap *,struct dentry *,struct iattr *); +extern int jfs_setattr (const struct mnt_idmap *,struct dentry *,struct iattr *);extern const struct address_space_operations jfs_aops;extern const struct inode_operations jfs_dir_inode_operations;fs/kernfs/inode.c +1
-1@@ -107,7 +107,7 @@ int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr)return ret; } -int kernfs_iop_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int kernfs_iop_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct inode *inode =d_inode (dentry);fs/kernfs/kernfs-internal.h +1
-1@@ -173,7 +173,7 @@ extern const struct xattr_handler * const kernfs_xattr_handlers[];void kernfs_evict_inode (struct inode *inode);int kernfs_iop_permission (const struct mnt_idmap *idmap,struct inode *inode,int mask); -int kernfs_iop_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int kernfs_iop_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr); int kernfs_iop_getattr(const struct mnt_idmap *idmap, const struct path *path, struct kstat *stat,fs/libfs.c +2
-2@@ -913,7 +913,7 @@ 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 mnt_idmap *idmap,struct dentry *dentry, +int simple_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct inode *inode =d_inode (dentry);@@ -1727,7 +1727,7 @@ static struct dentry *empty_dir_lookup(struct inode *dir, struct dentry *dentry,return ERR_PTR (-ENOENT ); } -static int empty_dir_setattr (struct mnt_idmap *idmap, +static int empty_dir_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {return -EPERM ;fs/minix/file.c +1
-1@@ -23,7 +23,7 @@ const struct file_operations minix_file_operations = { .splice_read = filemap_splice_read, }; -static int minix_setattr (struct mnt_idmap *idmap, +static int minix_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/nfs/inode.c +1
-1@@ -690,7 +690,7 @@ EXPORT_SYMBOL_GPL(nfs_update_delegated_mtime);#define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE|ATTR_OPEN)int -nfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +nfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/nfs/namespace.c +1
-1@@ -235,7 +235,7 @@ nfs_namespace_getattr(const struct mnt_idmap *idmap, }static int -nfs_namespace_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +nfs_namespace_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {if (NFS_FH (d_inode (dentry))->size !=0 )fs/nilfs2/inode.c +1
-1@@ -904,7 +904,7 @@ void nilfs_evict_inode(struct inode *inode)*/ } -int nilfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int nilfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct nilfs_transaction_info ti;fs/nilfs2/nilfs.h +1
-1@@ -299,7 +299,7 @@ struct inode *nilfs_iget_for_shadow(struct inode *inode);extern void nilfs_update_inode (struct inode *,struct buffer_head *,int );extern void nilfs_truncate (struct inode *);extern void nilfs_evict_inode (struct inode *); -extern int nilfs_setattr (struct mnt_idmap *,struct dentry *, +extern int nilfs_setattr (const struct mnt_idmap *,struct dentry *,struct iattr *);extern void nilfs_write_failed (struct address_space *mapping,loff_t to); int nilfs_permission(const struct mnt_idmap *idmap, struct inode *inode,fs/ntfs/file.c +1
-1@@ -294,7 +294,7 @@ static int ntfs_setattr_size(struct inode *vi, struct iattr *attr)* NOTE: Changes in inode size are not supported yet for compressed or * encrypted files. */ -int ntfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ntfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *vi =d_inode (dentry);fs/ntfs/inode.h +1
-1@@ -330,7 +330,7 @@ int ntfs_read_inode_mount(struct inode *vi);int ntfs_show_options (struct seq_file *sf,struct dentry *root);int ntfs_truncate_vfs (struct inode *vi,loff_t new_size,loff_t i_size); -int ntfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ntfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr); int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path, struct kstat *stat, unsigned int request_mask,fs/ntfs3/file.c +1
-1@@ -703,7 +703,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)/* * ntfs_setattr - inode_operations::setattr */ -int ntfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ntfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/ntfs3/ntfs_fs.h +1
-1@@ -555,7 +555,7 @@ int ntfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry, struct file_kattr *fa);int ntfs_getattr (const struct mnt_idmap *idmap,const struct path *path,struct kstat *stat,u32 request_mask,u32 flags); -int ntfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ntfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr);int ntfs_file_open (struct inode *inode,struct file *file); int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,fs/ocfs2/dlmfs/dlmfs.c +1
-1@@ -188,7 +188,7 @@ static int dlmfs_file_release(struct inode *inode,* We do ->setattr() just to override size changes. Our size is the size * of the LVB and nothing else. */ -static int dlmfs_file_setattr (struct mnt_idmap *idmap, +static int dlmfs_file_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {int error;fs/ocfs2/file.c +1
-1@@ -1117,7 +1117,7 @@ static int ocfs2_extend_file(struct inode *inode,return ret; } -int ocfs2_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ocfs2_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {int status =0 , size_change;fs/ocfs2/file.h +1
-1@@ -50,7 +50,7 @@ int ocfs2_extend_no_holes(struct inode *inode, struct buffer_head *di_bh, u64 new_i_size, u64 zero_to);int ocfs2_zero_extend (struct inode *inode,struct buffer_head *di_bh,loff_t zero_to); -int ocfs2_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ocfs2_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr);int ocfs2_getattr (const struct mnt_idmap *idmap,const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags);fs/omfs/file.c +1
-1@@ -338,7 +338,7 @@ const struct file_operations omfs_file_operations = { .splice_read = filemap_splice_read, }; -static int omfs_setattr (struct mnt_idmap *idmap, +static int omfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/orangefs/inode.c +1
-1@@ -828,7 +828,7 @@ int __orangefs_setattr_mode(struct dentry *dentry, struct iattr *iattr)/* * Change attributes of an object referenced by dentry. */ -int orangefs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int orangefs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {int ret;fs/orangefs/orangefs-kernel.h +1
-1@@ -352,7 +352,7 @@ struct inode *orangefs_new_inode(struct super_block *sb,int __orangefs_setattr (struct inode *,struct iattr *);int __orangefs_setattr_mode (struct dentry *dentry,struct iattr *iattr); -int orangefs_setattr (struct mnt_idmap *,struct dentry *,struct iattr *); +int orangefs_setattr (const struct mnt_idmap *,struct dentry *,struct iattr *);int orangefs_getattr (const struct mnt_idmap *idmap,const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags);fs/overlayfs/inode.c +1
-1@@ -18,7 +18,7 @@#include "overlayfs.h" -int ovl_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ovl_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {int err;fs/overlayfs/overlayfs.h +1
-1@@ -948,7 +948,7 @@ static inline bool ovl_force_readonly(struct ovl_fs *ofs)/* xattr.c */ const struct xattr_handler *const *ovl_xattr_handlers (struct ovl_fs *ofs); -int ovl_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ovl_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr);int ovl_getattr (const struct mnt_idmap *idmap,const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags);fs/pidfs.c +1
-1@@ -823,7 +823,7 @@ static struct vfsmount *pidfs_mnt __ro_after_init;* implemented. Let's reject it completely until we have a clean * permission concept for pidfds. */ -static int pidfs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +static int pidfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {return anon_inode_setattr (idmap, dentry, attr);fs/proc/base.c +1
-1@@ -702,7 +702,7 @@ static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,/* Here the fs part begins */ /************************************************************************/ -int proc_nochmod_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int proc_nochmod_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {int error;fs/proc/generic.c +1
-1@@ -117,7 +117,7 @@ static bool pde_subdir_insert(struct proc_dir_entry *dir,return true; } -static int proc_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +static int proc_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct inode *inode =d_inode (dentry);fs/proc/internal.h +1
-1@@ -260,7 +260,7 @@ extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,extern const struct dentry_operations pid_dentry_operations;extern int pid_getattr (const struct mnt_idmap *,const struct path *,struct kstat *,u32 ,unsigned int ); -int proc_nochmod_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int proc_nochmod_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr);extern void proc_pid_evict_inode (struct proc_inode *);extern struct inode *proc_pid_make_inode (struct super_block *,struct task_struct *,umode_t );fs/proc/proc_sysctl.c +1
-1@@ -817,7 +817,7 @@ static int proc_sys_permission(const struct mnt_idmap *idmap,return error; } -static int proc_sys_setattr (struct mnt_idmap *idmap, +static int proc_sys_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/ramfs/file-nommu.c +2
-2@@ -22,7 +22,7 @@#include <linux/uaccess.h> #include "internal.h" -static int ramfs_nommu_setattr (struct mnt_idmap *,struct dentry *,struct iattr *); +static int ramfs_nommu_setattr (const struct mnt_idmap *,struct dentry *,struct iattr *); static unsigned long ramfs_nommu_get_unmapped_area(struct file *file, unsigned long addr, unsigned long len,@@ -161,7 +161,7 @@ static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size)* handle a change of attributes * - we're specifically interested in a change of size */ -static int ramfs_nommu_setattr (struct mnt_idmap *idmap, +static int ramfs_nommu_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *ia) {struct inode *inode =d_inode (dentry);fs/smb/client/cifsfs.h +1
-1@@ -80,7 +80,7 @@ int cifs_revalidate_mapping(struct inode *inode);int cifs_zap_mapping (struct inode *inode);int cifs_getattr (const struct mnt_idmap *idmap,const struct path *path,struct kstat *stat,u32 request_mask,unsigned int flags); -int cifs_setattr (struct mnt_idmap *idmap,struct dentry *direntry, +int cifs_setattr (const struct mnt_idmap *idmap,struct dentry *direntry,struct iattr *attrs);int cifs_fiemap (struct inode *inode,struct fiemap_extent_info *fei,u64 start,u64 len);fs/smb/client/inode.c +1
-1@@ -3549,7 +3549,7 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) }int -cifs_setattr (struct mnt_idmap *idmap,struct dentry *direntry, +cifs_setattr (const struct mnt_idmap *idmap,struct dentry *direntry,struct iattr *attrs) {struct cifs_sb_info *cifs_sb =CIFS_SB (direntry->d_sb);fs/tracefs/event_inode.c +1
-1@@ -182,7 +182,7 @@ static void update_attr(struct eventfs_attr *attr, struct iattr *iattr) } } -static int eventfs_set_attr (struct mnt_idmap *idmap,struct dentry *dentry, +static int eventfs_set_attr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {const struct eventfs_entry *entry;fs/tracefs/inode.c +1
-1@@ -207,7 +207,7 @@ static int tracefs_getattr(const struct mnt_idmap *idmap,return 0 ; } -static int tracefs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +static int tracefs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {unsigned int ia_valid = attr->ia_valid;fs/ubifs/file.c +1
-1@@ -1251,7 +1251,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,return err; } -int ubifs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ubifs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {int err;fs/ubifs/ubifs.h +1
-1@@ -2020,7 +2020,7 @@ int ubifs_calc_dark(const struct ubifs_info *c, int spc);/* file.c */ int ubifs_fsync (struct file *file,loff_t start,loff_t end,int datasync); -int ubifs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ubifs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr);int ubifs_update_time (struct inode *inode,enum fs_update_time type,unsigned int flags);fs/udf/file.c +1
-1@@ -212,7 +212,7 @@ const struct file_operations udf_file_operations = { .setlease = generic_setlease, }; -static int udf_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +static int udf_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/ufs/inode.c +1
-1@@ -1195,7 +1195,7 @@ static int ufs_truncate(struct inode *inode, loff_t size)return err; } -int ufs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int ufs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);fs/ufs/ufs.h +1
-1@@ -120,7 +120,7 @@ extern struct inode *ufs_iget(struct super_block *, unsigned long);extern int ufs_write_inode (struct inode *,struct writeback_control *);extern int ufs_sync_inode (struct inode *);extern void ufs_evict_inode (struct inode *); -extern int ufs_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +extern int ufs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr);/* namei.c */ fs/vboxsf/utils.c +1
-1@@ -258,7 +258,7 @@ int vboxsf_getattr(const struct mnt_idmap *idmap, const struct path *path,return 0 ; } -int vboxsf_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int vboxsf_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct vboxsf_inode *sf_i =VBOXSF_I (d_inode (dentry));fs/vboxsf/vfsmod.h +1
-1@@ -101,7 +101,7 @@ int vboxsf_inode_revalidate(struct dentry *dentry);int vboxsf_getattr (const struct mnt_idmap *idmap,const struct path *path,struct kstat *kstat,u32 request_mask,unsigned int query_flags); -int vboxsf_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +int vboxsf_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr);struct shfl_string *vboxsf_path_from_dentry (struct vboxsf_sbi *sbi,struct dentry *dentry);fs/xfs/xfs_iops.c +1
-1@@ -1130,7 +1130,7 @@ xfs_vn_setattr_size( STATIC intxfs_vn_setattr ( -struct mnt_idmap *idmap, +const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {fs/zonefs/super.c +1
-1@@ -533,7 +533,7 @@ static int zonefs_show_options(struct seq_file *seq, struct dentry *root)return 0 ; } -static int zonefs_inode_setattr (struct mnt_idmap *idmap, +static int zonefs_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct inode *inode =d_inode (dentry);include/linux/fs.h +3
-3@@ -2012,7 +2012,7 @@ struct inode_operations { umode_t,dev_t);int (*rename) (const struct mnt_idmap *,struct inode *,struct dentry *,struct inode *,struct dentry *,unsigned int ); -int (*setattr) (struct mnt_idmap *,struct dentry *,struct iattr *); +int (*setattr) (const struct mnt_idmap *,struct dentry *,struct iattr *);int (*getattr) (const struct mnt_idmap *,const struct path *,struct kstat *,u32 ,unsigned int );ssize_t (*listxattr) (struct dentry *,char *,size_t );@@ -2707,7 +2707,7 @@ static inline int bmap(struct inode *inode, sector_t *block) }#endif -int notify_change (struct mnt_idmap *,struct dentry *, +int notify_change (const struct mnt_idmap *,struct dentry *,struct iattr *,struct delegated_inode *);int inode_permission (const struct mnt_idmap *,struct inode *,int );int generic_permission (const struct mnt_idmap *,struct inode *,int );@@ -3261,7 +3261,7 @@ extern int dcache_dir_open(struct inode *, struct file *);extern int dcache_dir_close (struct inode *,struct file *);extern loff_t dcache_dir_lseek (struct file *,loff_t ,int );extern int dcache_readdir (struct file *,struct dir_context *); -extern int simple_setattr (struct mnt_idmap *,struct dentry *, +extern int simple_setattr (const struct mnt_idmap *,struct dentry *,struct iattr *);extern int simple_getattr (const struct mnt_idmap *,const struct path *,struct kstat *,u32 ,unsigned int );include/linux/lsm_hook_defs.h +2
-2@@ -140,9 +140,9 @@ LSM_HOOK(int, 0, inode_readlink, struct dentry *dentry) LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode, bool rcu) LSM_HOOK(int, 0, inode_permission, struct inode *inode, int mask) -LSM_HOOK(int, 0, inode_setattr, struct mnt_idmap *idmap, struct dentry *dentry, +LSM_HOOK(int, 0, inode_setattr, const struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr) -LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, struct mnt_idmap *idmap, +LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, const struct mnt_idmap *idmap, struct dentry *dentry, int ia_valid) LSM_HOOK(int, 0, inode_getattr, const struct path *path) LSM_HOOK(int, 0, inode_xattr_skipcap, const char *name)include/linux/nfs_fs.h +1
-1@@ -450,7 +450,7 @@ extern int nfs_clear_invalid_mapping(struct address_space *mapping);extern bool nfs_mapping_need_revalidate_inode (struct inode *inode);extern int nfs_revalidate_mapping (struct inode *inode,struct address_space *mapping);extern int nfs_revalidate_mapping_rcu (struct inode *inode); -extern int nfs_setattr (struct mnt_idmap *,struct dentry *,struct iattr *); +extern int nfs_setattr (const struct mnt_idmap *,struct dentry *,struct iattr *);extern void nfs_setattr_update_inode (struct inode *inode,struct iattr *attr,struct nfs_fattr *);extern void nfs_setsecurity (struct inode *inode,struct nfs_fattr *fattr);extern struct nfs_open_context *get_nfs_open_context (struct nfs_open_context *ctx);include/linux/security.h +4
-4@@ -422,9 +422,9 @@ int security_inode_readlink(struct dentry *dentry);int security_inode_follow_link (struct dentry *dentry,struct inode *inode,bool rcu);int security_inode_permission (struct inode *inode,int mask); -int security_inode_setattr (struct mnt_idmap *idmap, +int security_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr); -void security_inode_post_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +void security_inode_post_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,int ia_valid);int security_inode_getattr (const struct path *path); int security_inode_setxattr(const struct mnt_idmap *idmap,@@ -979,7 +979,7 @@ static inline int security_inode_permission(struct inode *inode, int mask)return 0 ; } -static inline int security_inode_setattr (struct mnt_idmap *idmap, +static inline int security_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {@@ -987,7 +987,7 @@ static inline int security_inode_setattr(struct mnt_idmap *idmap, }static inline void -security_inode_post_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +security_inode_post_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,int ia_valid) { }mm/secretmem.c +1
-1@@ -161,7 +161,7 @@ const struct address_space_operations secretmem_aops = { .migrate_folio = secretmem_migrate_folio, }; -static int secretmem_setattr (struct mnt_idmap *idmap, +static int secretmem_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct inode *inode =d_inode (dentry);mm/shmem.c +1
-1@@ -1326,7 +1326,7 @@ static int shmem_getattr(const struct mnt_idmap *idmap,return 0 ; } -static int shmem_setattr (struct mnt_idmap *idmap, +static int shmem_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {struct inode *inode =d_inode (dentry);net/socket.c +1
-1@@ -670,7 +670,7 @@ static ssize_t sockfs_listxattr(struct dentry *dentry, char *buffer,return used; } -static int sockfs_setattr (struct mnt_idmap *idmap, +static int sockfs_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {int err =simple_setattr (&nop_mnt_idmap, dentry, iattr);security/integrity/evm/evm_main.c +2
-2@@ -956,7 +956,7 @@ static int evm_attr_change(const struct mnt_idmap *idmap,* Permit update of file attributes when files have a valid EVM signature, * except in the case of them having an immutable portable signature. */ -static int evm_inode_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +static int evm_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {unsigned int ia_valid = attr->ia_valid;@@ -1008,7 +1008,7 @@ static int evm_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,* This function is called from notify_change(), which expects the caller * to lock the inode's i_mutex. */ -static void evm_inode_post_setattr (struct mnt_idmap *idmap, +static void evm_inode_post_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,int ia_valid) {if (!evm_revalidate_status (NULL ))security/integrity/ima/ima_appraise.c +1
-1@@ -634,7 +634,7 @@ void ima_update_xattr(struct ima_iint_cache *iint, struct file *file)* This function is called from notify_change(), which expects the caller * to lock the inode's i_mutex. */ -static void ima_inode_post_setattr (struct mnt_idmap *idmap, +static void ima_inode_post_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,int ia_valid) {struct inode *inode =d_backing_inode (dentry);security/security.c +2
-2@@ -1855,7 +1855,7 @@ int security_inode_permission(struct inode *inode, int mask)* * Return: Returns 0 if permission is granted. */ -int security_inode_setattr (struct mnt_idmap *idmap, +int security_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {if (unlikely (IS_PRIVATE (d_backing_inode (dentry))))@@ -1872,7 +1872,7 @@ EXPORT_SYMBOL_GPL(security_inode_setattr);* * Update inode security field after successful setting file attributes. */ -void security_inode_post_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +void security_inode_post_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,int ia_valid) {if (unlikely (IS_PRIVATE (d_backing_inode (dentry))))security/selinux/hooks.c +1
-1@@ -3297,7 +3297,7 @@ static int selinux_inode_permission(struct inode *inode, int requested)return rc; } -static int selinux_inode_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +static int selinux_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {const struct cred *cred =current_cred ();security/smack/smack_lsm.c +1
-1@@ -1270,7 +1270,7 @@ static int smack_inode_permission(struct inode *inode, int mask)* * Returns 0 if access is permitted, an error code otherwise */ -static int smack_inode_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +static int smack_inode_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *iattr) {struct smk_audit_info ad;virt/kvm/guest_memfd.c +1
-1@@ -506,7 +506,7 @@ static const struct address_space_operations kvm_gmem_aops = {#endif }; -static int kvm_gmem_setattr (struct mnt_idmap *idmap,struct dentry *dentry, +static int kvm_gmem_setattr (const struct mnt_idmap *idmap,struct dentry *dentry,struct iattr *attr) {return -EINVAL ;Signature · 2 lines
-- 2.53.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Re: [PATCH 24/27] fs: port ->setattr() to pass const mnt_idmap
In reply to Christian BraunerQuoted 113 lines · On Sep 1, 2026 Christian Brauner <[email protected]> wrote:
Convert to const struct
mnt_idmap.A mount's idmapping is immutable. The only thing that is allowed to be modified afterwards is the reference count and that is hidden behind
mnt_idmap_get()andmnt_idmap_put(). Everything else only ever reads from the idmapping. This is the same model that struct cred uses and the idmapping is also rather sensitive.So make the idmap argument const wherever we can. The conversion is done from the bottom up so callers can continue to pass a non-const pointer to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by Christian Brauner (Amutable) <[email protected]>Reviewed-by Jan Kara <[email protected]>--- Documentation/filesystems/locking.rst | 2 +- Documentation/filesystems/vfs.rst | 2 +- arch/powerpc/platforms/cell/spufs/inode.c | 2 +- fs/9p/v9fs_vfs.h | 2 +- fs/9p/vfs_inode.c | 2 +- fs/9p/vfs_inode_dotl.c | 2 +- fs/adfs/adfs.h | 2 +- fs/adfs/inode.c | 2 +- fs/affs/affs.h | 2 +- fs/affs/inode.c | 2 +- fs/afs/inode.c | 2 +- fs/afs/internal.h | 2 +- fs/anon_inodes.c | 2 +- fs/attr.c | 2 +- fs/bad_inode.c | 2 +- fs/btrfs/inode.c | 2 +- fs/ceph/inode.c | 2 +- fs/ceph/super.h | 2 +- fs/coda/coda_linux.h | 2 +- fs/coda/inode.c | 2 +- fs/configfs/configfs_internal.h | 2 +- fs/configfs/inode.c | 2 +- fs/debugfs/inode.c | 2 +- fs/ecryptfs/inode.c | 2 +- fs/efivarfs/inode.c | 2 +- fs/exfat/exfat_fs.h | 2 +- fs/exfat/file.c | 2 +- fs/ext2/ext2.h | 2 +- fs/ext2/inode.c | 2 +- fs/ext4/ext4.h | 2 +- fs/ext4/inode.c | 2 +- fs/f2fs/f2fs.h | 2 +- fs/f2fs/file.c | 2 +- fs/fat/fat.h | 2 +- fs/fat/file.c | 2 +- fs/fuse/dir.c | 2 +- fs/gfs2/inode.c | 2 +- fs/hfs/hfs_fs.h | 2 +- fs/hfs/inode.c | 2 +- fs/hfsplus/inode.c | 2 +- fs/hostfs/hostfs_kern.c | 2 +- fs/hpfs/hpfs_fn.h | 2 +- fs/hpfs/inode.c | 2 +- fs/hugetlbfs/inode.c | 2 +- fs/inode.c | 2 +- fs/internal.h | 2 +- fs/jffs2/fs.c | 2 +- fs/jffs2/os-linux.h | 2 +- fs/jfs/file.c | 2 +- fs/jfs/jfs_inode.h | 2 +- fs/kernfs/inode.c | 2 +- fs/kernfs/kernfs-internal.h | 2 +- fs/libfs.c | 4 ++-- fs/minix/file.c | 2 +- fs/nfs/inode.c | 2 +- fs/nfs/namespace.c | 2 +- fs/nilfs2/inode.c | 2 +- fs/nilfs2/nilfs.h | 2 +- fs/ntfs/file.c | 2 +- fs/ntfs/inode.h | 2 +- fs/ntfs3/file.c | 2 +- fs/ntfs3/ntfs_fs.h | 2 +- fs/ocfs2/dlmfs/dlmfs.c | 2 +- fs/ocfs2/file.c | 2 +- fs/ocfs2/file.h | 2 +- fs/omfs/file.c | 2 +- fs/orangefs/inode.c | 2 +- fs/orangefs/orangefs-kernel.h | 2 +- fs/overlayfs/inode.c | 2 +- fs/overlayfs/overlayfs.h | 2 +- fs/pidfs.c | 2 +- fs/proc/base.c | 2 +- fs/proc/generic.c | 2 +- fs/proc/internal.h | 2 +- fs/proc/proc_sysctl.c | 2 +- fs/ramfs/file-nommu.c | 4 ++-- fs/smb/client/cifsfs.h | 2 +- fs/smb/client/inode.c | 2 +- fs/tracefs/event_inode.c | 2 +- fs/tracefs/inode.c | 2 +- fs/ubifs/file.c | 2 +- fs/ubifs/ubifs.h | 2 +- fs/udf/file.c | 2 +- fs/ufs/inode.c | 2 +- fs/ufs/ufs.h | 2 +- fs/vboxsf/utils.c | 2 +- fs/vboxsf/vfsmod.h | 2 +- fs/xfs/xfs_iops.c | 2 +- fs/zonefs/super.c | 2 +- include/linux/fs.h | 6 +++--- include/linux/lsm_hook_defs.h | 4 ++-- include/linux/nfs_fs.h | 2 +- include/linux/security.h | 8 ++++---- mm/secretmem.c | 2 +- mm/shmem.c | 2 +-
Quoted 8 lines
net/socket.c | 2 +- security/integrity/evm/evm_main.c | 4 ++-- security/integrity/ima/ima_appraise.c | 2 +- security/security.c | 4 ++-- security/selinux/hooks.c | 2 +- security/smack/smack_lsm.c | 2 +- virt/kvm/guest_memfd.c | 2 +- 102 files changed, 112 insertions(+), 112 deletions(-)
--
paul-moore.com
Christian Brauner
maintainerPATCH 25/27 fs: port vfs_*() helpers to const mnt_idmap
In reply to Christian BraunerConvert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be modified afterwards is the reference count and that is hidden behind mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads from the idmapping. This is the same model that struct cred uses and the idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done from the bottom up so callers can continue to pass a non-const pointer to a const parameter until the conversion is finished.
No functional changes.
--- fs/btrfs/ioctl.c | 4 ++-- fs/internal.h | 2 +- fs/namei.c | 44 ++++++++++++++++++++++---------------------- fs/open.c | 2 +- include/linux/fs.h | 30 +++++++++++++++--------------- include/linux/namei.h | 16 ++++++++-------- 6 files changed, 49 insertions(+), 49 deletions(-)
fs/btrfs/ioctl.c +2 -2
@@ -864,7 +864,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,* inside this filesystem so it's quite a bit simpler. */ static noinline int btrfs_mksubvol(struct dentry *parent, -struct mnt_idmap *idmap, +const struct mnt_idmap *idmap,struct qstr *qname,struct btrfs_root *snap_src,bool readonly,struct btrfs_qgroup_inherit *inherit)
@@ -911,7 +911,7 @@ static noinline int btrfs_mksubvol(struct dentry *parent, } static noinline int btrfs_mksnapshot(struct dentry *parent, - struct mnt_idmap *idmap, + const struct mnt_idmap *idmap, struct qstr *qname, struct btrfs_root *root, bool readonly,
fs/internal.h +1 -1
@@ -63,7 +63,7 @@ int filename_mknodat(int dfd, struct filename *name, umode_t mode, unsigned intint filename_symlinkat (struct filename *from,int newdfd,struct filename *to);int filename_linkat (int olddfd,struct filename *old,int newdfd,struct filename *new,int flags); -int vfs_tmpfile (struct mnt_idmap *idmap, +int vfs_tmpfile (const struct mnt_idmap *idmap,const struct path *parentpath,struct file *file,umode_t mode);struct dentry *d_hash_and_lookup (struct dentry *,struct qstr *);
fs/namei.c +22 -22
176 lines not on this page · raw message
fs/open.c +1 -1
@@ -36,7 +36,7 @@#include "internal.h" -int do_truncate (struct mnt_idmap *idmap,struct dentry *dentry, +int do_truncate (const struct mnt_idmap *idmap,struct dentry *dentry,loff_t length,unsigned int time_attrs,struct file *filp) {int ret;
include/linux/fs.h +15 -15
@@ -1761,19 +1761,19 @@ bool inode_owner_or_capable(const struct mnt_idmap *idmap,/* * VFS helper functions.. */ -int vfs_create (struct mnt_idmap *,struct dentry *,umode_t , +int vfs_create (const struct mnt_idmap *,struct dentry *,umode_t ,struct delegated_inode *); -struct dentry *vfs_mkdir (struct mnt_idmap *,struct inode *, +struct dentry *vfs_mkdir (const struct mnt_idmap *,struct inode *,struct dentry *,umode_t ,struct delegated_inode *); -int vfs_mknod (struct mnt_idmap *,struct inode *,struct dentry *, +int vfs_mknod (const struct mnt_idmap *,struct inode *,struct dentry *,umode_t ,dev_t ,struct delegated_inode *); -int vfs_symlink (struct mnt_idmap *,struct inode *, +int vfs_symlink (const struct mnt_idmap *,struct inode *,struct dentry *,const char *,struct delegated_inode *); -int vfs_link (struct dentry *,struct mnt_idmap *,struct inode *, +int vfs_link (struct dentry *,const struct mnt_idmap *,struct inode *,struct dentry *,struct delegated_inode *); -int vfs_rmdir (struct mnt_idmap *,struct inode *,struct dentry *, +int vfs_rmdir (const struct mnt_idmap *,struct inode *,struct dentry *,struct delegated_inode *); -int vfs_unlink (struct mnt_idmap *,struct inode *,struct dentry *, +int vfs_unlink (const struct mnt_idmap *,struct inode *,struct dentry *,struct delegated_inode *);/**
@@ -1787,7 +1787,7 @@ int vfs_unlink(struct mnt_idmap *, struct inode *, struct dentry *,* @flags: rename flags */ struct renamedata { -struct mnt_idmap *mnt_idmap; +const struct mnt_idmap *mnt_idmap;struct dentry *old_parent;struct dentry *old_dentry;struct dentry *new_parent;
@@ -1798,14 +1798,14 @@ struct renamedata {int vfs_rename (struct renamedata *); -static inline int vfs_whiteout (struct mnt_idmap *idmap, +static inline int vfs_whiteout (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry) {return vfs_mknod (idmap, dir, dentry,S_IFCHR |WHITEOUT_MODE ,WHITEOUT_DEV ,NULL ); } -struct file *kernel_tmpfile_open (struct mnt_idmap *idmap, +struct file *kernel_tmpfile_open (const struct mnt_idmap *idmap,const struct path *parentpath,umode_t mode,int open_flag,const struct cred *cred);
@@ -2483,7 +2483,7 @@ static inline bool is_idmapped_mnt(const struct vfsmount *mnt) }int vfs_truncate (const struct path *,loff_t ); -int do_truncate (struct mnt_idmap *,struct dentry *,loff_t start, +int do_truncate (const struct mnt_idmap *,struct dentry *,loff_t start,unsigned int time_attrs,struct file *filp);extern int vfs_fallocate (struct file *file,int mode,loff_t offset,loff_t len);
@@ -2721,12 +2721,12 @@ static inline int path_permission(const struct path *path, int mask)return inode_permission (mnt_idmap (path->mnt),d_inode (path->dentry), mask); } -int __check_sticky (struct mnt_idmap *idmap,struct inode *dir, +int __check_sticky (const struct mnt_idmap *idmap,struct inode *dir,struct inode *inode); -int may_delete_dentry (struct mnt_idmap *idmap,struct inode *dir, +int may_delete_dentry (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *victim,bool isdir); -int may_create_dentry (struct mnt_idmap *idmap, +int may_create_dentry (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *child);static inline bool execute_ok (struct inode *inode)
@@ -3578,7 +3578,7 @@ static inline bool is_sxid(umode_t mode)return mode & (S_ISUID |S_ISGID ); } -static inline int check_sticky (struct mnt_idmap *idmap, +static inline int check_sticky (const struct mnt_idmap *idmap,struct inode *dir,struct inode *inode) {if (!(dir->i_mode &S_ISVTX ))
include/linux/namei.h +8 -8
@@ -70,24 +70,24 @@ extern struct dentry *try_lookup_noperm(struct qstr *, struct dentry *);extern struct dentry *lookup_noperm (struct qstr *,struct dentry *);extern struct dentry *lookup_noperm_unlocked (struct qstr *,struct dentry *);extern struct dentry *lookup_noperm_positive_unlocked (struct qstr *,struct dentry *); -struct dentry *lookup_one (struct mnt_idmap *,struct qstr *,struct dentry *); -struct dentry *lookup_one_unlocked (struct mnt_idmap *idmap, +struct dentry *lookup_one (const struct mnt_idmap *,struct qstr *,struct dentry *); +struct dentry *lookup_one_unlocked (const struct mnt_idmap *idmap,struct qstr *name,struct dentry *base); -struct dentry *lookup_one_positive_unlocked (struct mnt_idmap *idmap, +struct dentry *lookup_one_positive_unlocked (const struct mnt_idmap *idmap,struct qstr *name,struct dentry *base); -struct dentry *lookup_one_positive_killable (struct mnt_idmap *idmap, +struct dentry *lookup_one_positive_killable (const struct mnt_idmap *idmap,struct qstr *name,struct dentry *base); -struct dentry *start_creating (struct mnt_idmap *idmap,struct dentry *parent, +struct dentry *start_creating (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name); -struct dentry *start_removing (struct mnt_idmap *idmap,struct dentry *parent, +struct dentry *start_removing (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name); -struct dentry *start_creating_killable (struct mnt_idmap *idmap, +struct dentry *start_creating_killable (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name); -struct dentry *start_removing_killable (struct mnt_idmap *idmap, +struct dentry *start_removing_killable (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name);struct dentry *start_creating_noperm (struct dentry *parent,struct qstr *name);
Signature · 1 line
2.53.0
Re: [PATCH 25/27] fs: port vfs_*() helpers to const mnt_idmap
Quoted 8 lines · Christian Brauner
Convert to const struct
mnt_idmap.A mount's idmapping is immutable. The only thing that is allowed to be modified afterwards is the reference count and that is hidden behind
mnt_idmap_get()andmnt_idmap_put(). Everything else only ever reads from the idmapping. This is the same model that struct cred uses and the idmapping is also rather sensitive.
Quoted 7 lines
So make the idmap argument const wherever we can. The conversion is done from the bottom up so callers can continue to pass a non-const pointer to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by Christian Brauner (Amutable) <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 391 lines
--- fs/btrfs/ioctl.c | 4 ++-- fs/internal.h | 2 +- fs/namei.c | 44 ++++++++++++++++++++++---------------------- fs/open.c | 2 +- include/linux/fs.h | 30 +++++++++++++++--------------- include/linux/namei.h | 16 ++++++++-------- 6 files changed, 49 insertions(+), 49 deletions(-)fs/btrfs/ioctl.c +2
-2@@ -864,7 +864,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,* inside this filesystem so it's quite a bit simpler. */ static noinline int btrfs_mksubvol(struct dentry *parent, -struct mnt_idmap *idmap, +const struct mnt_idmap *idmap,struct qstr *qname,struct btrfs_root *snap_src,bool readonly,struct btrfs_qgroup_inherit *inherit)@@ -911,7 +911,7 @@ static noinline int btrfs_mksubvol(struct dentry *parent, } static noinline int btrfs_mksnapshot(struct dentry *parent, - struct mnt_idmap *idmap, + const struct mnt_idmap *idmap, struct qstr *qname, struct btrfs_root *root, bool readonly,fs/internal.h +1
-1@@ -63,7 +63,7 @@ int filename_mknodat(int dfd, struct filename *name, umode_t mode, unsigned intint filename_symlinkat (struct filename *from,int newdfd,struct filename *to);int filename_linkat (int olddfd,struct filename *old,int newdfd,struct filename *new,int flags); -int vfs_tmpfile (struct mnt_idmap *idmap, +int vfs_tmpfile (const struct mnt_idmap *idmap,const struct path *parentpath,struct file *file,umode_t mode);struct dentry *d_hash_and_lookup (struct dentry *,struct qstr *);fs/namei.c +22
-22@@ -3111,7 +3111,7 @@ int lookup_noperm_common(struct qstr *qname, struct dentry *base)return 0 ; } -static int lookup_one_common (struct mnt_idmap *idmap, +static int lookup_one_common (const struct mnt_idmap *idmap,struct qstr *qname,struct dentry *base) {int err;@@ -3190,7 +3190,7 @@ EXPORT_SYMBOL(lookup_noperm);* * The caller must hold base->i_rwsem. */ -struct dentry *lookup_one (struct mnt_idmap *idmap,struct qstr *name, +struct dentry *lookup_one (const struct mnt_idmap *idmap,struct qstr *name,struct dentry *base) {struct dentry *dentry;@@ -3223,7 +3223,7 @@ EXPORT_SYMBOL(lookup_one);* - ERR_PTR(-ENOENT) if parent has been removed, or * - ERR_PTR(-EACCES) if parent directory is not searchable. */ -struct dentry *lookup_one_unlocked (struct mnt_idmap *idmap,struct qstr *name, +struct dentry *lookup_one_unlocked (const struct mnt_idmap *idmap,struct qstr *name,struct dentry *base) {int err;@@ -3263,7 +3263,7 @@ EXPORT_SYMBOL(lookup_one_unlocked);* - same errors as lookup_one_unlocked() or * - ERR_PTR(-EINTR) if a fatal signal is pending. */ -struct dentry *lookup_one_positive_killable (struct mnt_idmap *idmap, +struct dentry *lookup_one_positive_killable (const struct mnt_idmap *idmap,struct qstr *name,struct dentry *base) {@@ -3306,7 +3306,7 @@ EXPORT_SYMBOL(lookup_one_positive_killable);* - ERR_PTR(-ENOENT) if the name could not be found, or * - same errors as lookup_one_unlocked(). */ -struct dentry *lookup_one_positive_unlocked (struct mnt_idmap *idmap, +struct dentry *lookup_one_positive_unlocked (const struct mnt_idmap *idmap,struct qstr *name,struct dentry *base) {@@ -3396,7 +3396,7 @@ EXPORT_SYMBOL(lookup_noperm_positive_unlocked);* * Returns: a negative or positive dentry, or an error. */ -struct dentry *start_creating (struct mnt_idmap *idmap,struct dentry *parent, +struct dentry *start_creating (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name) {int err =lookup_one_common (idmap, name, parent);@@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(start_creating);* * Returns: a positive dentry, or an error. */ -struct dentry *start_removing (struct mnt_idmap *idmap,struct dentry *parent, +struct dentry *start_removing (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name) {int err =lookup_one_common (idmap, name, parent);@@ -3451,7 +3451,7 @@ EXPORT_SYMBOL(start_removing);* * Returns: a negative or positive dentry, or an error. */ -struct dentry *start_creating_killable (struct mnt_idmap *idmap, +struct dentry *start_creating_killable (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name) {@@ -3482,7 +3482,7 @@ EXPORT_SYMBOL(start_creating_killable);* * Returns: a positive dentry, or an error. */ -struct dentry *start_removing_killable (struct mnt_idmap *idmap, +struct dentry *start_removing_killable (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name) {@@ -3642,7 +3642,7 @@ int user_path_at(int dfd, const char __user *name, unsigned flags, }EXPORT_SYMBOL (user_path_at); -int __check_sticky (struct mnt_idmap *idmap,struct inode *dir, +int __check_sticky (const struct mnt_idmap *idmap,struct inode *dir,struct inode *inode) {kuid_t fsuid =current_fsuid ();@@ -3675,7 +3675,7 @@ EXPORT_SYMBOL(__check_sticky);* 11. We don't allow removal of NFS sillyrenamed files; it's handled by * nfs_async_unlink(). */ -int may_delete_dentry (struct mnt_idmap *idmap,struct inode *dir, +int may_delete_dentry (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *victim,bool isdir) {struct inode *inode =d_backing_inode (victim);@@ -3728,7 +3728,7 @@ EXPORT_SYMBOL(may_delete_dentry);* 4. We should have write and exec permissions on dir * 5. We can't do it if dir is immutable (done in permission()) */ -int may_create_dentry (struct mnt_idmap *idmap, +int may_create_dentry (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *child) {audit_inode_child (dir, child,AUDIT_TYPE_CHILD_CREATE );@@ -4174,7 +4174,7 @@ static inline umode_t vfs_prepare_mode(const struct mnt_idmap *idmap,* On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply pass @nop_mnt_idmap. */ -int vfs_create (struct mnt_idmap *idmap,struct dentry *dentry,umode_t mode, +int vfs_create (const struct mnt_idmap *idmap,struct dentry *dentry,umode_t mode,struct delegated_inode *di) {struct inode *dir =d_inode (dentry->d_parent);@@ -4287,7 +4287,7 @@ static int may_open(const struct mnt_idmap *idmap, const struct path *path,return 0 ; } -static int handle_truncate (struct mnt_idmap *idmap,struct file *filp) +static int handle_truncate (const struct mnt_idmap *idmap,struct file *filp) {const struct path *path = &filp->f_path;struct inode *inode = path->dentry->d_inode;@@ -4863,7 +4863,7 @@ static int do_open(struct nameidata *nd,* On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply pass @nop_mnt_idmap. */ -int vfs_tmpfile (struct mnt_idmap *idmap, +int vfs_tmpfile (const struct mnt_idmap *idmap,const struct path *parentpath,struct file *file,umode_t mode) {@@ -4921,7 +4921,7 @@ int vfs_tmpfile(struct mnt_idmap *idmap,* hence this is only for kernel internal use, and must not be installed into * file tables or such. */ -struct file *kernel_tmpfile_open (struct mnt_idmap *idmap, +struct file *kernel_tmpfile_open (const struct mnt_idmap *idmap,const struct path *parentpath,umode_t mode,int open_flag,const struct cred *cred)@@ -5236,7 +5236,7 @@ EXPORT_SYMBOL(dentry_create);* On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply pass @nop_mnt_idmap. */ -int vfs_mknod (struct mnt_idmap *idmap,struct inode *dir, +int vfs_mknod (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode,dev_t dev,struct delegated_inode *delegated_inode) {@@ -5378,7 +5378,7 @@ SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsigned, d* * In case of an error the dentry is dput() and an ERR_PTR() is returned. */ -struct dentry *vfs_mkdir (struct mnt_idmap *idmap,struct inode *dir, +struct dentry *vfs_mkdir (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,umode_t mode,struct delegated_inode *delegated_inode) {@@ -5485,7 +5485,7 @@ SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)* On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply pass @nop_mnt_idmap. */ -int vfs_rmdir (struct mnt_idmap *idmap,struct inode *dir, +int vfs_rmdir (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,struct delegated_inode *delegated_inode) {int error =may_delete_dentry (idmap, dir, dentry, true);@@ -5620,7 +5620,7 @@ SYSCALL_DEFINE1(rmdir, const char __user *, pathname)* On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply pass @nop_mnt_idmap. */ -int vfs_unlink (struct mnt_idmap *idmap,struct inode *dir, +int vfs_unlink (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,struct delegated_inode *delegated_inode) {struct inode *target = dentry->d_inode;@@ -5770,7 +5770,7 @@ SYSCALL_DEFINE1(unlink, const char __user *, pathname)* On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply pass @nop_mnt_idmap. */ -int vfs_symlink (struct mnt_idmap *idmap,struct inode *dir, +int vfs_symlink (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry,const char *oldname,struct delegated_inode *delegated_inode) {@@ -5872,7 +5872,7 @@ SYSCALL_DEFINE2(symlink, const char __user *, oldname, const char __user *, newn* On non-idmapped mounts or if permission checking is to be performed on the * raw inode simply pass @nop_mnt_idmap. */ -int vfs_link (struct dentry *old_dentry,struct mnt_idmap *idmap, +int vfs_link (struct dentry *old_dentry,const struct mnt_idmap *idmap,struct inode *dir,struct dentry *new_dentry,struct delegated_inode *delegated_inode) {fs/open.c +1
-1@@ -36,7 +36,7 @@#include "internal.h" -int do_truncate (struct mnt_idmap *idmap,struct dentry *dentry, +int do_truncate (const struct mnt_idmap *idmap,struct dentry *dentry,loff_t length,unsigned int time_attrs,struct file *filp) {int ret;include/linux/fs.h +15
-15@@ -1761,19 +1761,19 @@ bool inode_owner_or_capable(const struct mnt_idmap *idmap,/* * VFS helper functions.. */ -int vfs_create (struct mnt_idmap *,struct dentry *,umode_t , +int vfs_create (const struct mnt_idmap *,struct dentry *,umode_t ,struct delegated_inode *); -struct dentry *vfs_mkdir (struct mnt_idmap *,struct inode *, +struct dentry *vfs_mkdir (const struct mnt_idmap *,struct inode *,struct dentry *,umode_t ,struct delegated_inode *); -int vfs_mknod (struct mnt_idmap *,struct inode *,struct dentry *, +int vfs_mknod (const struct mnt_idmap *,struct inode *,struct dentry *,umode_t ,dev_t ,struct delegated_inode *); -int vfs_symlink (struct mnt_idmap *,struct inode *, +int vfs_symlink (const struct mnt_idmap *,struct inode *,struct dentry *,const char *,struct delegated_inode *); -int vfs_link (struct dentry *,struct mnt_idmap *,struct inode *, +int vfs_link (struct dentry *,const struct mnt_idmap *,struct inode *,struct dentry *,struct delegated_inode *); -int vfs_rmdir (struct mnt_idmap *,struct inode *,struct dentry *, +int vfs_rmdir (const struct mnt_idmap *,struct inode *,struct dentry *,struct delegated_inode *); -int vfs_unlink (struct mnt_idmap *,struct inode *,struct dentry *, +int vfs_unlink (const struct mnt_idmap *,struct inode *,struct dentry *,struct delegated_inode *);/** @@ -1787,7 +1787,7 @@ int vfs_unlink(struct mnt_idmap *, struct inode *, struct dentry *,* @flags: rename flags */ struct renamedata { -struct mnt_idmap *mnt_idmap; +const struct mnt_idmap *mnt_idmap;struct dentry *old_parent;struct dentry *old_dentry;struct dentry *new_parent;@@ -1798,14 +1798,14 @@ struct renamedata {int vfs_rename (struct renamedata *); -static inline int vfs_whiteout (struct mnt_idmap *idmap, +static inline int vfs_whiteout (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *dentry) {return vfs_mknod (idmap, dir, dentry,S_IFCHR |WHITEOUT_MODE ,WHITEOUT_DEV ,NULL ); } -struct file *kernel_tmpfile_open (struct mnt_idmap *idmap, +struct file *kernel_tmpfile_open (const struct mnt_idmap *idmap,const struct path *parentpath,umode_t mode,int open_flag,const struct cred *cred);@@ -2483,7 +2483,7 @@ static inline bool is_idmapped_mnt(const struct vfsmount *mnt) }int vfs_truncate (const struct path *,loff_t ); -int do_truncate (struct mnt_idmap *,struct dentry *,loff_t start, +int do_truncate (const struct mnt_idmap *,struct dentry *,loff_t start,unsigned int time_attrs,struct file *filp);extern int vfs_fallocate (struct file *file,int mode,loff_t offset,loff_t len);@@ -2721,12 +2721,12 @@ static inline int path_permission(const struct path *path, int mask)return inode_permission (mnt_idmap (path->mnt),d_inode (path->dentry), mask); } -int __check_sticky (struct mnt_idmap *idmap,struct inode *dir, +int __check_sticky (const struct mnt_idmap *idmap,struct inode *dir,struct inode *inode); -int may_delete_dentry (struct mnt_idmap *idmap,struct inode *dir, +int may_delete_dentry (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *victim,bool isdir); -int may_create_dentry (struct mnt_idmap *idmap, +int may_create_dentry (const struct mnt_idmap *idmap,struct inode *dir,struct dentry *child);static inline bool execute_ok (struct inode *inode)@@ -3578,7 +3578,7 @@ static inline bool is_sxid(umode_t mode)return mode & (S_ISUID |S_ISGID ); } -static inline int check_sticky (struct mnt_idmap *idmap, +static inline int check_sticky (const struct mnt_idmap *idmap,struct inode *dir,struct inode *inode) {if (!(dir->i_mode &S_ISVTX ))include/linux/namei.h +8
-8@@ -70,24 +70,24 @@ extern struct dentry *try_lookup_noperm(struct qstr *, struct dentry *);extern struct dentry *lookup_noperm (struct qstr *,struct dentry *);extern struct dentry *lookup_noperm_unlocked (struct qstr *,struct dentry *);extern struct dentry *lookup_noperm_positive_unlocked (struct qstr *,struct dentry *); -struct dentry *lookup_one (struct mnt_idmap *,struct qstr *,struct dentry *); -struct dentry *lookup_one_unlocked (struct mnt_idmap *idmap, +struct dentry *lookup_one (const struct mnt_idmap *,struct qstr *,struct dentry *); +struct dentry *lookup_one_unlocked (const struct mnt_idmap *idmap,struct qstr *name,struct dentry *base); -struct dentry *lookup_one_positive_unlocked (struct mnt_idmap *idmap, +struct dentry *lookup_one_positive_unlocked (const struct mnt_idmap *idmap,struct qstr *name,struct dentry *base); -struct dentry *lookup_one_positive_killable (struct mnt_idmap *idmap, +struct dentry *lookup_one_positive_killable (const struct mnt_idmap *idmap,struct qstr *name,struct dentry *base); -struct dentry *start_creating (struct mnt_idmap *idmap,struct dentry *parent, +struct dentry *start_creating (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name); -struct dentry *start_removing (struct mnt_idmap *idmap,struct dentry *parent, +struct dentry *start_removing (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name); -struct dentry *start_creating_killable (struct mnt_idmap *idmap, +struct dentry *start_creating_killable (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name); -struct dentry *start_removing_killable (struct mnt_idmap *idmap, +struct dentry *start_removing_killable (const struct mnt_idmap *idmap,struct dentry *parent,struct qstr *name);struct dentry *start_creating_noperm (struct dentry *parent,struct qstr *name);Signature · 2 lines
-- 2.53.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Christian Brauner
maintainerPATCH 26/27 fs: port mnt_idmap() and file_mnt_idmap() to const mnt_idmap
In reply to Christian BraunerNow that everything takes a mnt_idmap as const store a const pointer in struct vfsmount, struct mount_kattr and struct kstatmount and return one from mnt_idmap(), file_mnt_idmap() and ovl_upper_mnt_idmap(). Finally, also make mnt_idmap_get() return a const pointer. Also convert the remaining local variables that are initialized from the accessors.
alloc_mnt_idmap() keeps returning a non-const pointer. It is the only place where an idmapping is actually written to.
--- Documentation/filesystems/porting.rst | 13 +++++++++++++ fs/backing-file.c | 2 +- fs/btrfs/ioctl.c | 4 ++-- fs/ceph/file.c | 2 +- fs/coredump.c | 2 +- fs/exec.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/f2fs/file.c | 6 +++--- fs/fhandle.c | 2 +- fs/file_attr.c | 4 ++-- fs/fuse/dir.c | 2 +- fs/fuse/file.c | 2 +- fs/internal.h | 2 +- fs/mnt_idmapping.c | 4 ++-- fs/namei.c | 14 +++++++------- fs/namespace.c | 8 ++++---- fs/open.c | 4 ++-- fs/overlayfs/file.c | 2 +- fs/overlayfs/inode.c | 2 +- fs/overlayfs/ovl_entry.h | 2 +- fs/overlayfs/util.c | 4 ++-- fs/remap_range.c | 2 +- fs/smb/server/oplock.c | 2 +- fs/smb/server/smb2pdu.c | 20 ++++++++++---------- fs/smb/server/smb_common.c | 2 +- fs/smb/server/smbacl.c | 6 +++--- fs/smb/server/vfs.c | 10 +++++----- fs/stat.c | 2 +- include/linux/fs.h | 2 +- include/linux/mnt_idmapping.h | 2 +- include/linux/mount.h | 4 ++-- net/unix/af_unix.c | 2 +- security/apparmor/lsm.c | 4 ++-- 33 files changed, 79 insertions(+), 66 deletions(-)
Documentation/filesystems/porting.rst +13 -0
@@ -1409,3 +1409,16 @@ use only if you have no alternative. The .create inode_operation no longer receives the 'excl' arg. It must always assume the file does not already exist. If the filesystem needs to be involved in non-exclusive create, it should provide atomic_open. + +--- + +**mandatory** + +All struct mnt_idmap pointers handed to filesystems are const now. +->create(), ->mkdir(), ->mknod(), ->symlink(), ->rename(), ->setattr(), +->getattr(), ->permission(), ->tmpfile(), ->get_acl(), ->set_acl() and +->fileattr_set() as well as the xattr ->set() handler and the vfs_*() +helpers take a const struct mnt_idmap *. mnt_idmap() and file_mnt_idmap() +return one. The idmapping is immutable so nothing should have modified it +anyway. References are taken and dropped via mnt_idmap_get() and +mnt_idmap_put() as before, both accept a const pointer.
fs/backing-file.c +1 -1
@@ -59,7 +59,7 @@ struct file *backing_tmpfile_open(const struct file *user_file, int flags,const struct path *real_parentpath, umode_t mode, const struct cred *cred) { - struct mnt_idmap *real_idmap = mnt_idmap(real_parentpath->mnt); + const struct mnt_idmap *real_idmap = mnt_idmap(real_parentpath->mnt);const struct path *user_path = &user_file->f_path;struct file *f;int error;
fs/btrfs/ioctl.c +2 -2
@@ -1149,7 +1149,7 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file, {int ret;struct qstr qname =QSTR (name); -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);if (!S_ISDIR (file_inode (file)->i_mode))return -ENOTDIR ;
@@ -2226,7 +2226,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,struct btrfs_root *dest =NULL ;struct btrfs_ioctl_vol_args AUTO_KFREE (vol_args );struct btrfs_ioctl_vol_args_v2 AUTO_KFREE (vol_args2 ); -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);char *subvol_name, *subvol_name_ptr =NULL ;int ret =0 ;bool destroy_parent = false;
fs/ceph/file.c +1 -1
@@ -795,7 +795,7 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode,int ceph_atomic_open (struct inode *dir,struct dentry *dentry,struct file *file,unsigned flags,umode_t mode) { -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct ceph_fs_client *fsc =ceph_sb_to_fs_client (dir->i_sb);struct ceph_client *cl = fsc->client;struct ceph_mds_client *mdsc = fsc->mdsc;
fs/coredump.c +1 -1
@@ -878,7 +878,7 @@ static inline bool coredump_force_suid_safe(const struct coredump_params *cprm)static bool coredump_file (struct core_name *cn,struct coredump_params *cprm,const struct linux_binfmt *binfmt) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct inode *inode; struct file *file __free(fput) = NULL;int open_flags =O_CREAT |O_WRONLY |O_NOFOLLOW |O_LARGEFILE |O_EXCL ;
fs/exec.c +2 -2
@@ -1339,7 +1339,7 @@ EXPORT_SYMBOL(begin_new_exec);void would_dump (struct linux_binprm *bprm,struct file *file) {struct inode *inode =file_inode (file); -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);if (inode_permission (idmap, inode,MAY_READ ) <0 ) {struct user_namespace *old, *user_ns; bprm->interp_flags |=BINPRM_FLAGS_ENFORCE_NONDUMP ;
@@ -1623,7 +1623,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)static void bprm_fill_uid (struct linux_binprm *bprm,struct file *file) {/* Handle suid and sgid on files */ -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct inode *inode =file_inode (file);unsigned int mode;vfsuid_t vfsuid;
fs/ext4/ioctl.c +1 -1
@@ -1539,7 +1539,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 mnt_idmap *idmap =file_mnt_idmap (filp); +const struct mnt_idmap *idmap =file_mnt_idmap (filp);ext4_debug ("cmd = %u, arg = %lu\n" , cmd, arg);
fs/f2fs/file.c +3 -3
@@ -2361,7 +2361,7 @@ static int f2fs_ioc_getversion(struct file *filp, unsigned long arg)static int f2fs_ioc_start_atomic_write (struct file *filp,bool truncate) {struct inode *inode =file_inode (filp); -struct mnt_idmap *idmap =file_mnt_idmap (filp); +const struct mnt_idmap *idmap =file_mnt_idmap (filp);struct f2fs_inode_info *fi =F2FS_I (inode);struct f2fs_sb_info *sbi =F2FS_I_SB (inode);loff_t isize;
@@ -2473,7 +2473,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)static int f2fs_ioc_commit_atomic_write (struct file *filp) {struct inode *inode =file_inode (filp); -struct mnt_idmap *idmap =file_mnt_idmap (filp); +const struct mnt_idmap *idmap =file_mnt_idmap (filp);int ret;if (!(filp->f_mode &FMODE_WRITE ))
@@ -2508,7 +2508,7 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp)static int f2fs_ioc_abort_atomic_write (struct file *filp) {struct inode *inode =file_inode (filp); -struct mnt_idmap *idmap =file_mnt_idmap (filp); +const struct mnt_idmap *idmap =file_mnt_idmap (filp);int ret;if (!(filp->f_mode &FMODE_WRITE ))
fs/fhandle.c +1 -1
@@ -201,7 +201,7 @@ static int vfs_dentry_acceptable(void *context, struct dentry *dentry)struct handle_to_path_ctx *ctx = context;struct user_namespace *user_ns =current_user_ns ();struct dentry *d, *root = ctx->root.dentry; -struct mnt_idmap *idmap =mnt_idmap (ctx->root.mnt); +const struct mnt_idmap *idmap =mnt_idmap (ctx->root.mnt);int retval =0 ;if (!root)
fs/file_attr.c +2 -2
@@ -323,7 +323,7 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)int ioctl_setflags (struct file *file,unsigned int __user *argp) { -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct dentry *dentry = file->f_path.dentry;struct file_kattr fa = {};unsigned int flags;
@@ -355,7 +355,7 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)int ioctl_fssetxattr (struct file *file,void __user *argp) { -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct dentry *dentry = file->f_path.dentry;struct file_kattr fa = {};int err;
fs/fuse/dir.c +1 -1
@@ -941,7 +941,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry, umode_t mode) {int err; -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct fuse_conn *fc =get_fuse_conn (dir);if (fuse_is_bad (dir))
fs/fuse/file.c +1 -1
@@ -1487,7 +1487,7 @@ static const struct iomap_write_ops fuse_iomap_write_ops = {static ssize_t fuse_cache_write_iter (struct kiocb *iocb,struct iov_iter *from) {struct file *file = iocb->ki_filp; -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct address_space *mapping = file->f_mapping;ssize_t written =0 ;struct inode *inode = mapping->host;
fs/internal.h +1 -1
@@ -327,7 +327,7 @@ ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *po* fs/attr.c */ struct mnt_idmap *alloc_mnt_idmap (struct user_namespace *mnt_userns); -struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap); +const struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap);void mnt_idmap_put (const struct mnt_idmap *idmap);struct stashed_operations { struct dentry *(*stash_dentry)(struct dentry **stashed,
fs/mnt_idmapping.c +2 -2
@@ -312,14 +312,14 @@ struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns)* * Return: @idmap with reference count bumped if @not_mnt_idmap isn't passed. */ -struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap) +const struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap) {struct mnt_idmap *nonconst_idmap = (struct mnt_idmap *)idmap;if (idmap != &nop_mnt_idmap && idmap != &invalid_mnt_idmap)refcount_inc (&nonconst_idmap->count); -return nonconst_idmap; +return idmap; }EXPORT_SYMBOL_GPL (mnt_idmap_get);
fs/namei.c +7 -7
@@ -1273,7 +1273,7 @@ fs_initcall(init_fs_namei_sysctls);*/ static inline int may_follow_link (struct nameidata *nd,const struct inode *inode) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;vfsuid_t vfsuid;if (!sysctl_protected_symlinks)
@@ -2596,7 +2596,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)/* At this point we know we have a real path component. */ for (;;) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;const char *link;unsigned long lastword;
@@ -4432,7 +4432,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, const struct open_flags *op) {struct delegated_inode delegated_inode = { }; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct dentry *dir = nd->path.dentry;struct inode *dir_inode = dir->d_inode;int open_flag;
@@ -4789,7 +4789,7 @@ static const char *open_last_lookups(struct nameidata *nd,static int do_open (struct nameidata *nd,struct file *file,const struct open_flags *op) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;int open_flag = op->open_flag;bool do_truncate;int acc_mode;
@@ -5169,7 +5169,7 @@ struct file *dentry_create(struct path *path, int flags, umode_t mode,struct dentry *orig_dentry = dentry;struct dentry *dir = dentry->d_parent;struct inode *dir_inode =d_inode (dir); -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;int error, create_error; file =alloc_empty_file (flags, cred);
@@ -5294,7 +5294,7 @@ int filename_mknodat(int dfd, struct filename *name, umode_t mode, unsigned int dev) {struct delegated_inode di = { }; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct dentry *dentry;struct path path;int error;
@@ -5949,7 +5949,7 @@ EXPORT_SYMBOL(vfs_link);int filename_linkat (int olddfd,struct filename *old,int newdfd,struct filename *new,int flags) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct dentry *new_dentry;struct path old_path, new_path;struct delegated_inode delegated_inode = { };
fs/namespace.c +4 -4
@@ -109,7 +109,7 @@ struct mount_kattr {unsigned int lookup_flags;enum mount_kattr_flags_t kflags;struct user_namespace *mnt_userns; -struct mnt_idmap *mnt_idmap; +const struct mnt_idmap *mnt_idmap; };/* /sys/fs */
@@ -4898,7 +4898,7 @@ static int mount_setattr_prepare(struct mount_kattr *kattr, struct mount *mnt)static void do_idmap_mount (const struct mount_kattr *kattr,struct mount *mnt) { -struct mnt_idmap *old_idmap; +const struct mnt_idmap *old_idmap;if (!kattr->mnt_idmap)return ;
@@ -4941,7 +4941,7 @@ static int do_mount_setattr(const struct path *path, struct mount_kattr *kattr)return -EINVAL ;if (kattr->mnt_userns) { -struct mnt_idmap *mnt_idmap; +const struct mnt_idmap *mnt_idmap; mnt_idmap =alloc_mnt_idmap (kattr->mnt_userns);if (IS_ERR (mnt_idmap))
@@ -5246,7 +5246,7 @@ struct kstatmount {struct statmount __user *buf;size_t bufsize;struct vfsmount *mnt; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;u64 mask;struct path root;struct seq_file seq;
fs/open.c +2 -2
@@ -72,7 +72,7 @@ int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,int vfs_truncate (const struct path *path,loff_t length) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct inode *inode;int error;
@@ -787,7 +787,7 @@ static inline bool setattr_vfsgid(struct iattr *attr, kgid_t kgid)int chown_common (const struct path *path,uid_t user,gid_t group) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct user_namespace *fs_userns;struct inode *inode = path->dentry->d_inode;struct delegated_inode delegated_inode = { };
fs/overlayfs/file.c +1 -1
@@ -30,7 +30,7 @@ static struct file *ovl_open_realfile(const struct file *file, {struct inode *realinode =d_inode (realpath->dentry);struct inode *inode =file_inode (file); -struct mnt_idmap *real_idmap; +const struct mnt_idmap *real_idmap;struct file *realfile;int flags = file->f_flags |OVL_OPEN_FLAGS ;int acc_mode =ACC_MODE (flags);
fs/overlayfs/inode.c +1 -1
@@ -406,7 +406,7 @@ struct posix_acl *ovl_get_acl_path(const struct path *path, const char *acl_name, bool noperm) {struct posix_acl *real_acl, *clone; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct inode *realinode =d_inode (path->dentry); idmap =mnt_idmap (path->mnt);
fs/overlayfs/ovl_entry.h +1 -1
@@ -105,7 +105,7 @@ static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)return ofs->layers[0 ].mnt; } -static inline struct mnt_idmap *ovl_upper_mnt_idmap (struct ovl_fs *ofs) +static inline const struct mnt_idmap *ovl_upper_mnt_idmap (struct ovl_fs *ofs) {return mnt_idmap (ovl_upper_mnt (ofs)); }
fs/overlayfs/util.c +2 -2
@@ -657,7 +657,7 @@ bool ovl_path_is_whiteout(struct ovl_fs *ofs, const struct path *path)struct file *ovl_path_open (const struct path *path,int flags) {struct inode *inode =d_inode (path->dentry); -struct mnt_idmap *real_idmap =mnt_idmap (path->mnt); +const struct mnt_idmap *real_idmap =mnt_idmap (path->mnt);int err, acc_mode;if (flags & ~(O_ACCMODE |O_LARGEFILE ))
@@ -1496,7 +1496,7 @@ void ovl_copyattr(struct inode *inode) {struct path realpath;struct inode *realinode; -struct mnt_idmap *real_idmap; +const struct mnt_idmap *real_idmap;vfsuid_t vfsuid;vfsgid_t vfsgid;
fs/remap_range.c +1 -1
@@ -415,7 +415,7 @@ EXPORT_SYMBOL(vfs_clone_file_range);/* Check whether we are allowed to dedupe the destination file */ static bool may_dedupe_file (struct file *file) { -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct inode *inode =file_inode (file);if (capable (CAP_SYS_ADMIN ))
fs/smb/server/oplock.c +1 -1
@@ -2229,7 +2229,7 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp) {struct create_posix_rsp *buf;struct inode *inode =file_inode (fp->filp); -struct mnt_idmap *idmap =file_mnt_idmap (fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);vfsuid_t vfsuid =i_uid_into_vfsuid (idmap, inode);vfsgid_t vfsgid =i_gid_into_vfsgid (idmap, inode);
fs/smb/server/smb2pdu.c +10 -10
@@ -3234,7 +3234,7 @@ static bool smb2_is_private_ea(const char *name, size_t name_len)static int smb2_set_ea (struct smb2_ea_info *eabuf,unsigned int buf_len,const struct path *path,bool get_write) { -struct mnt_idmap *idmap =mnt_idmap (path->mnt); +const struct mnt_idmap *idmap =mnt_idmap (path->mnt);char *attr_name =NULL , *value;int rc =0 ;unsigned int next =0 ;
@@ -3335,7 +3335,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,struct ksmbd_file *fp, char *stream_name, int s_type) { - struct mnt_idmap *idmap = mnt_idmap(path->mnt); + const struct mnt_idmap *idmap = mnt_idmap(path->mnt);size_t xattr_stream_size;char *xattr_stream_name;int rc;
@@ -3411,7 +3411,7 @@ static loff_t ksmbd_stream_eof(struct ksmbd_file *fp)static int smb2_remove_smb_xattrs (const struct path *path) { -struct mnt_idmap *idmap =mnt_idmap (path->mnt); +const struct mnt_idmap *idmap =mnt_idmap (path->mnt);char *name, *xattr_list =NULL ;ssize_t xattr_list_len;int err =0 ;
@@ -4088,7 +4088,7 @@ int smb2_open(struct ksmbd_work *work)struct ksmbd_share_config *share = tcon->share_conf;struct ksmbd_file *fp =NULL ;struct file *filp =NULL ; -struct mnt_idmap *idmap =NULL ; +const struct mnt_idmap *idmap =NULL ;struct kstat stat;struct create_context *context;struct lease_ctx_info *lc =NULL ;
@@ -5753,7 +5753,7 @@ struct smb2_query_dir_private {static int process_query_dir_entries (struct smb2_query_dir_private *priv) { -struct mnt_idmap *idmap =file_mnt_idmap (priv->dir_fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (priv->dir_fp->filp);struct kstat kstat;struct ksmbd_kstat ksmbd_kstat;int rc;
@@ -6352,7 +6352,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,ssize_t buf_free_len, alignment_bytes, next_offset, rsp_data_cnt =0 ;struct smb2_ea_info_req *ea_req =NULL ;const struct path *path; -struct mnt_idmap *idmap =file_mnt_idmap (fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);if (!(fp->daccess &FILE_READ_EA_LE )) { pr_err("Not permitted to read ext attr : 0x%x\n",
@@ -7062,7 +7062,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp, {struct smb311_posix_qinfo *file_info;struct inode *inode =file_inode (fp->filp); -struct mnt_idmap *idmap =file_mnt_idmap (fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);vfsuid_t vfsuid =i_uid_into_vfsuid (idmap, inode);vfsgid_t vfsgid =i_gid_into_vfsgid (idmap, inode);struct kstat stat;
@@ -7547,7 +7547,7 @@ static int smb2_get_info_sec(struct ksmbd_work *work, struct smb2_query_info_rsp *rsp) {struct ksmbd_file *fp; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct smb_ntsd *pntsd =NULL , *ppntsd =NULL ;struct smb_fattr fattr = {{0 }};struct inode *inode;
@@ -8060,7 +8060,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,struct iattr attrs;struct file *filp;struct inode *inode; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;__le32 attrs_mask =FILE_ATTRIBUTE_DIRECTORY_LE |FILE_ATTRIBUTE_COMPRESSED_LE ;int rc =0 ;
@@ -10652,7 +10652,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id, struct file_sparse *sparse) {struct ksmbd_file *fp; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;int ret =0 ;__le32 old_fattr;
fs/smb/server/smb_common.c +1 -1
@@ -467,7 +467,7 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level, {int i, rc =0 ;struct ksmbd_conn *conn = work->conn; -struct mnt_idmap *idmap =file_mnt_idmap (dir->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (dir->filp);for (i =0 ; i <2 ; i++) {struct kstat kstat;
fs/smb/server/smbacl.c +3 -3
@@ -1183,7 +1183,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,struct smb_ntsd *parent_pntsd =NULL ;struct smb_sid owner_sid, group_sid;struct dentry *parent = path->dentry->d_parent; -struct mnt_idmap *idmap =mnt_idmap (path->mnt); +const struct mnt_idmap *idmap =mnt_idmap (path->mnt);int inherited_flags =0 , flags =0 , i, nt_size =0 , pdacl_size;int rc =0 , pntsd_type, ppntsd_size, acl_len, aces_size;unsigned int dacloffset;
@@ -1438,7 +1438,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, __le32 *pdaccess, __le32 raw_daccess, int uid, bool strict) { - struct mnt_idmap *idmap = mnt_idmap(path->mnt); + const struct mnt_idmap *idmap = mnt_idmap(path->mnt);struct smb_ntsd *pntsd =NULL ;struct smb_acl *pdacl;struct posix_acl *posix_acls;
@@ -1660,7 +1660,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,int rc;struct smb_fattr fattr = {{0 }};struct inode *inode =d_inode (path->dentry); -struct mnt_idmap *idmap =mnt_idmap (path->mnt); +const struct mnt_idmap *idmap =mnt_idmap (path->mnt);struct iattr newattrs; fattr.cf_uid =INVALID_UID ;
fs/smb/server/vfs.c +5 -5
@@ -183,7 +183,7 @@ int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode)*/ int ksmbd_vfs_mkdir (struct ksmbd_work *work,const char *name,umode_t mode) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct path path;struct dentry *dentry, *d;int err =0 ;
@@ -386,7 +386,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos, {const struct cred *saved_cred;char *stream_buf =NULL , *wbuf; -struct mnt_idmap *idmap =file_mnt_idmap (fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);size_t size;ssize_t v_len;int err =0 ;
@@ -577,7 +577,7 @@ int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id)*/ int ksmbd_vfs_remove_file (struct ksmbd_work *work,const struct path *path) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct dentry *parent = path->dentry->d_parent;int err;
@@ -1202,7 +1202,7 @@ int ksmbd_vfs_unlink(struct file *filp)const struct cred *saved_cred;int err =0 ;struct dentry *dir, *dentry = filp->f_path.dentry; -struct mnt_idmap *idmap =file_mnt_idmap (filp); +const struct mnt_idmap *idmap =file_mnt_idmap (filp); saved_cred =override_creds (filp->f_cred); err =mnt_want_write (filp->f_path.mnt);
@@ -2316,7 +2316,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,const struct cred *saved_cred =NULL ;struct file_kattr fa;struct dentry *dentry = fp->filp->f_path.dentry; -struct mnt_idmap *idmap =file_mnt_idmap (fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);u32 flags;__le32 old_fattr;int rc;
fs/stat.c +1 -1
@@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(generic_fill_statx_atomic_writes);int vfs_getattr_nosec (const struct path *path,struct kstat *stat,u32 request_mask,unsigned int query_flags) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct inode *inode =d_backing_inode (path->dentry);memset (stat,0 ,sizeof (*stat));
include/linux/fs.h +1 -1
@@ -2459,7 +2459,7 @@ struct filename {static_assert (offsetof(struct filename , iname) %sizeof (long ) ==0 );static_assert (sizeof (struct filename ) %64 ==0 ); -static inline struct mnt_idmap *file_mnt_idmap (const struct file *file) +static inline const struct mnt_idmap *file_mnt_idmap (const struct file *file) {return mnt_idmap (file->f_path.mnt); }
include/linux/mnt_idmapping.h +1 -1
@@ -121,7 +121,7 @@ static inline bool vfsgid_eq_kgid(vfsgid_t vfsgid, kgid_t kgid)int vfsgid_in_group_p (vfsgid_t vfsgid); -struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap); +const struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap);void mnt_idmap_put (const struct mnt_idmap *idmap); vfsuid_t make_vfsuid(const struct mnt_idmap *idmap,
include/linux/mount.h +2 -2
@@ -59,10 +59,10 @@ struct vfsmount {struct dentry *mnt_root;/* root of the mounted tree */ struct super_block *mnt_sb;/* pointer to superblock */ int mnt_flags; -struct mnt_idmap *mnt_idmap; +const struct mnt_idmap *mnt_idmap; } __randomize_layout; -static inline struct mnt_idmap *mnt_idmap (const struct vfsmount *mnt) +static inline const struct mnt_idmap *mnt_idmap (const struct vfsmount *mnt) {/* Pairs with smp_store_release() in do_idmap_mount(). */ return READ_ONCE (mnt->mnt_idmap);
net/unix/af_unix.c +1 -1
@@ -1361,7 +1361,7 @@ static int unix_bind_bsd(struct sock *sk, struct sockaddr_un *sunaddr,struct unix_sock *u =unix_sk (sk);unsigned int new_hash, old_hash;struct net *net =sock_net (sk); -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct unix_address *addr;struct dentry *dentry;struct path parent;
security/apparmor/lsm.c +2 -2
@@ -397,7 +397,7 @@ static int apparmor_path_rename(const struct path *old_dir, struct dentry *old_d label =begin_current_label_crit_section (&needput);if (!unconfined (label)) { -struct mnt_idmap *idmap =mnt_idmap (old_dir->mnt); +const struct mnt_idmap *idmap =mnt_idmap (old_dir->mnt);vfsuid_t vfsuid;struct path old_path = { .mnt = old_dir->mnt, .dentry = old_dentry };
@@ -485,7 +485,7 @@ static int apparmor_file_open(struct file *file) label =aa_get_newest_cred_label_condref (file->f_cred, &needput);if (!unconfined (label)) { -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct inode *inode =file_inode (file);vfsuid_t vfsuid;struct path_cond cond = {
Signature · 1 line
2.53.0
Re: [PATCH 26/27] fs: port mnt_idmap() and file_mnt_idmap() to const mnt_idmap
Quoted 10 lines · Christian Brauner
Now that everything takes a
mnt_idmapas const store a const pointer in struct vfsmount, structmount_kattrand struct kstatmount and return one frommnt_idmap(),file_mnt_idmap()andovl_upper_mnt_idmap(). Finally, also makemnt_idmap_get()return a const pointer. Also convert the remaining local variables that are initialized from the accessors.
alloc_mnt_idmap()keeps returning a non-const pointer. It is the only place where an idmapping is actually written to.Signed-off-by Christian Brauner (Amutable) <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 777 lines
--- Documentation/filesystems/porting.rst | 13 +++++++++++++ fs/backing-file.c | 2 +- fs/btrfs/ioctl.c | 4 ++-- fs/ceph/file.c | 2 +- fs/coredump.c | 2 +- fs/exec.c | 4 ++-- fs/ext4/ioctl.c | 2 +- fs/f2fs/file.c | 6 +++--- fs/fhandle.c | 2 +- fs/file_attr.c | 4 ++-- fs/fuse/dir.c | 2 +- fs/fuse/file.c | 2 +- fs/internal.h | 2 +- fs/mnt_idmapping.c | 4 ++-- fs/namei.c | 14 +++++++------- fs/namespace.c | 8 ++++---- fs/open.c | 4 ++-- fs/overlayfs/file.c | 2 +- fs/overlayfs/inode.c | 2 +- fs/overlayfs/ovl_entry.h | 2 +- fs/overlayfs/util.c | 4 ++-- fs/remap_range.c | 2 +- fs/smb/server/oplock.c | 2 +- fs/smb/server/smb2pdu.c | 20 ++++++++++---------- fs/smb/server/smb_common.c | 2 +- fs/smb/server/smbacl.c | 6 +++--- fs/smb/server/vfs.c | 10 +++++----- fs/stat.c | 2 +- include/linux/fs.h | 2 +- include/linux/mnt_idmapping.h | 2 +- include/linux/mount.h | 4 ++-- net/unix/af_unix.c | 2 +- security/apparmor/lsm.c | 4 ++-- 33 files changed, 79 insertions(+), 66 deletions(-)Documentation/filesystems/porting.rst +13
-0@@ -1409,3 +1409,16 @@ use only if you have no alternative. The .create inode_operation no longer receives the 'excl' arg. It must always assume the file does not already exist. If the filesystem needs to be involved in non-exclusive create, it should provide atomic_open. + +--- + +**mandatory** + +All struct mnt_idmap pointers handed to filesystems are const now. +->create(), ->mkdir(), ->mknod(), ->symlink(), ->rename(), ->setattr(), +->getattr(), ->permission(), ->tmpfile(), ->get_acl(), ->set_acl() and +->fileattr_set() as well as the xattr ->set() handler and the vfs_*() +helpers take a const struct mnt_idmap *. mnt_idmap() and file_mnt_idmap() +return one. The idmapping is immutable so nothing should have modified it +anyway. References are taken and dropped via mnt_idmap_get() and +mnt_idmap_put() as before, both accept a const pointer.fs/backing-file.c +1
-1@@ -59,7 +59,7 @@ struct file *backing_tmpfile_open(const struct file *user_file, int flags,const struct path *real_parentpath, umode_t mode, const struct cred *cred) { - struct mnt_idmap *real_idmap = mnt_idmap(real_parentpath->mnt); + const struct mnt_idmap *real_idmap = mnt_idmap(real_parentpath->mnt);const struct path *user_path = &user_file->f_path;struct file *f;int error;fs/btrfs/ioctl.c +2
-2@@ -1149,7 +1149,7 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file, {int ret;struct qstr qname =QSTR (name); -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);if (!S_ISDIR (file_inode (file)->i_mode))return -ENOTDIR ;@@ -2226,7 +2226,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,struct btrfs_root *dest =NULL ;struct btrfs_ioctl_vol_args AUTO_KFREE (vol_args );struct btrfs_ioctl_vol_args_v2 AUTO_KFREE (vol_args2 ); -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);char *subvol_name, *subvol_name_ptr =NULL ;int ret =0 ;bool destroy_parent = false;fs/ceph/file.c +1
-1@@ -795,7 +795,7 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode,int ceph_atomic_open (struct inode *dir,struct dentry *dentry,struct file *file,unsigned flags,umode_t mode) { -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct ceph_fs_client *fsc =ceph_sb_to_fs_client (dir->i_sb);struct ceph_client *cl = fsc->client;struct ceph_mds_client *mdsc = fsc->mdsc;fs/coredump.c +1
-1@@ -878,7 +878,7 @@ static inline bool coredump_force_suid_safe(const struct coredump_params *cprm)static bool coredump_file (struct core_name *cn,struct coredump_params *cprm,const struct linux_binfmt *binfmt) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct inode *inode; struct file *file __free(fput) = NULL;int open_flags =O_CREAT |O_WRONLY |O_NOFOLLOW |O_LARGEFILE |O_EXCL ;fs/exec.c +2
-2@@ -1339,7 +1339,7 @@ EXPORT_SYMBOL(begin_new_exec);void would_dump (struct linux_binprm *bprm,struct file *file) {struct inode *inode =file_inode (file); -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);if (inode_permission (idmap, inode,MAY_READ ) <0 ) {struct user_namespace *old, *user_ns; bprm->interp_flags |=BINPRM_FLAGS_ENFORCE_NONDUMP ;@@ -1623,7 +1623,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)static void bprm_fill_uid (struct linux_binprm *bprm,struct file *file) {/* Handle suid and sgid on files */ -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct inode *inode =file_inode (file);unsigned int mode;vfsuid_t vfsuid;fs/ext4/ioctl.c +1
-1@@ -1539,7 +1539,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 mnt_idmap *idmap =file_mnt_idmap (filp); +const struct mnt_idmap *idmap =file_mnt_idmap (filp);ext4_debug ("cmd = %u, arg = %lu\n" , cmd, arg);fs/f2fs/file.c +3
-3@@ -2361,7 +2361,7 @@ static int f2fs_ioc_getversion(struct file *filp, unsigned long arg)static int f2fs_ioc_start_atomic_write (struct file *filp,bool truncate) {struct inode *inode =file_inode (filp); -struct mnt_idmap *idmap =file_mnt_idmap (filp); +const struct mnt_idmap *idmap =file_mnt_idmap (filp);struct f2fs_inode_info *fi =F2FS_I (inode);struct f2fs_sb_info *sbi =F2FS_I_SB (inode);loff_t isize;@@ -2473,7 +2473,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)static int f2fs_ioc_commit_atomic_write (struct file *filp) {struct inode *inode =file_inode (filp); -struct mnt_idmap *idmap =file_mnt_idmap (filp); +const struct mnt_idmap *idmap =file_mnt_idmap (filp);int ret;if (!(filp->f_mode &FMODE_WRITE ))@@ -2508,7 +2508,7 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp)static int f2fs_ioc_abort_atomic_write (struct file *filp) {struct inode *inode =file_inode (filp); -struct mnt_idmap *idmap =file_mnt_idmap (filp); +const struct mnt_idmap *idmap =file_mnt_idmap (filp);int ret;if (!(filp->f_mode &FMODE_WRITE ))fs/fhandle.c +1
-1@@ -201,7 +201,7 @@ static int vfs_dentry_acceptable(void *context, struct dentry *dentry)struct handle_to_path_ctx *ctx = context;struct user_namespace *user_ns =current_user_ns ();struct dentry *d, *root = ctx->root.dentry; -struct mnt_idmap *idmap =mnt_idmap (ctx->root.mnt); +const struct mnt_idmap *idmap =mnt_idmap (ctx->root.mnt);int retval =0 ;if (!root)fs/file_attr.c +2
-2@@ -323,7 +323,7 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)int ioctl_setflags (struct file *file,unsigned int __user *argp) { -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct dentry *dentry = file->f_path.dentry;struct file_kattr fa = {};unsigned int flags;@@ -355,7 +355,7 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)int ioctl_fssetxattr (struct file *file,void __user *argp) { -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct dentry *dentry = file->f_path.dentry;struct file_kattr fa = {};int err;fs/fuse/dir.c +1
-1@@ -941,7 +941,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry, umode_t mode) {int err; -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct fuse_conn *fc =get_fuse_conn (dir);if (fuse_is_bad (dir))fs/fuse/file.c +1
-1@@ -1487,7 +1487,7 @@ static const struct iomap_write_ops fuse_iomap_write_ops = {static ssize_t fuse_cache_write_iter (struct kiocb *iocb,struct iov_iter *from) {struct file *file = iocb->ki_filp; -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct address_space *mapping = file->f_mapping;ssize_t written =0 ;struct inode *inode = mapping->host;fs/internal.h +1
-1@@ -327,7 +327,7 @@ ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *po* fs/attr.c */ struct mnt_idmap *alloc_mnt_idmap (struct user_namespace *mnt_userns); -struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap); +const struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap);void mnt_idmap_put (const struct mnt_idmap *idmap);struct stashed_operations { struct dentry *(*stash_dentry)(struct dentry **stashed,fs/mnt_idmapping.c +2
-2@@ -312,14 +312,14 @@ struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns)* * Return: @idmap with reference count bumped if @not_mnt_idmap isn't passed. */ -struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap) +const struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap) {struct mnt_idmap *nonconst_idmap = (struct mnt_idmap *)idmap;if (idmap != &nop_mnt_idmap && idmap != &invalid_mnt_idmap)refcount_inc (&nonconst_idmap->count); -return nonconst_idmap; +return idmap; }EXPORT_SYMBOL_GPL (mnt_idmap_get);fs/namei.c +7
-7@@ -1273,7 +1273,7 @@ fs_initcall(init_fs_namei_sysctls);*/ static inline int may_follow_link (struct nameidata *nd,const struct inode *inode) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;vfsuid_t vfsuid;if (!sysctl_protected_symlinks)@@ -2596,7 +2596,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)/* At this point we know we have a real path component. */ for (;;) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;const char *link;unsigned long lastword;@@ -4432,7 +4432,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file, const struct open_flags *op) {struct delegated_inode delegated_inode = { }; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct dentry *dir = nd->path.dentry;struct inode *dir_inode = dir->d_inode;int open_flag;@@ -4789,7 +4789,7 @@ static const char *open_last_lookups(struct nameidata *nd,static int do_open (struct nameidata *nd,struct file *file,const struct open_flags *op) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;int open_flag = op->open_flag;bool do_truncate;int acc_mode;@@ -5169,7 +5169,7 @@ struct file *dentry_create(struct path *path, int flags, umode_t mode,struct dentry *orig_dentry = dentry;struct dentry *dir = dentry->d_parent;struct inode *dir_inode =d_inode (dir); -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;int error, create_error; file =alloc_empty_file (flags, cred);@@ -5294,7 +5294,7 @@ int filename_mknodat(int dfd, struct filename *name, umode_t mode, unsigned int dev) {struct delegated_inode di = { }; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct dentry *dentry;struct path path;int error;@@ -5949,7 +5949,7 @@ EXPORT_SYMBOL(vfs_link);int filename_linkat (int olddfd,struct filename *old,int newdfd,struct filename *new,int flags) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct dentry *new_dentry;struct path old_path, new_path;struct delegated_inode delegated_inode = { };fs/namespace.c +4
-4@@ -109,7 +109,7 @@ struct mount_kattr {unsigned int lookup_flags;enum mount_kattr_flags_t kflags;struct user_namespace *mnt_userns; -struct mnt_idmap *mnt_idmap; +const struct mnt_idmap *mnt_idmap; };/* /sys/fs */ @@ -4898,7 +4898,7 @@ static int mount_setattr_prepare(struct mount_kattr *kattr, struct mount *mnt)static void do_idmap_mount (const struct mount_kattr *kattr,struct mount *mnt) { -struct mnt_idmap *old_idmap; +const struct mnt_idmap *old_idmap;if (!kattr->mnt_idmap)return ;@@ -4941,7 +4941,7 @@ static int do_mount_setattr(const struct path *path, struct mount_kattr *kattr)return -EINVAL ;if (kattr->mnt_userns) { -struct mnt_idmap *mnt_idmap; +const struct mnt_idmap *mnt_idmap; mnt_idmap =alloc_mnt_idmap (kattr->mnt_userns);if (IS_ERR (mnt_idmap))@@ -5246,7 +5246,7 @@ struct kstatmount {struct statmount __user *buf;size_t bufsize;struct vfsmount *mnt; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;u64 mask;struct path root;struct seq_file seq;fs/open.c +2
-2@@ -72,7 +72,7 @@ int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,int vfs_truncate (const struct path *path,loff_t length) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct inode *inode;int error;@@ -787,7 +787,7 @@ static inline bool setattr_vfsgid(struct iattr *attr, kgid_t kgid)int chown_common (const struct path *path,uid_t user,gid_t group) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct user_namespace *fs_userns;struct inode *inode = path->dentry->d_inode;struct delegated_inode delegated_inode = { };fs/overlayfs/file.c +1
-1@@ -30,7 +30,7 @@ static struct file *ovl_open_realfile(const struct file *file, {struct inode *realinode =d_inode (realpath->dentry);struct inode *inode =file_inode (file); -struct mnt_idmap *real_idmap; +const struct mnt_idmap *real_idmap;struct file *realfile;int flags = file->f_flags |OVL_OPEN_FLAGS ;int acc_mode =ACC_MODE (flags);fs/overlayfs/inode.c +1
-1@@ -406,7 +406,7 @@ struct posix_acl *ovl_get_acl_path(const struct path *path, const char *acl_name, bool noperm) {struct posix_acl *real_acl, *clone; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct inode *realinode =d_inode (path->dentry); idmap =mnt_idmap (path->mnt);fs/overlayfs/ovl_entry.h +1
-1@@ -105,7 +105,7 @@ static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)return ofs->layers[0 ].mnt; } -static inline struct mnt_idmap *ovl_upper_mnt_idmap (struct ovl_fs *ofs) +static inline const struct mnt_idmap *ovl_upper_mnt_idmap (struct ovl_fs *ofs) {return mnt_idmap (ovl_upper_mnt (ofs)); }fs/overlayfs/util.c +2
-2@@ -657,7 +657,7 @@ bool ovl_path_is_whiteout(struct ovl_fs *ofs, const struct path *path)struct file *ovl_path_open (const struct path *path,int flags) {struct inode *inode =d_inode (path->dentry); -struct mnt_idmap *real_idmap =mnt_idmap (path->mnt); +const struct mnt_idmap *real_idmap =mnt_idmap (path->mnt);int err, acc_mode;if (flags & ~(O_ACCMODE |O_LARGEFILE ))@@ -1496,7 +1496,7 @@ void ovl_copyattr(struct inode *inode) {struct path realpath;struct inode *realinode; -struct mnt_idmap *real_idmap; +const struct mnt_idmap *real_idmap;vfsuid_t vfsuid;vfsgid_t vfsgid;fs/remap_range.c +1
-1@@ -415,7 +415,7 @@ EXPORT_SYMBOL(vfs_clone_file_range);/* Check whether we are allowed to dedupe the destination file */ static bool may_dedupe_file (struct file *file) { -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct inode *inode =file_inode (file);if (capable (CAP_SYS_ADMIN ))fs/smb/server/oplock.c +1
-1@@ -2229,7 +2229,7 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp) {struct create_posix_rsp *buf;struct inode *inode =file_inode (fp->filp); -struct mnt_idmap *idmap =file_mnt_idmap (fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);vfsuid_t vfsuid =i_uid_into_vfsuid (idmap, inode);vfsgid_t vfsgid =i_gid_into_vfsgid (idmap, inode);fs/smb/server/smb2pdu.c +10
-10@@ -3234,7 +3234,7 @@ static bool smb2_is_private_ea(const char *name, size_t name_len)static int smb2_set_ea (struct smb2_ea_info *eabuf,unsigned int buf_len,const struct path *path,bool get_write) { -struct mnt_idmap *idmap =mnt_idmap (path->mnt); +const struct mnt_idmap *idmap =mnt_idmap (path->mnt);char *attr_name =NULL , *value;int rc =0 ;unsigned int next =0 ;@@ -3335,7 +3335,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,struct ksmbd_file *fp, char *stream_name, int s_type) { - struct mnt_idmap *idmap = mnt_idmap(path->mnt); + const struct mnt_idmap *idmap = mnt_idmap(path->mnt);size_t xattr_stream_size;char *xattr_stream_name;int rc;@@ -3411,7 +3411,7 @@ static loff_t ksmbd_stream_eof(struct ksmbd_file *fp)static int smb2_remove_smb_xattrs (const struct path *path) { -struct mnt_idmap *idmap =mnt_idmap (path->mnt); +const struct mnt_idmap *idmap =mnt_idmap (path->mnt);char *name, *xattr_list =NULL ;ssize_t xattr_list_len;int err =0 ;@@ -4088,7 +4088,7 @@ int smb2_open(struct ksmbd_work *work)struct ksmbd_share_config *share = tcon->share_conf;struct ksmbd_file *fp =NULL ;struct file *filp =NULL ; -struct mnt_idmap *idmap =NULL ; +const struct mnt_idmap *idmap =NULL ;struct kstat stat;struct create_context *context;struct lease_ctx_info *lc =NULL ;@@ -5753,7 +5753,7 @@ struct smb2_query_dir_private {static int process_query_dir_entries (struct smb2_query_dir_private *priv) { -struct mnt_idmap *idmap =file_mnt_idmap (priv->dir_fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (priv->dir_fp->filp);struct kstat kstat;struct ksmbd_kstat ksmbd_kstat;int rc;@@ -6352,7 +6352,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,ssize_t buf_free_len, alignment_bytes, next_offset, rsp_data_cnt =0 ;struct smb2_ea_info_req *ea_req =NULL ;const struct path *path; -struct mnt_idmap *idmap =file_mnt_idmap (fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);if (!(fp->daccess &FILE_READ_EA_LE )) { pr_err("Not permitted to read ext attr : 0x%x\n",@@ -7062,7 +7062,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp, {struct smb311_posix_qinfo *file_info;struct inode *inode =file_inode (fp->filp); -struct mnt_idmap *idmap =file_mnt_idmap (fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);vfsuid_t vfsuid =i_uid_into_vfsuid (idmap, inode);vfsgid_t vfsgid =i_gid_into_vfsgid (idmap, inode);struct kstat stat;@@ -7547,7 +7547,7 @@ static int smb2_get_info_sec(struct ksmbd_work *work, struct smb2_query_info_rsp *rsp) {struct ksmbd_file *fp; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct smb_ntsd *pntsd =NULL , *ppntsd =NULL ;struct smb_fattr fattr = {{0 }};struct inode *inode;@@ -8060,7 +8060,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,struct iattr attrs;struct file *filp;struct inode *inode; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;__le32 attrs_mask =FILE_ATTRIBUTE_DIRECTORY_LE |FILE_ATTRIBUTE_COMPRESSED_LE ;int rc =0 ;@@ -10652,7 +10652,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id, struct file_sparse *sparse) {struct ksmbd_file *fp; -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;int ret =0 ;__le32 old_fattr;fs/smb/server/smb_common.c +1
-1@@ -467,7 +467,7 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level, {int i, rc =0 ;struct ksmbd_conn *conn = work->conn; -struct mnt_idmap *idmap =file_mnt_idmap (dir->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (dir->filp);for (i =0 ; i <2 ; i++) {struct kstat kstat;fs/smb/server/smbacl.c +3
-3@@ -1183,7 +1183,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,struct smb_ntsd *parent_pntsd =NULL ;struct smb_sid owner_sid, group_sid;struct dentry *parent = path->dentry->d_parent; -struct mnt_idmap *idmap =mnt_idmap (path->mnt); +const struct mnt_idmap *idmap =mnt_idmap (path->mnt);int inherited_flags =0 , flags =0 , i, nt_size =0 , pdacl_size;int rc =0 , pntsd_type, ppntsd_size, acl_len, aces_size;unsigned int dacloffset;@@ -1438,7 +1438,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path, __le32 *pdaccess, __le32 raw_daccess, int uid, bool strict) { - struct mnt_idmap *idmap = mnt_idmap(path->mnt); + const struct mnt_idmap *idmap = mnt_idmap(path->mnt);struct smb_ntsd *pntsd =NULL ;struct smb_acl *pdacl;struct posix_acl *posix_acls;@@ -1660,7 +1660,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,int rc;struct smb_fattr fattr = {{0 }};struct inode *inode =d_inode (path->dentry); -struct mnt_idmap *idmap =mnt_idmap (path->mnt); +const struct mnt_idmap *idmap =mnt_idmap (path->mnt);struct iattr newattrs; fattr.cf_uid =INVALID_UID ;fs/smb/server/vfs.c +5
-5@@ -183,7 +183,7 @@ int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode)*/ int ksmbd_vfs_mkdir (struct ksmbd_work *work,const char *name,umode_t mode) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct path path;struct dentry *dentry, *d;int err =0 ;@@ -386,7 +386,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos, {const struct cred *saved_cred;char *stream_buf =NULL , *wbuf; -struct mnt_idmap *idmap =file_mnt_idmap (fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);size_t size;ssize_t v_len;int err =0 ;@@ -577,7 +577,7 @@ int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id)*/ int ksmbd_vfs_remove_file (struct ksmbd_work *work,const struct path *path) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct dentry *parent = path->dentry->d_parent;int err;@@ -1202,7 +1202,7 @@ int ksmbd_vfs_unlink(struct file *filp)const struct cred *saved_cred;int err =0 ;struct dentry *dir, *dentry = filp->f_path.dentry; -struct mnt_idmap *idmap =file_mnt_idmap (filp); +const struct mnt_idmap *idmap =file_mnt_idmap (filp); saved_cred =override_creds (filp->f_cred); err =mnt_want_write (filp->f_path.mnt);@@ -2316,7 +2316,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,const struct cred *saved_cred =NULL ;struct file_kattr fa;struct dentry *dentry = fp->filp->f_path.dentry; -struct mnt_idmap *idmap =file_mnt_idmap (fp->filp); +const struct mnt_idmap *idmap =file_mnt_idmap (fp->filp);u32 flags;__le32 old_fattr;int rc;fs/stat.c +1
-1@@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(generic_fill_statx_atomic_writes);int vfs_getattr_nosec (const struct path *path,struct kstat *stat,u32 request_mask,unsigned int query_flags) { -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct inode *inode =d_backing_inode (path->dentry);memset (stat,0 ,sizeof (*stat));include/linux/fs.h +1
-1@@ -2459,7 +2459,7 @@ struct filename {static_assert (offsetof(struct filename , iname) %sizeof (long ) ==0 );static_assert (sizeof (struct filename ) %64 ==0 ); -static inline struct mnt_idmap *file_mnt_idmap (const struct file *file) +static inline const struct mnt_idmap *file_mnt_idmap (const struct file *file) {return mnt_idmap (file->f_path.mnt); }include/linux/mnt_idmapping.h +1
-1@@ -121,7 +121,7 @@ static inline bool vfsgid_eq_kgid(vfsgid_t vfsgid, kgid_t kgid)int vfsgid_in_group_p (vfsgid_t vfsgid); -struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap); +const struct mnt_idmap *mnt_idmap_get (const struct mnt_idmap *idmap);void mnt_idmap_put (const struct mnt_idmap *idmap); vfsuid_t make_vfsuid(const struct mnt_idmap *idmap,include/linux/mount.h +2
-2@@ -59,10 +59,10 @@ struct vfsmount {struct dentry *mnt_root;/* root of the mounted tree */ struct super_block *mnt_sb;/* pointer to superblock */ int mnt_flags; -struct mnt_idmap *mnt_idmap; +const struct mnt_idmap *mnt_idmap; } __randomize_layout; -static inline struct mnt_idmap *mnt_idmap (const struct vfsmount *mnt) +static inline const struct mnt_idmap *mnt_idmap (const struct vfsmount *mnt) {/* Pairs with smp_store_release() in do_idmap_mount(). */ return READ_ONCE (mnt->mnt_idmap);net/unix/af_unix.c +1
-1@@ -1361,7 +1361,7 @@ static int unix_bind_bsd(struct sock *sk, struct sockaddr_un *sunaddr,struct unix_sock *u =unix_sk (sk);unsigned int new_hash, old_hash;struct net *net =sock_net (sk); -struct mnt_idmap *idmap; +const struct mnt_idmap *idmap;struct unix_address *addr;struct dentry *dentry;struct path parent;security/apparmor/lsm.c +2
-2@@ -397,7 +397,7 @@ static int apparmor_path_rename(const struct path *old_dir, struct dentry *old_d label =begin_current_label_crit_section (&needput);if (!unconfined (label)) { -struct mnt_idmap *idmap =mnt_idmap (old_dir->mnt); +const struct mnt_idmap *idmap =mnt_idmap (old_dir->mnt);vfsuid_t vfsuid;struct path old_path = { .mnt = old_dir->mnt, .dentry = old_dentry };@@ -485,7 +485,7 @@ static int apparmor_file_open(struct file *file) label =aa_get_newest_cred_label_condref (file->f_cred, &needput);if (!unconfined (label)) { -struct mnt_idmap *idmap =file_mnt_idmap (file); +const struct mnt_idmap *idmap =file_mnt_idmap (file);struct inode *inode =file_inode (file);vfsuid_t vfsuid;struct path_cond cond = {Signature · 2 lines
-- 2.53.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Christian Brauner
maintainerPATCH 27/27 fs: make nop_mnt_idmap and invalid_mnt_idmap const
In reply to Christian BraunerMake both static maps const so they end up in rodata. Any attempt to modify them now faults instead of silently corrupting the initial idmapping.
--- fs/mnt_idmapping.c | 4 ++-- include/linux/mnt_idmapping.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
fs/mnt_idmapping.c +2 -2
@@ -28,7 +28,7 @@ struct mnt_idmap {* mapping. This means that {g,u}id 0 is mapped to {g,u}id 0, {g,u}id 1 is * mapped to {g,u}id 1, [...], {g,u}id 1000 to {g,u}id 1000, [...]. */ -struct mnt_idmap nop_mnt_idmap = { +const struct mnt_idmap nop_mnt_idmap = { .count =REFCOUNT_INIT (1 ), };EXPORT_SYMBOL_GPL (nop_mnt_idmap);
@@ -37,7 +37,7 @@ EXPORT_SYMBOL_GPL(nop_mnt_idmap);* Carries the invalid idmapping of a full 0-4294967295 {g,u}id range. * This means that all {g,u}ids are mapped to INVALID_VFS{G,U}ID. */ -struct mnt_idmap invalid_mnt_idmap = { +const struct mnt_idmap invalid_mnt_idmap = { .count =REFCOUNT_INIT (1 ), };EXPORT_SYMBOL_GPL (invalid_mnt_idmap);
include/linux/mnt_idmapping.h +2 -2
@@ -8,8 +8,8 @@struct mnt_idmap ;struct user_namespace ; -extern struct mnt_idmap nop_mnt_idmap; -extern struct mnt_idmap invalid_mnt_idmap; +extern const struct mnt_idmap nop_mnt_idmap; +extern const struct mnt_idmap invalid_mnt_idmap;extern struct user_namespace init_user_ns; typedef struct {
Signature · 1 line
2.53.0
Re: [PATCH 27/27] fs: make nop_mnt_idmap and invalid_mnt_idmap const
Quoted 5 lines · Christian Brauner
Make both static maps const so they end up in rodata. Any attempt to modify them now faults instead of silently corrupting the initial idmapping.
Signed-off-by Christian Brauner (Amutable) <[email protected]>
Looks good. Feel free to add:
Honza
Quoted 46 lines
--- fs/mnt_idmapping.c | 4 ++-- include/linux/mnt_idmapping.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)fs/mnt_idmapping.c +2
-2@@ -28,7 +28,7 @@ struct mnt_idmap {* mapping. This means that {g,u}id 0 is mapped to {g,u}id 0, {g,u}id 1 is * mapped to {g,u}id 1, [...], {g,u}id 1000 to {g,u}id 1000, [...]. */ -struct mnt_idmap nop_mnt_idmap = { +const struct mnt_idmap nop_mnt_idmap = { .count =REFCOUNT_INIT (1 ), };EXPORT_SYMBOL_GPL (nop_mnt_idmap);@@ -37,7 +37,7 @@ EXPORT_SYMBOL_GPL(nop_mnt_idmap);* Carries the invalid idmapping of a full 0-4294967295 {g,u}id range. * This means that all {g,u}ids are mapped to INVALID_VFS{G,U}ID. */ -struct mnt_idmap invalid_mnt_idmap = { +const struct mnt_idmap invalid_mnt_idmap = { .count =REFCOUNT_INIT (1 ), };EXPORT_SYMBOL_GPL (invalid_mnt_idmap);include/linux/mnt_idmapping.h +2
-2@@ -8,8 +8,8 @@struct mnt_idmap ;struct user_namespace ; -extern struct mnt_idmap nop_mnt_idmap; -extern struct mnt_idmap invalid_mnt_idmap; +extern const struct mnt_idmap nop_mnt_idmap; +extern const struct mnt_idmap invalid_mnt_idmap;extern struct user_namespace init_user_ns; typedef struct {Signature · 2 lines
-- 2.53.0
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 11 lines · Christian Brauner
A mount's idmapping is immutable. The only thing that is allowed to be modified afterwards is the reference count and that is hidden behind
mnt_idmap_get()andmnt_idmap_put(). Everything else only ever reads from the idmapping. This is the same model that struct cred uses and the idmapping is also rather sensitive.So make the idmap argument const wherever we can. The conversion is done from the bottom up so callers can continue to pass a non-const pointer to a const parameter until the conversion is finished.
Signed-off-by Christian Brauner (Amutable) <[email protected]>
Looks good!