Skip to content

Commit

Permalink
LSM: Remove unused arguments from security_path_truncate().
Browse files Browse the repository at this point in the history
When commit be6d3e5 "introduce new LSM hooks
where vfsmount is available." was proposed, regarding security_path_truncate(),
only "struct file *" argument (which AppArmor wanted to use) was removed.
But length and time_attrs arguments are not used by TOMOYO nor AppArmor.
Thus, let's remove these arguments.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Nick Piggin <npiggin@suse.de>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
Tetsuo Handa authored and James Morris committed Aug 2, 2010
1 parent 3e62cbb commit ea0d3ab
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 20 deletions.
3 changes: 1 addition & 2 deletions fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -1484,8 +1484,7 @@ static int handle_truncate(struct path *path)
*/
error = locks_verify_locked(inode);
if (!error)
error = security_path_truncate(path, 0,
ATTR_MTIME|ATTR_CTIME|ATTR_OPEN);
error = security_path_truncate(path);
if (!error) {
error = do_truncate(path->dentry, 0,
ATTR_MTIME|ATTR_CTIME|ATTR_OPEN,
Expand Down
5 changes: 2 additions & 3 deletions fs/open.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static long do_sys_truncate(const char __user *pathname, loff_t length)

error = locks_verify_truncate(inode, NULL, length);
if (!error)
error = security_path_truncate(&path, length, 0);
error = security_path_truncate(&path);
if (!error)
error = do_truncate(path.dentry, length, 0, NULL);

Expand Down Expand Up @@ -165,8 +165,7 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)

error = locks_verify_truncate(inode, file, length);
if (!error)
error = security_path_truncate(&file->f_path, length,
ATTR_MTIME|ATTR_CTIME);
error = security_path_truncate(&file->f_path);
if (!error)
error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, file);
out_putf:
Expand Down
11 changes: 3 additions & 8 deletions include/linux/security.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,6 @@ static inline void security_free_mnt_opts(struct security_mnt_opts *opts)
* @path_truncate:
* Check permission before truncating a file.
* @path contains the path structure for the file.
* @length is the new length of the file.
* @time_attrs is the flags passed to do_truncate().
* Return 0 if permission is granted.
* @inode_getattr:
* Check permission before obtaining file attributes.
Expand Down Expand Up @@ -1412,8 +1410,7 @@ struct security_operations {
int (*path_rmdir) (struct path *dir, struct dentry *dentry);
int (*path_mknod) (struct path *dir, struct dentry *dentry, int mode,
unsigned int dev);
int (*path_truncate) (struct path *path, loff_t length,
unsigned int time_attrs);
int (*path_truncate) (struct path *path);
int (*path_symlink) (struct path *dir, struct dentry *dentry,
const char *old_name);
int (*path_link) (struct dentry *old_dentry, struct path *new_dir,
Expand Down Expand Up @@ -2806,8 +2803,7 @@ int security_path_mkdir(struct path *dir, struct dentry *dentry, int mode);
int security_path_rmdir(struct path *dir, struct dentry *dentry);
int security_path_mknod(struct path *dir, struct dentry *dentry, int mode,
unsigned int dev);
int security_path_truncate(struct path *path, loff_t length,
unsigned int time_attrs);
int security_path_truncate(struct path *path);
int security_path_symlink(struct path *dir, struct dentry *dentry,
const char *old_name);
int security_path_link(struct dentry *old_dentry, struct path *new_dir,
Expand Down Expand Up @@ -2841,8 +2837,7 @@ static inline int security_path_mknod(struct path *dir, struct dentry *dentry,
return 0;
}

static inline int security_path_truncate(struct path *path, loff_t length,
unsigned int time_attrs)
static inline int security_path_truncate(struct path *path)
{
return 0;
}
Expand Down
3 changes: 1 addition & 2 deletions security/capability.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,7 @@ static int cap_path_rename(struct path *old_path, struct dentry *old_dentry,
return 0;
}

static int cap_path_truncate(struct path *path, loff_t length,
unsigned int time_attrs)
static int cap_path_truncate(struct path *path)
{
return 0;
}
Expand Down
5 changes: 2 additions & 3 deletions security/security.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,12 +417,11 @@ int security_path_rename(struct path *old_dir, struct dentry *old_dentry,
new_dentry);
}

int security_path_truncate(struct path *path, loff_t length,
unsigned int time_attrs)
int security_path_truncate(struct path *path)
{
if (unlikely(IS_PRIVATE(path->dentry->d_inode)))
return 0;
return security_ops->path_truncate(path, length, time_attrs);
return security_ops->path_truncate(path);
}

int security_path_chmod(struct dentry *dentry, struct vfsmount *mnt,
Expand Down
3 changes: 1 addition & 2 deletions security/tomoyo/tomoyo.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ static int tomoyo_bprm_check_security(struct linux_binprm *bprm)
return tomoyo_check_open_permission(domain, &bprm->file->f_path, O_RDONLY);
}

static int tomoyo_path_truncate(struct path *path, loff_t length,
unsigned int time_attrs)
static int tomoyo_path_truncate(struct path *path)
{
return tomoyo_path_perm(TOMOYO_TYPE_TRUNCATE, path);
}
Expand Down

0 comments on commit ea0d3ab

Please sign in to comment.