mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
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
...
This commit is contained in:
+1
-1
@@ -79,7 +79,7 @@ __bpf_kfunc void bpf_put_file(struct file *file)
|
||||
* pathname in *buf*, including the NUL termination character. On error, a
|
||||
* negative integer is returned.
|
||||
*/
|
||||
__bpf_kfunc int bpf_path_d_path(struct path *path, char *buf, size_t buf__sz)
|
||||
__bpf_kfunc int bpf_path_d_path(const struct path *path, char *buf, size_t buf__sz)
|
||||
{
|
||||
int len;
|
||||
char *ret;
|
||||
|
||||
+13
-20
@@ -114,26 +114,21 @@ static int create_link(struct config_item *parent_item,
|
||||
}
|
||||
|
||||
|
||||
static int get_target(const char *symname, struct path *path,
|
||||
struct config_item **target, struct super_block *sb)
|
||||
static int get_target(const char *symname, struct config_item **target,
|
||||
struct super_block *sb)
|
||||
{
|
||||
struct path path __free(path_put) = {};
|
||||
int ret;
|
||||
|
||||
ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, path);
|
||||
if (!ret) {
|
||||
if (path->dentry->d_sb == sb) {
|
||||
*target = configfs_get_config_item(path->dentry);
|
||||
if (!*target) {
|
||||
ret = -ENOENT;
|
||||
path_put(path);
|
||||
}
|
||||
} else {
|
||||
ret = -EPERM;
|
||||
path_put(path);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
ret = kern_path(symname, LOOKUP_FOLLOW|LOOKUP_DIRECTORY, &path);
|
||||
if (ret)
|
||||
return ret;
|
||||
if (path.dentry->d_sb != sb)
|
||||
return -EPERM;
|
||||
*target = configfs_get_config_item(path.dentry);
|
||||
if (!*target)
|
||||
return -ENOENT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +136,6 @@ int configfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
|
||||
struct dentry *dentry, const char *symname)
|
||||
{
|
||||
int ret;
|
||||
struct path path;
|
||||
struct configfs_dirent *sd;
|
||||
struct config_item *parent_item;
|
||||
struct config_item *target_item = NULL;
|
||||
@@ -188,7 +182,7 @@ int configfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
|
||||
* AV, a thoroughly annoyed bastard.
|
||||
*/
|
||||
inode_unlock(dir);
|
||||
ret = get_target(symname, &path, &target_item, dentry->d_sb);
|
||||
ret = get_target(symname, &target_item, dentry->d_sb);
|
||||
inode_lock(dir);
|
||||
if (ret)
|
||||
goto out_put;
|
||||
@@ -210,7 +204,6 @@ int configfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
|
||||
}
|
||||
|
||||
config_item_put(target_item);
|
||||
path_put(&path);
|
||||
|
||||
out_put:
|
||||
config_item_put(parent_item);
|
||||
|
||||
+3
-3
@@ -54,7 +54,7 @@ struct backing_file {
|
||||
|
||||
#define backing_file(f) container_of(f, struct backing_file, file)
|
||||
|
||||
struct path *backing_file_user_path(const struct file *f)
|
||||
const struct path *backing_file_user_path(const struct file *f)
|
||||
{
|
||||
return &backing_file(f)->user_path;
|
||||
}
|
||||
@@ -171,7 +171,7 @@ static int init_file(struct file *f, int flags, const struct cred *cred)
|
||||
* the respective member when opening the file.
|
||||
*/
|
||||
mutex_init(&f->f_pos_lock);
|
||||
memset(&f->f_path, 0, sizeof(f->f_path));
|
||||
memset(&f->__f_path, 0, sizeof(f->f_path));
|
||||
memset(&f->f_ra, 0, sizeof(f->f_ra));
|
||||
|
||||
f->f_flags = flags;
|
||||
@@ -319,7 +319,7 @@ struct file *alloc_empty_backing_file(int flags, const struct cred *cred)
|
||||
static void file_init_path(struct file *file, const struct path *path,
|
||||
const struct file_operations *fop)
|
||||
{
|
||||
file->f_path = *path;
|
||||
file->__f_path = *path;
|
||||
file->f_inode = path->dentry->d_inode;
|
||||
file->f_mapping = path->dentry->d_inode->i_mapping;
|
||||
file->f_wb_err = filemap_sample_wb_err(file->f_mapping);
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ extern int finish_clean_context(struct fs_context *fc);
|
||||
* namei.c
|
||||
*/
|
||||
extern int filename_lookup(int dfd, struct filename *name, unsigned flags,
|
||||
struct path *path, struct path *root);
|
||||
struct path *path, const struct path *root);
|
||||
int do_rmdir(int dfd, struct filename *name);
|
||||
int do_unlinkat(int dfd, struct filename *name);
|
||||
int may_linkat(struct mnt_idmap *idmap, const struct path *link);
|
||||
|
||||
+6
-6
@@ -2695,7 +2695,7 @@ static int path_lookupat(struct nameidata *nd, unsigned flags, struct path *path
|
||||
}
|
||||
|
||||
int filename_lookup(int dfd, struct filename *name, unsigned flags,
|
||||
struct path *path, struct path *root)
|
||||
struct path *path, const struct path *root)
|
||||
{
|
||||
int retval;
|
||||
struct nameidata nd;
|
||||
@@ -3651,8 +3651,8 @@ static struct dentry *atomic_open(struct nameidata *nd, struct dentry *dentry,
|
||||
if (nd->flags & LOOKUP_DIRECTORY)
|
||||
open_flag |= O_DIRECTORY;
|
||||
|
||||
file->f_path.dentry = DENTRY_NOT_SET;
|
||||
file->f_path.mnt = nd->path.mnt;
|
||||
file->__f_path.dentry = DENTRY_NOT_SET;
|
||||
file->__f_path.mnt = nd->path.mnt;
|
||||
error = dir->i_op->atomic_open(dir, dentry, file,
|
||||
open_to_namei_flags(open_flag), mode);
|
||||
d_lookup_done(dentry);
|
||||
@@ -4020,8 +4020,8 @@ int vfs_tmpfile(struct mnt_idmap *idmap,
|
||||
child = d_alloc(parentpath->dentry, &slash_name);
|
||||
if (unlikely(!child))
|
||||
return -ENOMEM;
|
||||
file->f_path.mnt = parentpath->mnt;
|
||||
file->f_path.dentry = child;
|
||||
file->__f_path.mnt = parentpath->mnt;
|
||||
file->__f_path.dentry = child;
|
||||
mode = vfs_prepare_mode(idmap, dir, mode, mode, mode);
|
||||
error = dir->i_op->tmpfile(idmap, dir, file, mode);
|
||||
dput(child);
|
||||
@@ -4256,7 +4256,7 @@ struct dentry *start_creating_path(int dfd, const char *pathname,
|
||||
}
|
||||
EXPORT_SYMBOL(start_creating_path);
|
||||
|
||||
void end_creating_path(struct path *path, struct dentry *dentry)
|
||||
void end_creating_path(const struct path *path, struct dentry *dentry)
|
||||
{
|
||||
if (!IS_ERR(dentry))
|
||||
dput(dentry);
|
||||
|
||||
+1
-1
@@ -676,7 +676,7 @@ nfs_set_local_verifier(struct inode *inode,
|
||||
}
|
||||
|
||||
/* Factored out from fs/nfsd/vfs.h:fh_getattr() */
|
||||
static int __vfs_getattr(struct path *p, struct kstat *stat, int version)
|
||||
static int __vfs_getattr(const struct path *p, struct kstat *stat, int version)
|
||||
{
|
||||
u32 request_mask = STATX_BASIC_STATS;
|
||||
|
||||
|
||||
+2
-2
@@ -402,7 +402,7 @@ static struct svc_export *svc_export_update(struct svc_export *new,
|
||||
struct svc_export *old);
|
||||
static struct svc_export *svc_export_lookup(struct svc_export *);
|
||||
|
||||
static int check_export(struct path *path, int *flags, unsigned char *uuid)
|
||||
static int check_export(const struct path *path, int *flags, unsigned char *uuid)
|
||||
{
|
||||
struct inode *inode = d_inode(path->dentry);
|
||||
|
||||
@@ -1181,7 +1181,7 @@ denied:
|
||||
* use exp_get_by_name() or exp_find().
|
||||
*/
|
||||
struct svc_export *
|
||||
rqst_exp_get_by_name(struct svc_rqst *rqstp, struct path *path)
|
||||
rqst_exp_get_by_name(struct svc_rqst *rqstp, const struct path *path)
|
||||
{
|
||||
struct svc_export *gssexp, *exp = ERR_PTR(-ENOENT);
|
||||
struct nfsd_net *nn = net_generic(SVC_NET(rqstp), nfsd_net_id);
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ int nfsd_export_init(struct net *);
|
||||
void nfsd_export_shutdown(struct net *);
|
||||
void nfsd_export_flush(struct net *);
|
||||
struct svc_export * rqst_exp_get_by_name(struct svc_rqst *,
|
||||
struct path *);
|
||||
const struct path *);
|
||||
struct svc_export * rqst_exp_parent(struct svc_rqst *,
|
||||
struct path *);
|
||||
struct svc_export * rqst_find_fsidzero_export(struct svc_rqst *);
|
||||
|
||||
@@ -571,7 +571,7 @@ static int nsfs_export_permission(struct handle_to_path_ctx *ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct file *nsfs_export_open(struct path *path, unsigned int oflags)
|
||||
static struct file *nsfs_export_open(const struct path *path, unsigned int oflags)
|
||||
{
|
||||
return file_open_root(path, "", oflags, 0);
|
||||
}
|
||||
|
||||
@@ -1022,8 +1022,8 @@ cleanup_all:
|
||||
put_file_access(f);
|
||||
cleanup_file:
|
||||
path_put(&f->f_path);
|
||||
f->f_path.mnt = NULL;
|
||||
f->f_path.dentry = NULL;
|
||||
f->__f_path.mnt = NULL;
|
||||
f->__f_path.dentry = NULL;
|
||||
f->f_inode = NULL;
|
||||
return error;
|
||||
}
|
||||
@@ -1050,7 +1050,7 @@ int finish_open(struct file *file, struct dentry *dentry,
|
||||
{
|
||||
BUG_ON(file->f_mode & FMODE_OPENED); /* once it's opened, it's opened */
|
||||
|
||||
file->f_path.dentry = dentry;
|
||||
file->__f_path.dentry = dentry;
|
||||
return do_dentry_open(file, open);
|
||||
}
|
||||
EXPORT_SYMBOL(finish_open);
|
||||
@@ -1073,7 +1073,7 @@ int finish_no_open(struct file *file, struct dentry *dentry)
|
||||
{
|
||||
if (IS_ERR(dentry))
|
||||
return PTR_ERR(dentry);
|
||||
file->f_path.dentry = dentry;
|
||||
file->__f_path.dentry = dentry;
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(finish_no_open);
|
||||
@@ -1093,7 +1093,7 @@ int vfs_open(const struct path *path, struct file *file)
|
||||
{
|
||||
int ret;
|
||||
|
||||
file->f_path = *path;
|
||||
file->__f_path = *path;
|
||||
ret = do_dentry_open(file, NULL);
|
||||
if (!ret) {
|
||||
/*
|
||||
|
||||
@@ -242,7 +242,7 @@ static int ovl_verify_area(loff_t pos, loff_t pos2, loff_t len, loff_t totlen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int ovl_sync_file(struct path *path)
|
||||
static int ovl_sync_file(const struct path *path)
|
||||
{
|
||||
struct file *new_file;
|
||||
int err;
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ static bool ovl_is_real_file(const struct file *realfile,
|
||||
}
|
||||
|
||||
static struct file *ovl_real_file_path(const struct file *file,
|
||||
struct path *realpath)
|
||||
const struct path *realpath)
|
||||
{
|
||||
struct ovl_file *of = file->private_data;
|
||||
struct file *realfile = of->realfile;
|
||||
|
||||
@@ -562,11 +562,11 @@ int ovl_set_metacopy_xattr(struct ovl_fs *ofs, struct dentry *d,
|
||||
struct ovl_metacopy *metacopy);
|
||||
bool ovl_is_metacopy_dentry(struct dentry *dentry);
|
||||
char *ovl_get_redirect_xattr(struct ovl_fs *ofs, const struct path *path, int padding);
|
||||
int ovl_ensure_verity_loaded(struct path *path);
|
||||
int ovl_ensure_verity_loaded(const struct path *path);
|
||||
int ovl_validate_verity(struct ovl_fs *ofs,
|
||||
struct path *metapath,
|
||||
struct path *datapath);
|
||||
int ovl_get_verity_digest(struct ovl_fs *ofs, struct path *src,
|
||||
const struct path *metapath,
|
||||
const struct path *datapath);
|
||||
int ovl_get_verity_digest(struct ovl_fs *ofs, const struct path *src,
|
||||
struct ovl_metacopy *metacopy);
|
||||
int ovl_sync_status(struct ovl_fs *ofs);
|
||||
|
||||
|
||||
@@ -404,7 +404,7 @@ static int ovl_check_namelen(const struct path *path, struct ovl_fs *ofs,
|
||||
return err;
|
||||
}
|
||||
|
||||
static int ovl_lower_dir(const char *name, struct path *path,
|
||||
static int ovl_lower_dir(const char *name, const struct path *path,
|
||||
struct ovl_fs *ofs, int *stack_depth)
|
||||
{
|
||||
int fh_type;
|
||||
|
||||
+4
-4
@@ -1381,7 +1381,7 @@ err_free:
|
||||
}
|
||||
|
||||
/* Call with mounter creds as it may open the file */
|
||||
int ovl_ensure_verity_loaded(struct path *datapath)
|
||||
int ovl_ensure_verity_loaded(const struct path *datapath)
|
||||
{
|
||||
struct inode *inode = d_inode(datapath->dentry);
|
||||
struct file *filp;
|
||||
@@ -1401,8 +1401,8 @@ int ovl_ensure_verity_loaded(struct path *datapath)
|
||||
}
|
||||
|
||||
int ovl_validate_verity(struct ovl_fs *ofs,
|
||||
struct path *metapath,
|
||||
struct path *datapath)
|
||||
const struct path *metapath,
|
||||
const struct path *datapath)
|
||||
{
|
||||
struct ovl_metacopy metacopy_data;
|
||||
u8 actual_digest[FS_VERITY_MAX_DIGEST_SIZE];
|
||||
@@ -1455,7 +1455,7 @@ int ovl_validate_verity(struct ovl_fs *ofs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ovl_get_verity_digest(struct ovl_fs *ofs, struct path *src,
|
||||
int ovl_get_verity_digest(struct ovl_fs *ofs, const struct path *src,
|
||||
struct ovl_metacopy *metacopy)
|
||||
{
|
||||
int err, digest_size;
|
||||
|
||||
+1
-1
@@ -850,7 +850,7 @@ static int pidfs_export_permission(struct handle_to_path_ctx *ctx,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct file *pidfs_export_open(struct path *path, unsigned int oflags)
|
||||
static struct file *pidfs_export_open(const struct path *path, unsigned int oflags)
|
||||
{
|
||||
/*
|
||||
* Clear O_LARGEFILE as open_by_handle_at() forces it and raise
|
||||
|
||||
+4
-4
@@ -73,7 +73,7 @@ static int ksmbd_vfs_path_lookup(struct ksmbd_share_config *share_conf,
|
||||
{
|
||||
struct qstr last;
|
||||
struct filename *filename __free(putname) = NULL;
|
||||
struct path *root_share_path = &share_conf->vfs_path;
|
||||
const struct path *root_share_path = &share_conf->vfs_path;
|
||||
int err, type;
|
||||
struct dentry *d;
|
||||
|
||||
@@ -1306,7 +1306,7 @@ int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *filepath,
|
||||
caseless, true);
|
||||
}
|
||||
|
||||
void ksmbd_vfs_kern_path_unlock(struct path *path)
|
||||
void ksmbd_vfs_kern_path_unlock(const struct path *path)
|
||||
{
|
||||
/* While lock is still held, ->d_parent is safe */
|
||||
inode_unlock(d_inode(path->dentry->d_parent));
|
||||
@@ -1867,7 +1867,7 @@ void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock)
|
||||
}
|
||||
|
||||
int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
|
||||
struct path *path)
|
||||
const struct path *path)
|
||||
{
|
||||
struct posix_acl_state acl_state;
|
||||
struct posix_acl *acls;
|
||||
@@ -1920,7 +1920,7 @@ int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
|
||||
}
|
||||
|
||||
int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
|
||||
struct path *path, struct inode *parent_inode)
|
||||
const struct path *path, struct inode *parent_inode)
|
||||
{
|
||||
struct posix_acl *acls;
|
||||
struct posix_acl_entry *pace;
|
||||
|
||||
+3
-3
@@ -123,7 +123,7 @@ int ksmbd_vfs_kern_path(struct ksmbd_work *work, char *name,
|
||||
int ksmbd_vfs_kern_path_locked(struct ksmbd_work *work, char *name,
|
||||
unsigned int flags,
|
||||
struct path *path, bool caseless);
|
||||
void ksmbd_vfs_kern_path_unlock(struct path *path);
|
||||
void ksmbd_vfs_kern_path_unlock(const struct path *path);
|
||||
struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
|
||||
const char *name,
|
||||
unsigned int flags,
|
||||
@@ -164,8 +164,8 @@ int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
|
||||
struct dentry *dentry,
|
||||
struct xattr_dos_attrib *da);
|
||||
int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
|
||||
struct path *path);
|
||||
const struct path *path);
|
||||
int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
|
||||
struct path *path,
|
||||
const struct path *path,
|
||||
struct inode *parent_inode);
|
||||
#endif /* __KSMBD_VFS_H__ */
|
||||
|
||||
@@ -293,7 +293,7 @@ static int statx_lookup_flags(int flags)
|
||||
return lookup_flags;
|
||||
}
|
||||
|
||||
static int vfs_statx_path(struct path *path, int flags, struct kstat *stat,
|
||||
static int vfs_statx_path(const struct path *path, int flags, struct kstat *stat,
|
||||
u32 request_mask)
|
||||
{
|
||||
int error = vfs_getattr(path, stat, request_mask, flags);
|
||||
|
||||
@@ -276,7 +276,7 @@ struct export_operations {
|
||||
int (*commit_blocks)(struct inode *inode, struct iomap *iomaps,
|
||||
int nr_iomaps, struct iattr *iattr);
|
||||
int (*permission)(struct handle_to_path_ctx *ctx, unsigned int oflags);
|
||||
struct file * (*open)(struct path *path, unsigned int oflags);
|
||||
struct file * (*open)(const struct path *path, unsigned int oflags);
|
||||
#define EXPORT_OP_NOWCC (0x1) /* don't collect v3 wcc data */
|
||||
#define EXPORT_OP_NOSUBTREECHK (0x2) /* no subtree checking */
|
||||
#define EXPORT_OP_CLOSE_BEFORE_UNLINK (0x4) /* close files before unlink */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user