Browse Source

[patch 3/5] vfs: change remove_suid() to file_remove_suid()

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>
Miklos Szeredi 17 years ago
parent
commit
2f1936b877
7 changed files with 11 additions and 10 deletions
  1. 1 1
      fs/fuse/file.c
  2. 1 1
      fs/ntfs/file.c
  3. 2 2
      fs/splice.c
  4. 1 1
      fs/xfs/linux-2.6/xfs_lrw.c
  5. 1 1
      include/linux/fs.h
  6. 4 3
      mm/filemap.c
  7. 1 1
      mm/filemap_xip.c

+ 1 - 1
fs/fuse/file.c

@@ -893,7 +893,7 @@ static ssize_t fuse_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
 	if (count == 0)
 	if (count == 0)
 		goto out;
 		goto out;
 
 
-	err = remove_suid(file->f_path.dentry);
+	err = file_remove_suid(file);
 	if (err)
 	if (err)
 		goto out;
 		goto out;
 
 

+ 1 - 1
fs/ntfs/file.c

@@ -2118,7 +2118,7 @@ static ssize_t ntfs_file_aio_write_nolock(struct kiocb *iocb,
 		goto out;
 		goto out;
 	if (!count)
 	if (!count)
 		goto out;
 		goto out;
-	err = remove_suid(file->f_path.dentry);
+	err = file_remove_suid(file);
 	if (err)
 	if (err)
 		goto out;
 		goto out;
 	file_update_time(file);
 	file_update_time(file);

+ 2 - 2
fs/splice.c

@@ -772,7 +772,7 @@ generic_file_splice_write_nolock(struct pipe_inode_info *pipe, struct file *out,
 	ssize_t ret;
 	ssize_t ret;
 	int err;
 	int err;
 
 
-	err = remove_suid(out->f_path.dentry);
+	err = file_remove_suid(out);
 	if (unlikely(err))
 	if (unlikely(err))
 		return err;
 		return err;
 
 
@@ -830,7 +830,7 @@ generic_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
 	ssize_t ret;
 	ssize_t ret;
 
 
 	inode_double_lock(inode, pipe->inode);
 	inode_double_lock(inode, pipe->inode);
-	ret = remove_suid(out->f_path.dentry);
+	ret = file_remove_suid(out);
 	if (likely(!ret))
 	if (likely(!ret))
 		ret = __splice_from_pipe(pipe, &sd, pipe_to_file);
 		ret = __splice_from_pipe(pipe, &sd, pipe_to_file);
 	inode_double_unlock(inode, pipe->inode);
 	inode_double_unlock(inode, pipe->inode);

+ 1 - 1
fs/xfs/linux-2.6/xfs_lrw.c

@@ -711,7 +711,7 @@ start:
 	     !capable(CAP_FSETID)) {
 	     !capable(CAP_FSETID)) {
 		error = xfs_write_clear_setuid(xip);
 		error = xfs_write_clear_setuid(xip);
 		if (likely(!error))
 		if (likely(!error))
-			error = -remove_suid(file->f_path.dentry);
+			error = -file_remove_suid(file);
 		if (unlikely(error)) {
 		if (unlikely(error)) {
 			goto out_unlock_internal;
 			goto out_unlock_internal;
 		}
 		}

+ 1 - 1
include/linux/fs.h

@@ -1834,7 +1834,7 @@ extern void clear_inode(struct inode *);
 extern void destroy_inode(struct inode *);
 extern void destroy_inode(struct inode *);
 extern struct inode *new_inode(struct super_block *);
 extern struct inode *new_inode(struct super_block *);
 extern int should_remove_suid(struct dentry *);
 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 __insert_inode_hash(struct inode *, unsigned long hashval);
 extern void remove_inode_hash(struct inode *);
 extern void remove_inode_hash(struct inode *);

+ 4 - 3
mm/filemap.c

@@ -1758,8 +1758,9 @@ static int __remove_suid(struct dentry *dentry, int kill)
 	return notify_change(dentry, &newattrs);
 	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 killsuid = should_remove_suid(dentry);
 	int killpriv = security_inode_need_killpriv(dentry);
 	int killpriv = security_inode_need_killpriv(dentry);
 	int error = 0;
 	int error = 0;
@@ -1773,7 +1774,7 @@ int remove_suid(struct dentry *dentry)
 
 
 	return error;
 	return error;
 }
 }
-EXPORT_SYMBOL(remove_suid);
+EXPORT_SYMBOL(file_remove_suid);
 
 
 static size_t __iovec_copy_from_user_inatomic(char *vaddr,
 static size_t __iovec_copy_from_user_inatomic(char *vaddr,
 			const struct iovec *iov, size_t base, size_t bytes)
 			const struct iovec *iov, size_t base, size_t bytes)
@@ -2529,7 +2530,7 @@ __generic_file_aio_write_nolock(struct kiocb *iocb, const struct iovec *iov,
 	if (count == 0)
 	if (count == 0)
 		goto out;
 		goto out;
 
 
-	err = remove_suid(file->f_path.dentry);
+	err = file_remove_suid(file);
 	if (err)
 	if (err)
 		goto out;
 		goto out;
 
 

+ 1 - 1
mm/filemap_xip.c

@@ -380,7 +380,7 @@ xip_file_write(struct file *filp, const char __user *buf, size_t len,
 	if (count == 0)
 	if (count == 0)
 		goto out_backing;
 		goto out_backing;
 
 
-	ret = remove_suid(filp->f_path.dentry);
+	ret = file_remove_suid(filp);
 	if (ret)
 	if (ret)
 		goto out_backing;
 		goto out_backing;