Skip to content

Commit

Permalink
Merge branch 'work.const-path' of git://git.kernel.org/pub/scm/linux/…
Browse files Browse the repository at this point in the history
…kernel/git/viro/vfs

Pull 'struct path' constification update from Al Viro:
 "'struct path' is passed by reference to a bunch of Linux security
  methods; in theory, there's nothing to stop them from modifying the
  damn thing and LSM community being what it is, sooner or later some
  enterprising soul is going to decide that it's a good idea.

  Let's remove the temptation and constify all of those..."

* 'work.const-path' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
  constify ima_d_path()
  constify security_sb_pivotroot()
  constify security_path_chroot()
  constify security_path_{link,rename}
  apparmor: remove useless checks for NULL ->mnt
  constify security_path_{mkdir,mknod,symlink}
  constify security_path_{unlink,rmdir}
  apparmor: constify common_perm_...()
  apparmor: constify aa_path_link()
  apparmor: new helper - common_path_perm()
  constify chmod_common/security_path_chmod
  constify security_sb_mount()
  constify chown_common/security_path_chown
  tomoyo: constify assorted struct path *
  apparmor_path_truncate(): path->mnt is never NULL
  constify vfs_truncate()
  constify security_path_truncate()
  [apparmor] constify struct path * in a bunch of helpers
  • Loading branch information
torvalds committed May 17, 2016
2 parents 681750c + 81cd889 commit c52b761
Show file tree
Hide file tree
Showing 19 changed files with 132 additions and 155 deletions.
2 changes: 1 addition & 1 deletion fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -2837,7 +2837,7 @@ static inline int open_to_namei_flags(int flag)
return flag;
}

static int may_o_create(struct path *dir, struct dentry *dentry, umode_t mode)
static int may_o_create(const struct path *dir, struct dentry *dentry, umode_t mode)
{
int error = security_path_mknod(dir, dentry, mode, 0);
if (error)
Expand Down
6 changes: 3 additions & 3 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
return ret;
}

long vfs_truncate(struct path *path, loff_t length)
long vfs_truncate(const struct path *path, loff_t length)
{
struct inode *inode;
long error;
Expand Down Expand Up @@ -499,7 +499,7 @@ SYSCALL_DEFINE1(chroot, const char __user *, filename)
return error;
}

static int chmod_common(struct path *path, umode_t mode)
static int chmod_common(const struct path *path, umode_t mode)
{
struct inode *inode = path->dentry->d_inode;
struct inode *delegated_inode = NULL;
Expand Down Expand Up @@ -564,7 +564,7 @@ SYSCALL_DEFINE2(chmod, const char __user *, filename, umode_t, mode)
return sys_fchmodat(AT_FDCWD, filename, mode);
}

