From: Miklos Szeredi <miklos@szeredi.hu>
To: linux-fsdevel@vger.kernel.org
Cc: hch@infradead.org, viro@ZenIV.linux.org.uk, linux-kernel@vger.kernel.org
Subject: [patch 8/8] vfs: create file_remove_suid() helper
Date: Thu, 29 May 2008 13:32:53 +0200 [thread overview]
Message-ID: <20080529113318.257547449@szeredi.hu> (raw)
In-Reply-To: <20080529113245.450308367@szeredi.hu>
[-- Attachment #1: file_remove_suid.patch --]
[-- Type: text/plain, Size: 4989 bytes --]
From: Miklos Szeredi <mszeredi@suse.cz>
All calls to remove_suid() are made with a file pointer. This is not
accidental: similarly to file_update_time(), this function is called
when the file is written.
So simplify callers by passing the file pointer instead of the dentry.
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
fs/fuse/file.c | 2 +-
fs/ntfs/file.c | 2 +-
fs/splice.c | 4 ++--
fs/xfs/linux-2.6/xfs_lrw.c | 2 +-
include/linux/fs.h | 2 +-
mm/filemap.c | 7 ++++---
mm/filemap_xip.c | 2 +-
7 files changed, 11 insertions(+), 10 deletions(-)
Index: linux-2.6/fs/ntfs/file.c
===================================================================
--- linux-2.6.orig/fs/ntfs/file.c 2008-05-29 12:46:19.000000000 +0200
+++ linux-2.6/fs/ntfs/file.c 2008-05-29 12:46:26.000000000 +0200
@@ -2118,7 +2118,7 @@ static ssize_t ntfs_file_aio_write_noloc
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);
Index: linux-2.6/fs/splice.c
===================================================================
--- linux-2.6.orig/fs/splice.c 2008-05-29 12:46:19.000000000 +0200
+++ linux-2.6/fs/splice.c 2008-05-29 12:46:26.000000000 +0200
@@ -762,7 +762,7 @@ generic_file_splice_write_nolock(struct
ssize_t ret;
int err;
- err = remove_suid(out->f_path.dentry);
+ err = file_remove_suid(out);
if (unlikely(err))
return err;
@@ -820,7 +820,7 @@ generic_file_splice_write(struct pipe_in
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);
Index: linux-2.6/fs/xfs/linux-2.6/xfs_lrw.c
===================================================================
--- linux-2.6.orig/fs/xfs/linux-2.6/xfs_lrw.c 2008-05-29 12:46:19.000000000 +0200
+++ linux-2.6/fs/xfs/linux-2.6/xfs_lrw.c 2008-05-29 12:46:26.000000000 +0200
@@ -711,7 +711,7 @@ start:
!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;
}
Index: linux-2.6/include/linux/fs.h
===================================================================
--- linux-2.6.orig/include/linux/fs.h 2008-05-29 12:46:25.000000000 +0200
+++ linux-2.6/include/linux/fs.h 2008-05-29 12:46:26.000000000 +0200
@@ -1850,7 +1850,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 *);
Index: linux-2.6/mm/filemap.c
===================================================================
--- linux-2.6.orig/mm/filemap.c 2008-05-29 12:46:19.000000000 +0200
+++ linux-2.6/mm/filemap.c 2008-05-29 12:46:26.000000000 +0200
@@ -1668,8 +1668,9 @@ static int __remove_suid(struct dentry *
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;
@@ -1683,7 +1684,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)
@@ -2394,7 +2395,7 @@ __generic_file_aio_write_nolock(struct k
if (count == 0)
goto out;
- err = remove_suid(file->f_path.dentry);
+ err = file_remove_suid(file);
if (err)
goto out;
Index: linux-2.6/mm/filemap_xip.c
===================================================================
--- linux-2.6.orig/mm/filemap_xip.c 2008-05-29 12:46:19.000000000 +0200
+++ linux-2.6/mm/filemap_xip.c 2008-05-29 12:46:26.000000000 +0200
@@ -380,7 +380,7 @@ xip_file_write(struct file *filp, const
if (count == 0)
goto out_backing;
- ret = remove_suid(filp->f_path.dentry);
+ ret = file_remove_suid(filp);
if (ret)
goto out_backing;
Index: linux-2.6/fs/fuse/file.c
===================================================================
--- linux-2.6.orig/fs/fuse/file.c 2008-05-29 12:46:19.000000000 +0200
+++ linux-2.6/fs/fuse/file.c 2008-05-29 12:46:26.000000000 +0200
@@ -893,7 +893,7 @@ static ssize_t fuse_file_aio_write(struc
if (count == 0)
goto out;
- err = remove_suid(file->f_path.dentry);
+ err = file_remove_suid(file);
if (err)
goto out;
--
next prev parent reply other threads:[~2008-05-29 11:36 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-29 11:32 [patch 0/8] vfs: more cleanups and fixes Miklos Szeredi
2008-05-29 11:32 ` [patch 1/8] vfs: dcache cleanups Miklos Szeredi
2008-05-29 12:23 ` Matthew Wilcox
2008-05-31 8:18 ` Christoph Hellwig
2008-05-29 11:32 ` [patch 2/8] vfs: fix sys_getcwd for detached mounts Miklos Szeredi
2008-05-31 8:20 ` Christoph Hellwig
2008-05-29 11:32 ` [patch 3/8] Make d_path() consistent across mount operations Miklos Szeredi
2008-05-31 8:22 ` Christoph Hellwig
2008-06-01 20:38 ` Miklos Szeredi
2008-06-02 5:55 ` Christoph Hellwig
2008-05-29 11:32 ` [patch 4/8] nfsd: rename MAY_ flags Miklos Szeredi
2008-05-29 12:47 ` Christoph Hellwig
2008-05-29 14:02 ` Miklos Szeredi
2008-05-29 20:40 ` J. Bruce Fields
2008-05-30 7:36 ` Christoph Hellwig
2008-05-30 9:07 ` Miklos Szeredi
2008-05-30 9:53 ` Miklos Szeredi
2008-05-30 20:12 ` J. Bruce Fields
2008-05-29 11:32 ` [patch 5/8] vfs: annotate permission operations Miklos Szeredi
2008-05-31 8:23 ` Christoph Hellwig
2008-05-29 11:32 ` [patch 6/8] Factor out sysctl pathname code Miklos Szeredi
2008-05-31 8:27 ` Christoph Hellwig
2008-06-03 13:34 ` Stephen Smalley
2008-05-29 11:32 ` [patch 7/8] vfs: clean up getattr API Miklos Szeredi
2008-05-29 11:32 ` Miklos Szeredi [this message]
2008-05-31 8:29 ` [patch 8/8] vfs: create file_remove_suid() helper Christoph Hellwig
2008-06-01 20:45 ` Miklos Szeredi
2008-06-02 6:05 ` Christoph Hellwig
2008-06-02 7:06 ` Miklos Szeredi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080529113318.257547449@szeredi.hu \
--to=miklos@szeredi.hu \
--cc=hch@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®