Skip to content

Commit

Permalink
[patch 3/5] vfs: change remove_suid() to file_remove_suid()
Browse files Browse the repository at this point in the history
All calls to remove_suid() are made with a file pointer, because
(similarly to file_update_time) it is called when the file is written.

Clean up callers by passing in a file instead of a dentry.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
  • Loading branch information
Miklos Szeredi authored and Al Viro committed Jul 27, 2008
1 parent c82e42d commit 2f1936b
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion fs/fuse/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
if (count == 0)
goto out;

err = remove_suid(file->f_path.dentry);
err = file_remove_suid(file);
if (err)
goto out;

Expand Down
2 changes: 1 addition & 1 deletion fs/ntfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ static ssize_t ntfs_file_aio_write_nolock(struct kiocb *iocb,
goto out;
if (!count)
goto out;
err = remove_suid(file->f_path.dentry);
err = file_remove_suid(file);
if (err)
goto out;
file_update_time(file);
Expand Down
4 changes: 2 additions & 2 deletions fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,
ssize_t ret;
int err;

err = remove_suid(out->f_path.dentry);
err = file_remove_suid(out);
if (unlikely(err))
return err;

Expand Down Expand Up @@ -830,7 +830,7 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
ssize_t ret;

inode_double_lock(inode, pipe->inode);
ret = remove_suid(out->f_path.dentry);
ret = file_remove_suid(out);
if (likely(!ret))
ret = __splice_from_pipe(pipe, &sd, pipe_to_file);
inode_double_unlock(inode, pipe->inode);
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/linux-2.6/xfs_lrw.c
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ xfs_write(
!capable(CAP_FSETID)) {
error = xfs_write_clear_setuid(xip);
if (likely(!error))
error = -remove_suid(file->f_path.dentry);
error = -file_remove_suid(file);
if (unlikely(error)) {
goto out_unlock_internal;
}
Expand Down
2 changes: 1 addition & 1 deletion include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1834,7 +1834,7 @@ extern void clear_inode(struct inode *);
extern void destroy_inode(struct inode *);
extern struct inode *new_inode(struct super_block *);
extern int should_remove_suid(struct dentry *);
extern int remove_suid(struct dentry *);
extern int file_remove_suid(struct file *);

extern void __insert_inode_hash(struct inode *, unsigned long hashval);
extern void remove_inode_hash(struct inode *);
Expand Down
7 changes: 4 additions & 3 deletions mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1758,8 +1758,9 @@ static int __remove_suid(struct dentry *dentry, int kill)
return notify_change(dentry, &newattrs);
}

int remove_suid(struct dentry *dentry)
int file_remove_suid(struct file *file)
{
struct dentry *dentry = file->f_path.dentry;
int killsuid = should_remove_suid(dentry);
int killpriv = security_inode_need_killpriv(dentry);
int error = 0;
Expand All @@ -1773,7 +1774,7 @@ int remove_suid(struct dentry *dentry)

return error;
}
EXPORT_SYMBOL(remove_suid);
EXPORT_SYMBOL(file_remove_suid);

static size_t __iovec_copy_from_user_inatomic(char *vaddr,
const struct iovec *iov, size_t base, size_t bytes)
Expand Down Expand Up @@ -2529,7 +2530,7 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
if (count == 0)
goto out;

err = remove_suid(file->f_path.dentry);
err = file_remove_suid(file);
if (err)
goto out;

Expand Down
2 changes: 1 addition & 1 deletion mm/filemap_xip.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len,
if (count == 0)
goto out_backing;

ret = remove_suid(filp->f_path.dentry);
ret = file_remove_suid(filp);
if (ret)
goto out_backing;

Expand Down

0 comments on commit 2f1936b

Please sign in to comment.