static int chown_common(struct path *path, uid_t user, gid_t group)
static int chown_common(const struct path *path, uid_t user, gid_t group)
{
struct inode *inode = path->dentry->d_inode;
struct inode *delegated_inode = NULL;
Expand Down
2 changes: 1 addition & 1 deletion include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -2293,7 +2293,7 @@ struct filename {
const char iname[];
};

extern long vfs_truncate(struct path *, loff_t);
extern long vfs_truncate(const struct path *, loff_t);
extern int do_truncate(struct dentry *, loff_t start, unsigned int time_attrs,
struct file *filp);
extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
Expand Down
28 changes: 14 additions & 14 deletions include/linux/lsm_hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -1344,10 +1344,10 @@ union security_list_options {
int (*sb_kern_mount)(struct super_block *sb, int flags, void *data);
int (*sb_show_options)(struct seq_file *m, struct super_block *sb);
int (*sb_statfs)(struct dentry *dentry);
int (*sb_mount)(const char *dev_name, struct path *path,
int (*sb_mount)(const char *dev_name, const struct path *path,
const char *type, unsigned long flags, void *data);
int (*sb_umount)(struct vfsmount *mnt, int flags);
int (*sb_pivotroot)(struct path *old_path, struct path *new_path);
int (*sb_pivotroot)(const struct path *old_path, const struct path *new_path);
int (*sb_set_mnt_opts)(struct super_block *sb,
struct security_mnt_opts *opts,
unsigned long kern_flags,
Expand All @@ -1361,23 +1361,23 @@ union security_list_options {


#ifdef CONFIG_SECURITY_PATH
int (*path_unlink)(struct path *dir, struct dentry *dentry);
int (*path_mkdir)(struct path *dir, struct dentry *dentry,
int (*path_unlink)(const struct path *dir, struct dentry *dentry);
int (*path_mkdir)(const struct path *dir, struct dentry *dentry,
umode_t mode);
int (*path_rmdir)(struct path *dir, struct dentry *dentry);
int (*path_mknod)(struct path *dir, struct dentry *dentry,
int (*path_rmdir)(const struct path *dir, struct dentry *dentry);
int (*path_mknod)(const struct path *dir, struct dentry *dentry,
umode_t mode, unsigned int dev);
int (*path_truncate)(struct path *path);
int (*path_symlink)(struct path *dir, struct dentry *dentry,
int (*path_truncate)(const struct path *path);
int (*path_symlink)(const struct path *dir, struct dentry *dentry,
const char *old_name);
int (*path_link)(struct dentry *old_dentry, struct path *new_dir,
int (*path_link)(struct dentry *old_dentry, const struct path *new_dir,
struct dentry *new_dentry);
int (*path_rename)(struct path *old_dir, struct dentry *old_dentry,
struct path *new_dir,
int (*path_rename)(const struct path *old_dir, struct dentry *old_dentry,
const struct path *new_dir,
struct dentry *new_dentry);
int (*path_chmod)(struct path *path, umode_t mode);
int (*path_chown)(struct path *path, kuid_t uid, kgid_t gid);
int (*path_chroot)(struct path *path);
int (*path_chmod)(const struct path *path, umode_t mode);
int (*path_chown)(const struct path *path, kuid_t uid, kgid_t gid);
int (*path_chroot)(const struct path *path);
#endif

int (*inode_alloc_security)(struct inode *inode);
Expand Down
58 changes: 29 additions & 29 deletions include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,10 @@ int security_sb_remount(struct super_block *sb, void *data);
int security_sb_kern_mount(struct super_block *sb, int flags, void *data);
int security_sb_show_options(struct seq_file *m, struct super_block *sb);
int security_sb_statfs(struct dentry *dentry);
int security_sb_mount(const char *dev_name, struct path *path,
int security_sb_mount(const char *dev_name, const struct path *path,
const char *type, unsigned long flags, void *data);
int security_sb_umount(struct vfsmount *mnt, int flags);
int security_sb_pivotroot(struct path *old_path, struct path *new_path);
int security_sb_pivotroot(const struct path *old_path, const struct path *new_path);
int security_sb_set_mnt_opts(struct super_block *sb,
struct security_mnt_opts *opts,
unsigned long kern_flags,
Expand Down Expand Up @@ -544,7 +544,7 @@ static inline int security_sb_statfs(struct dentry *dentry)
return 0;
}

static inline int security_sb_mount(const char *dev_name, struct path *path,
static inline int security_sb_mount(const char *dev_name, const struct path *path,
const char *type, unsigned long flags,
void *data)
{
Expand All @@ -556,8 +556,8 @@ static inline int security_sb_umount(struct vfsmount *mnt, int flags)
return 0;
}

static inline int security_sb_pivotroot(struct path *old_path,
struct path *new_path)
static inline int security_sb_pivotroot(const struct path *old_path,
const struct path *new_path)
{
return 0;
}
Expand Down Expand Up @@ -1456,83 +1456,83 @@ static inline void security_skb_classify_flow(struct sk_buff *skb, struct flowi
#endif /* CONFIG_SECURITY_NETWORK_XFRM */

#ifdef CONFIG_SECURITY_PATH
int security_path_unlink(struct path *dir, struct dentry *dentry);
int security_path_mkdir(struct path *dir, struct dentry *dentry, umode_t mode);
int security_path_rmdir(struct path *dir, struct dentry *dentry);
int security_path_mknod(struct path *dir, struct dentry *dentry, umode_t mode,
int security_path_unlink(const struct path *dir, struct dentry *dentry);
int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t mode);
int security_path_rmdir(const struct path *dir, struct dentry *dentry);
int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
unsigned int dev);
int security_path_truncate(struct path *path);
int security_path_symlink(struct path *dir, struct dentry *dentry,
int security_path_truncate(const struct path *path);
int security_path_symlink(const struct path *dir, struct dentry *dentry,
const char *old_name);
int security_path_link(struct dentry *old_dentry, struct path *new_dir,
int security_path_link(struct dentry *old_dentry, const struct path *new_dir,
struct dentry *new_dentry);
int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
struct path *new_dir, struct dentry *new_dentry,
int security_path_rename(const struct path *old_dir, struct dentry *old_dentry,
const struct path *new_dir, struct dentry *new_dentry,
unsigned int flags);
int security_path_chmod(struct path *path, umode_t mode);
int security_path_chown(struct path *path, kuid_t uid, kgid_t gid);
int security_path_chroot(struct path *path);
int security_path_chmod(const struct path *path, umode_t mode);
int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid);
int security_path_chroot(const struct path *path);
#else /* CONFIG_SECURITY_PATH */
static inline int security_path_unlink(struct path *dir, struct dentry *dentry)
static inline int security_path_unlink(const struct path *dir, struct dentry *dentry)
{
return 0;
}

static inline int security_path_mkdir(struct path *dir, struct dentry *dentry,
static inline int security_path_mkdir(const struct path *dir, struct dentry *dentry,
umode_t mode)
{
return 0;
}

static inline int security_path_rmdir(struct path *dir, struct dentry *dentry)
static inline int security_path_rmdir(const struct path *dir, struct dentry *dentry)
{
return 0;
}

static inline int security_path_mknod(struct path *dir, struct dentry *dentry,
static inline int security_path_mknod(const struct path *dir, struct dentry *dentry,
umode_t mode, unsigned int dev)
{
return 0;
}

static inline int security_path_truncate(struct path *path)
static inline int security_path_truncate(const struct path *path)
{
return 0;
}

static inline int security_path_symlink(struct path *dir, struct dentry *dentry,
static inline int security_path_symlink(const struct path *dir, struct dentry *dentry,
const char *old_name)
{
return 0;
}

static inline int security_path_link(struct dentry *old_dentry,
struct path *new_dir,
const struct path *new_dir,
struct dentry *new_dentry)
{
return 0;
}

static inline int security_path_rename(struct path *old_dir,
static inline int security_path_rename(const struct path *old_dir,
struct dentry *old_dentry,
struct path *new_dir,
const struct path *new_dir,
struct dentry *new_dentry,
unsigned int flags)
{
return 0;
}

static inline int security_path_chmod(struct path *path, umode_t mode)
static inline int security_path_chmod(const struct path *path, umode_t mode)
{
return 0;
}

static inline int security_path_chown(struct path *path, kuid_t uid, kgid_t gid)
static inline int security_path_chown(const struct path *path, kuid_t uid, kgid_t gid)
{
return 0;
}

static inline int security_path_chroot(struct path *path)
static inline int security_path_chroot(const struct path *path)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ static struct sock *unix_find_other(struct net *net,
return NULL;
}

static int unix_mknod(struct dentry *dentry, struct path *path, umode_t mode,
static int unix_mknod(struct dentry *dentry, const struct path *path, umode_t mode,
struct path *res)
{
int err;
Expand Down
4 changes: 2 additions & 2 deletions security/apparmor/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ static inline bool is_deleted(struct dentry *dentry)
*
* Returns: %0 else error if access denied or other error
*/
int aa_path_perm(int op, struct aa_profile *profile, struct path *path,
int aa_path_perm(int op, struct aa_profile *profile, const struct path *path,
int flags, u32 request, struct path_cond *cond)
{
char *buffer = NULL;
Expand Down Expand Up @@ -346,7 +346,7 @@ static inline bool xindex_is_subset(u32 link, u32 target)
* Returns: %0 if allowed else error
*/
int aa_path_link(struct aa_profile *profile, struct dentry *old_dentry,
struct path *new_dir, struct dentry *new_dentry)
const struct path *new_dir, struct dentry *new_dentry)
{
struct path link = { new_dir->mnt, new_dentry };
struct path target = { new_dir->mnt, old_dentry };
Expand Down
4 changes: 2 additions & 2 deletions security/apparmor/include/file.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ unsigned int aa_str_perms(struct aa_dfa *dfa, unsigned int start,
const char *name, struct path_cond *cond,
struct file_perms *perms);

int aa_path_perm(int op, struct aa_profile *profile, struct path *path,
int aa_path_perm(int op, struct aa_profile *profile, const struct path *path,
int flags, u32 request, struct path_cond *cond);

int aa_path_link(struct aa_profile *profile, struct dentry *old_dentry,
struct path *new_dir, struct dentry *new_dentry);
const struct path *new_dir, struct dentry *new_dentry);

int aa_file_perm(int op, struct aa_profile *profile, struct file *file,
u32 request);
Expand Down
2 changes: 1 addition & 1 deletion security/apparmor/include/path.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum path_flags {
PATH_MEDIATE_DELETED = 0x10000, /* mediate deleted paths */
};

int aa_path_name(struct path *path, int flags, char **buffer,
int aa_path_name(const struct path *path, int flags, char **buffer,
const char **name, const char **info);

#endif /* __AA_PATH_H */
Loading

0 comments on commit c52b761

Please sign in to comment.