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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'pull-f_path' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull file->f_path constification from Al Viro:
"Only one thing was modifying ->f_path of an opened file - acct(2).

Massaging that away and constifying a bunch of struct path * arguments
in functions that might be given &file->f_path ends up with the
situation where we can turn ->f_path into an anon union of const
struct path f_path and struct path __f_path, the latter modified only
in a few places in fs/{file_table,open,namei}.c, all for struct file
instances that are yet to be opened"

* tag 'pull-f_path' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (23 commits)
Have cc(1) catch attempts to modify ->f_path
kernel/acct.c: saner struct file treatment
configfs:get_target() - release path as soon as we grab configfs_item reference
apparmor/af_unix: constify struct path * arguments
ovl_is_real_file: constify realpath argument
ovl_sync_file(): constify path argument
ovl_lower_dir(): constify path argument
ovl_get_verity_digest(): constify path argument
ovl_validate_verity(): constify {meta,data}path arguments
ovl_ensure_verity_loaded(): constify datapath argument
ksmbd_vfs_set_init_posix_acl(): constify path argument
ksmbd_vfs_inherit_posix_acl(): constify path argument
ksmbd_vfs_kern_path_unlock(): constify path argument
ksmbd_vfs_path_lookup_locked(): root_share_path can be const struct path *
check_export(): constify path argument
export_operations->open(): constify path argument
rqst_exp_get_by_name(): constify path argument
nfs: constify path argument of __vfs_getattr()
bpf...d_path(): constify path argument
done_path_create(): constify path argument
...

+118 -144
+1 -1
fs/bpf_fs_kfuncs.c
··· 79 79 * pathname in *buf*, including the NUL termination character. On error, a 80 80 * negative integer is returned. 81 81 */ 82 - __bpf_kfunc int bpf_path_d_path(struct path *path, char *buf, size_t buf__sz) 82 + __bpf_kfunc int bpf_path_d_path(const struct path *path, char *buf, size_t buf__sz) 83 83 { 84 84 int len; 85 85 char *ret;
+13 -20
fs/configfs/symlink.c
··· 114 114 } 115 115 116 116 117 - static int get_target(const char *symname, struct path *path, 118 - struct config_item **target, struct super_block *sb) 117 + static int get_target(const char *symname, struct config_item **target, 118 + struct super_block *sb) 119 119 { 120 + struct path path __free(path_put) = {}; 120 121 int ret; 121 122 122 - ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, path); 123 - if (!ret) { 124 - if (path->dentry->d_sb == sb) { 125 - *target = configfs_get_config_item(path->dentry); 126 - if (!*target) { 127 - ret = -ENOENT; 128 - path_put(path); 129 - } 130 - } else { 131 - ret = -EPERM; 132 - path_put(path); 133 - } 134 - } 135 - 136 - return ret; 123 + ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &path); 124 + if (ret) 125 + return ret; 126 + if (path.dentry->d_sb != sb) 127 + return -EPERM; 128 + *target = configfs_get_config_item(path.dentry); 129 + if (!*target) 130 + return -ENOENT; 131 + return 0; 137 132 } 138 133 139 134 ··· 136 141 struct dentry *dentry, const char *symname) 137 142 { 138 143 int ret; 139 - struct path path; 140 144 struct configfs_dirent *sd; 141 145 struct config_item *parent_item; 142 146 struct config_item *target_item = NULL; ··· 182 188 * AV, a thoroughly annoyed bastard. 183 189 */ 184 190 inode_unlock(dir); 185 - ret = get_target(symname, &path, &target_item, dentry->d_sb); 191 + ret = get_target(symname, &target_item, dentry->d_sb); 186 192 inode_lock(dir); 187 193 if (ret) 188 194 goto out_put; ··· 204 210 } 205 211 206 212 config_item_put(target_item); 207 - path_put(&path); 208 213 209 214 out_put: 210 215 config_item_put(parent_item);
+3 -3
fs/file_table.c
··· 54 54 55 55 #define backing_file(f) container_of(f, struct backing_file, file) 56 56 57 - struct path *backing_file_user_path(const struct file *f) 57 + const struct path *backing_file_user_path(const struct file *f) 58 58 { 59 59 return &backing_file(f)->user_path; 60 60 } ··· 171 171 * the respective member when opening the file. 172 172 */ 173 173 mutex_init(&f->f_pos_lock); 174 - memset(&f->f_path, 0, sizeof(f->f_path)); 174 + memset(&f->__f_path, 0, sizeof(f->f_path)); 175 175 memset(&f->f_ra, 0, sizeof(f->f_ra)); 176 176 177 177 f->f_flags = flags; ··· 319 319 static void file_init_path(struct file *file, const struct path *path, 320 320 const struct file_operations *fop) 321 321 { 322 - file->f_path = *path; 322 + file->__f_path = *path; 323 323 file->f_inode = path->dentry->d_inode; 324 324 file->f_mapping = path->dentry->d_inode->i_mapping; 325 325 file->f_wb_err = filemap_sample_wb_err(file->f_mapping);
+1 -1
fs/internal.h
··· 53 53 * namei.c 54 54 */ 55 55 extern int filename_lookup(int dfd, struct filename *name, unsigned flags, 56 - struct path *path, struct path *root); 56 + struct path *path, const struct path *root); 57 57 int do_rmdir(int dfd, struct filename *name); 58 58 int do_unlinkat(int dfd, struct filename *name); 59 59 int may_linkat(struct mnt_idmap *idmap, const struct path *link);
+6 -6
fs/namei.c
··· 2695 2695 } 2696 2696 2697 2697 int filename_lookup(int dfd, struct filename *name, unsigned flags, 2698 - struct path *path, struct path *root) 2698 + struct path *path, const struct path *root) 2699 2699 { 2700 2700 int retval; 2701 2701 struct nameidata nd; ··· 3651 3651 if (nd->flags & LOOKUP_DIRECTORY) 3652 3652 open_flag |= O_DIRECTORY; 3653 3653 3654 - file->f_path.dentry = DENTRY_NOT_SET; 3655 - file->f_path.mnt = nd->path.mnt; 3654 + file->__f_path.dentry = DENTRY_NOT_SET; 3655 + file->__f_path.mnt = nd->path.mnt; 3656 3656 error = dir->i_op->atomic_open(dir, dentry, file, 3657 3657 open_to_namei_flags(open_flag), mode); 3658 3658 d_lookup_done(dentry); ··· 4020 4020 child = d_alloc(parentpath->dentry, &slash_name); 4021 4021 if (unlikely(!child)) 4022 4022 return -ENOMEM; 4023 - file->f_path.mnt = parentpath->mnt; 4024 - file->f_path.dentry = child; 4023 + file->__f_path.mnt = parentpath->mnt; 4024 + file->__f_path.dentry = child; 4025 4025 mode = vfs_prepare_mode(idmap, dir, mode, mode, mode); 4026 4026 error = dir->i_op->tmpfile(idmap, dir, file, mode); 4027 4027 dput(child); ··· 4256 4256 } 4257 4257 EXPORT_SYMBOL(start_creating_path); 4258 4258 4259 - void end_creating_path(struct path *path, struct dentry *dentry) 4259 + void end_creating_path(const struct path *path, struct dentry *dentry) 4260 4260 { 4261 4261 if (!IS_ERR(dentry)) 4262 4262 dput(dentry);
+1 -1
fs/nfs/localio.c
··· 676 676 } 677 677 678 678 /* Factored out from fs/nfsd/vfs.h:fh_getattr() */ 679 - static int __vfs_getattr(struct path *p, struct kstat *stat, int version) 679 + static int __vfs_getattr(const struct path *p, struct kstat *stat, int version) 680 680 { 681 681 u32 request_mask = STATX_BASIC_STATS; 682 682
+2 -2
fs/nfsd/export.c
··· 402 402 struct svc_export *old); 403 403 static struct svc_export *svc_export_lookup(struct svc_export *); 404 404 405 - static int check_export(struct path *path, int *flags, unsigned char *uuid) 405 + static int check_export(const struct path *path, int *flags, unsigned char *uuid) 406 406 { 407 407 struct inode *inode = d_inode(path->dentry); 408 408 ··· 1181 1181 * use exp_get_by_name() or exp_find(). 1182 1182 */ 1183 1183 struct svc_export * 1184 - rqst_exp_get_by_name(struct svc_rqst *rqstp, struct path *path) 1184 + rqst_exp_get_by_name(struct svc_rqst *rqstp, const struct path *path) 1185 1185 { 1186 1186 struct svc_export *gssexp, *exp = ERR_PTR(-ENOENT); 1187 1187 struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
+1 -1
fs/nfsd/export.h
··· 111 111 void nfsd_export_shutdown(struct net *); 112 112 void nfsd_export_flush(struct net *); 113 113 struct svc_export * rqst_exp_get_by_name(struct svc_rqst *, 114 - struct path *); 114 + const struct path *); 115 115 struct svc_export * rqst_exp_parent(struct svc_rqst *, 116 116 struct path *); 117 117 struct svc_export * rqst_find_fsidzero_export(struct svc_rqst *);
+1 -1
fs/nsfs.c
··· 571 571 return 0; 572 572 } 573 573 574 - static struct file *nsfs_export_open(struct path *path, unsigned int oflags) 574 + static struct file *nsfs_export_open(const struct path *path, unsigned int oflags) 575 575 { 576 576 return file_open_root(path, "", oflags, 0); 577 577 }
+5 -5
fs/open.c
··· 1022 1022 put_file_access(f); 1023 1023 cleanup_file: 1024 1024 path_put(&f->f_path); 1025 - f->f_path.mnt = NULL; 1026 - f->f_path.dentry = NULL; 1025 + f->__f_path.mnt = NULL; 1026 + f->__f_path.dentry = NULL; 1027 1027 f->f_inode = NULL; 1028 1028 return error; 1029 1029 } ··· 1050 1050 { 1051 1051 BUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */ 1052 1052 1053 - file->f_path.dentry = dentry; 1053 + file->__f_path.dentry = dentry; 1054 1054 return do_dentry_open(file, open); 1055 1055 } 1056 1056 EXPORT_SYMBOL(finish_open); ··· 1073 1073 { 1074 1074 if (IS_ERR(dentry)) 1075 1075 return PTR_ERR(dentry); 1076 - file->f_path.dentry = dentry; 1076 + file->__f_path.dentry = dentry; 1077 1077 return 0; 1078 1078 } 1079 1079 EXPORT_SYMBOL(finish_no_open); ··· 1093 1093 { 1094 1094 int ret; 1095 1095 1096 - file->f_path = *path; 1096 + file->__f_path = *path; 1097 1097 ret = do_dentry_open(file, NULL); 1098 1098 if (!ret) { 1099 1099 /*
+1 -1
fs/overlayfs/copy_up.c
··· 242 242 return 0; 243 243 } 244 244 245 - static int ovl_sync_file(struct path *path) 245 + static int ovl_sync_file(const struct path *path) 246 246 { 247 247 struct file *new_file; 248 248 int err;
+1 -1
fs/overlayfs/file.c
··· 120 120 } 121 121 122 122 static struct file *ovl_real_file_path(const struct file *file, 123 - struct path *realpath) 123 + const struct path *realpath) 124 124 { 125 125 struct ovl_file *of = file->private_data; 126 126 struct file *realfile = of->realfile;
+4 -4
fs/overlayfs/overlayfs.h
··· 562 562 struct ovl_metacopy *metacopy); 563 563 bool ovl_is_metacopy_dentry(struct dentry *dentry); 564 564 char *ovl_get_redirect_xattr(struct ovl_fs *ofs, const struct path *path, int padding); 565 - int ovl_ensure_verity_loaded(struct path *path); 565 + int ovl_ensure_verity_loaded(const struct path *path); 566 566 int ovl_validate_verity(struct ovl_fs *ofs, 567 - struct path *metapath, 568 - struct path *datapath); 569 - int ovl_get_verity_digest(struct ovl_fs *ofs, struct path *src, 567 + const struct path *metapath, 568 + const struct path *datapath); 569 + int ovl_get_verity_digest(struct ovl_fs *ofs, const struct path *src, 570 570 struct ovl_metacopy *metacopy); 571 571 int ovl_sync_status(struct ovl_fs *ofs); 572 572
+1 -1
fs/overlayfs/super.c
··· 404 404 return err; 405 405 } 406 406 407 - static int ovl_lower_dir(const char *name, struct path *path, 407 + static int ovl_lower_dir(const char *name, const struct path *path, 408 408 struct ovl_fs *ofs, int *stack_depth) 409 409 { 410 410 int fh_type;
+4 -4
fs/overlayfs/util.c
··· 1381 1381 } 1382 1382 1383 1383 /* Call with mounter creds as it may open the file */ 1384 - int ovl_ensure_verity_loaded(struct path *datapath) 1384 + int ovl_ensure_verity_loaded(const struct path *datapath) 1385 1385 { 1386 1386 struct inode *inode = d_inode(datapath->dentry); 1387 1387 struct file *filp; ··· 1401 1401 } 1402 1402 1403 1403 int ovl_validate_verity(struct ovl_fs *ofs, 1404 - struct path *metapath, 1405 - struct path *datapath) 1404 + const struct path *metapath, 1405 + const struct path *datapath) 1406 1406 { 1407 1407 struct ovl_metacopy metacopy_data; 1408 1408 u8 actual_digest[FS_VERITY_MAX_DIGEST_SIZE]; ··· 1455 1455 return 0; 1456 1456 } 1457 1457 1458 - int ovl_get_verity_digest(struct ovl_fs *ofs, struct path *src, 1458 + int ovl_get_verity_digest(struct ovl_fs *ofs, const struct path *src, 1459 1459 struct ovl_metacopy *metacopy) 1460 1460 { 1461 1461 int err, digest_size;
+1 -1
fs/pidfs.c
··· 850 850 return 0; 851 851 } 852 852 853 - static struct file *pidfs_export_open(struct path *path, unsigned int oflags) 853 + static struct file *pidfs_export_open(const struct path *path, unsigned int oflags) 854 854 { 855 855 /* 856 856 * Clear O_LARGEFILE as open_by_handle_at() forces it and raise
+4 -4
fs/smb/server/vfs.c
··· 73 73 { 74 74 struct qstr last; 75 75 struct filename *filename __free(putname) = NULL; 76 - struct path *root_share_path = &share_conf->vfs_path; 76 + const struct path *root_share_path = &share_conf->vfs_path; 77 77 int err, type; 78 78 struct dentry *d; 79 79 ··· 1306 1306 caseless, true); 1307 1307 } 1308 1308 1309 - void ksmbd_vfs_kern_path_unlock(struct path *path) 1309 + void ksmbd_vfs_kern_path_unlock(const struct path *path) 1310 1310 { 1311 1311 /* While lock is still held, ->d_parent is safe */ 1312 1312 inode_unlock(d_inode(path->dentry->d_parent)); ··· 1867 1867 } 1868 1868 1869 1869 int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap, 1870 - struct path *path) 1870 + const struct path *path) 1871 1871 { 1872 1872 struct posix_acl_state acl_state; 1873 1873 struct posix_acl *acls; ··· 1920 1920 } 1921 1921 1922 1922 int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap, 1923 - struct path *path, struct inode *parent_inode) 1923 + const struct path *path, struct inode *parent_inode) 1924 1924 { 1925 1925 struct posix_acl *acls; 1926 1926 struct posix_acl_entry *pace;
+3 -3
fs/smb/server/vfs.h
··· 123 123 int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name, 124 124 unsigned int flags, 125 125 struct path *path, bool caseless); 126 - void ksmbd_vfs_kern_path_unlock(struct path *path); 126 + void ksmbd_vfs_kern_path_unlock(const struct path *path); 127 127 struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work, 128 128 const char *name, 129 129 unsigned int flags, ··· 164 164 struct dentry *dentry, 165 165 struct xattr_dos_attrib *da); 166 166 int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap, 167 - struct path *path); 167 + const struct path *path); 168 168 int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap, 169 - struct path *path, 169 + const struct path *path, 170 170 struct inode *parent_inode); 171 171 #endif /* __KSMBD_VFS_H__ */
+1 -1
fs/stat.c
··· 293 293 return lookup_flags; 294 294 } 295 295 296 - static int vfs_statx_path(struct path *path, int flags, struct kstat *stat, 296 + static int vfs_statx_path(const struct path *path, int flags, struct kstat *stat, 297 297 u32 request_mask) 298 298 { 299 299 int error = vfs_getattr(path, stat, request_mask, flags);
+1 -1
include/linux/exportfs.h
··· 276 276 int (*commit_blocks)(struct inode *inode, struct iomap *iomaps, 277 277 int nr_iomaps, struct iattr *iattr); 278 278 int (*permission)(struct handle_to_path_ctx *ctx, unsigned int oflags); 279 - struct file * (*open)(struct path *path, unsigned int oflags); 279 + struct file * (*open)(const struct path *path, unsigned int oflags); 280 280 #define EXPORT_OP_NOWCC (0x1) /* don't collect v3 wcc data */ 281 281 #define EXPORT_OP_NOSUBTREECHK (0x2) /* no subtree checking */ 282 282 #define EXPORT_OP_CLOSE_BEFORE_UNLINK (0x4) /* close files before unlink */
+7 -2
include/linux/fs.h
··· 1192 1192 * @f_cred: stashed credentials of creator/opener 1193 1193 * @f_owner: file owner 1194 1194 * @f_path: path of the file 1195 + * @__f_path: writable alias for @f_path; *ONLY* for core VFS and only before 1196 + * the file gets open 1195 1197 * @f_pos_lock: lock protecting file position 1196 1198 * @f_pipe: specific to pipes 1197 1199 * @f_pos: file position ··· 1219 1217 const struct cred *f_cred; 1220 1218 struct fown_struct *f_owner; 1221 1219 /* --- cacheline 1 boundary (64 bytes) --- */ 1222 - struct path f_path; 1220 + union { 1221 + const struct path f_path; 1222 + struct path __f_path; 1223 + }; 1223 1224 union { 1224 1225 /* regular files (with FMODE_ATOMIC_POS) and directories */ 1225 1226 struct mutex f_pos_lock; ··· 2882 2877 const struct cred *cred); 2883 2878 struct file *dentry_create(const struct path *path, int flags, umode_t mode, 2884 2879 const struct cred *cred); 2885 - struct path *backing_file_user_path(const struct file *f); 2880 + const struct path *backing_file_user_path(const struct file *f); 2886 2881 2887 2882 /* 2888 2883 * When mmapping a file on a stackable filesystem (e.g., overlayfs), the file
+2 -2
include/linux/namei.h
··· 61 61 62 62 extern struct dentry *start_creating_path(int, const char *, struct path *, unsigned int); 63 63 extern struct dentry *start_creating_user_path(int, const char __user *, struct path *, unsigned int); 64 - extern void end_creating_path(struct path *, struct dentry *); 64 + extern void end_creating_path(const struct path *, struct dentry *); 65 65 extern struct dentry *start_removing_path(const char *, struct path *); 66 66 extern struct dentry *start_removing_user_path_at(int , const char __user *, struct path *); 67 - static inline void end_removing_path(struct path *path , struct dentry *dentry) 67 + static inline void end_removing_path(const struct path *path , struct dentry *dentry) 68 68 { 69 69 end_creating_path(path, dentry); 70 70 }
+45 -69
kernel/acct.c
··· 44 44 * a struct file opened for write. Fixed. 2/6/2000, AV. 45 45 */ 46 46 47 - #include <linux/mm.h> 48 47 #include <linux/slab.h> 49 48 #include <linux/acct.h> 50 49 #include <linux/capability.h> 51 - #include <linux/file.h> 52 50 #include <linux/tty.h> 53 - #include <linux/security.h> 54 - #include <linux/vfs.h> 51 + #include <linux/statfs.h> 55 52 #include <linux/jiffies.h> 56 - #include <linux/times.h> 57 53 #include <linux/syscalls.h> 58 - #include <linux/mount.h> 59 - #include <linux/uaccess.h> 54 + #include <linux/namei.h> 60 55 #include <linux/sched/cputime.h> 61 56 62 57 #include <asm/div64.h> ··· 212 217 complete(&acct->done); 213 218 } 214 219 215 - static int acct_on(struct filename *pathname) 220 + DEFINE_FREE(fput_sync, struct file *, if (!IS_ERR_OR_NULL(_T)) __fput_sync(_T)) 221 + static int acct_on(const char __user *name) 216 222 { 217 - struct file *file; 218 - struct vfsmount *mnt, *internal; 223 + /* Difference from BSD - they don't do O_APPEND */ 224 + const int open_flags = O_WRONLY|O_APPEND|O_LARGEFILE; 219 225 struct pid_namespace *ns = task_active_pid_ns(current); 226 + struct filename *pathname __free(putname) = getname(name); 227 + struct file *original_file __free(fput) = NULL; // in that order 228 + struct path internal __free(path_put) = {}; // in that order 229 + struct file *file __free(fput_sync) = NULL; // in that order 220 230 struct bsd_acct_struct *acct; 231 + struct vfsmount *mnt; 221 232 struct fs_pin *old; 222 - int err; 233 + 234 + if (IS_ERR(pathname)) 235 + return PTR_ERR(pathname); 236 + original_file = file_open_name(pathname, open_flags, 0); 237 + if (IS_ERR(original_file)) 238 + return PTR_ERR(original_file); 239 + 240 + mnt = mnt_clone_internal(&original_file->f_path); 241 + if (IS_ERR(mnt)) 242 + return PTR_ERR(mnt); 243 + 244 + internal.mnt = mnt; 245 + internal.dentry = dget(mnt->mnt_root); 246 + 247 + file = dentry_open(&internal, open_flags, current_cred()); 248 + if (IS_ERR(file)) 249 + return PTR_ERR(file); 250 + 251 + if (!S_ISREG(file_inode(file)->i_mode)) 252 + return -EACCES; 253 + 254 + /* Exclude kernel kernel internal filesystems. */ 255 + if (file_inode(file)->i_sb->s_flags & (SB_NOUSER | SB_KERNMOUNT)) 256 + return -EINVAL; 257 + 258 + /* Exclude procfs and sysfs. */ 259 + if (file_inode(file)->i_sb->s_iflags & SB_I_USERNS_VISIBLE) 260 + return -EINVAL; 261 + 262 + if (!(file->f_mode & FMODE_CAN_WRITE)) 263 + return -EIO; 223 264 224 265 acct = kzalloc(sizeof(struct bsd_acct_struct), GFP_KERNEL); 225 266 if (!acct) 226 267 return -ENOMEM; 227 268 228 - /* Difference from BSD - they don't do O_APPEND */ 229 - file = file_open_name(pathname, O_WRONLY|O_APPEND|O_LARGEFILE, 0); 230 - if (IS_ERR(file)) { 231 - kfree(acct); 232 - return PTR_ERR(file); 233 - } 234 - 235 - if (!S_ISREG(file_inode(file)->i_mode)) { 236 - kfree(acct); 237 - filp_close(file, NULL); 238 - return -EACCES; 239 - } 240 - 241 - /* Exclude kernel kernel internal filesystems. */ 242 - if (file_inode(file)->i_sb->s_flags & (SB_NOUSER | SB_KERNMOUNT)) { 243 - kfree(acct); 244 - filp_close(file, NULL); 245 - return -EINVAL; 246 - } 247 - 248 - /* Exclude procfs and sysfs. */ 249 - if (file_inode(file)->i_sb->s_iflags & SB_I_USERNS_VISIBLE) { 250 - kfree(acct); 251 - filp_close(file, NULL); 252 - return -EINVAL; 253 - } 254 - 255 - if (!(file->f_mode & FMODE_CAN_WRITE)) { 256 - kfree(acct); 257 - filp_close(file, NULL); 258 - return -EIO; 259 - } 260 - internal = mnt_clone_internal(&file->f_path); 261 - if (IS_ERR(internal)) { 262 - kfree(acct); 263 - filp_close(file, NULL); 264 - return PTR_ERR(internal); 265 - } 266 - err = mnt_get_write_access(internal); 267 - if (err) { 268 - mntput(internal); 269 - kfree(acct); 270 - filp_close(file, NULL); 271 - return err; 272 - } 273 - mnt = file->f_path.mnt; 274 - file->f_path.mnt = internal; 275 - 276 269 atomic_long_set(&acct->count, 1); 277 270 init_fs_pin(&acct->pin, acct_pin_kill); 278 - acct->file = file; 271 + acct->file = no_free_ptr(file); 279 272 acct->needcheck = jiffies; 280 273 acct->ns = ns; 281 274 mutex_init(&acct->lock); 282 275 INIT_WORK(&acct->work, close_work); 283 276 init_completion(&acct->done); 284 277 mutex_lock_nested(&acct->lock, 1); /* nobody has seen it yet */ 285 - pin_insert(&acct->pin, mnt); 278 + pin_insert(&acct->pin, original_file->f_path.mnt); 286 279 287 280 rcu_read_lock(); 288 281 old = xchg(&ns->bacct, &acct->pin); 289 282 mutex_unlock(&acct->lock); 290 283 pin_kill(old); 291 - mnt_put_write_access(mnt); 292 - mntput(mnt); 293 284 return 0; 294 285 } 295 286 ··· 300 319 return -EPERM; 301 320 302 321 if (name) { 303 - struct filename *tmp = getname(name); 304 - 305 - if (IS_ERR(tmp)) 306 - return PTR_ERR(tmp); 307 322 mutex_lock(&acct_on_mutex); 308 - error = acct_on(tmp); 323 + error = acct_on(name); 309 324 mutex_unlock(&acct_on_mutex); 310 - putname(tmp); 311 325 } else { 312 326 rcu_read_lock(); 313 327 pin_kill(task_active_pid_ns(current)->bacct);
+1 -1
kernel/trace/bpf_trace.c
··· 899 899 .arg1_type = ARG_ANYTHING, 900 900 }; 901 901 902 - BPF_CALL_3(bpf_d_path, struct path *, path, char *, buf, u32, sz) 902 + BPF_CALL_3(bpf_d_path, const struct path *, path, char *, buf, u32, sz) 903 903 { 904 904 struct path copy; 905 905 long len;
+7 -7
security/apparmor/af_unix.c
··· 31 31 } 32 32 33 33 static int unix_fs_perm(const char *op, u32 mask, const struct cred *subj_cred, 34 - struct aa_label *label, struct path *path) 34 + struct aa_label *label, const struct path *path) 35 35 { 36 36 AA_BUG(!label); 37 37 AA_BUG(!path); ··· 224 224 225 225 static int profile_sk_perm(struct aa_profile *profile, 226 226 struct apparmor_audit_data *ad, 227 - u32 request, struct sock *sk, struct path *path) 227 + u32 request, struct sock *sk, const struct path *path) 228 228 { 229 229 struct aa_ruleset *rules = profile->label.rules[0]; 230 230 struct aa_perms *p = NULL; ··· 386 386 387 387 /* null peer_label is allowed, in which case the peer_sk label is used */ 388 388 static int profile_peer_perm(struct aa_profile *profile, u32 request, 389 - struct sock *sk, struct path *path, 389 + struct sock *sk, const struct path *path, 390 390 struct sockaddr_un *peer_addr, 391 - int peer_addrlen, struct path *peer_path, 391 + int peer_addrlen, const struct path *peer_path, 392 392 struct aa_label *peer_label, 393 393 struct apparmor_audit_data *ad) 394 394 { ··· 445 445 static int aa_unix_label_sk_perm(const struct cred *subj_cred, 446 446 struct aa_label *label, 447 447 const char *op, u32 request, struct sock *sk, 448 - struct path *path) 448 + const struct path *path) 449 449 { 450 450 if (!unconfined(label)) { 451 451 struct aa_profile *profile; ··· 599 599 600 600 static int unix_peer_perm(const struct cred *subj_cred, 601 601 struct aa_label *label, const char *op, u32 request, 602 - struct sock *sk, struct path *path, 602 + struct sock *sk, const struct path *path, 603 603 struct sockaddr_un *peer_addr, int peer_addrlen, 604 - struct path *peer_path, struct aa_label *peer_label) 604 + const struct path *peer_path, struct aa_label *peer_label) 605 605 { 606 606 struct aa_profile *profile; 607 607 DEFINE_AUDIT_SK(ad, op, subj_cred, sk);
+1 -1
tools/testing/selftests/bpf/bpf_experimental.h
··· 219 219 * including the NULL termination character, stored in the supplied 220 220 * buffer. On error, a negative integer is returned. 221 221 */ 222 - extern int bpf_path_d_path(struct path *path, char *buf, size_t buf__sz) __ksym; 222 + extern int bpf_path_d_path(const struct path *path, char *buf, size_t buf__sz) __ksym; 223 223 224 224 /* This macro must be used to mark the exception callback corresponding to the 225 225 * main program. For example: