From 7ed85d003e6062747f6abb19fb95cd75e87fe05e Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 17 Oct 2006 19:50:36 +0200 Subject: [PATCH] --- yaml --- r: 40101 b: refs/heads/master c: 01de85e057328ecbef36e108673b1e81059d54c1 h: refs/heads/master i: 40099: 7b970d76ba95e8abcbf39784c57566dbfd0225cf v: v3 --- [refs] | 2 +- trunk/include/linux/fs.h | 2 ++ trunk/mm/filemap.c | 30 ++++++++++++++++++++++-------- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index 513c6ab988f5..c8130dbff38c 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 6da61809822c22634a3de2dcb3c60283b836a88a +refs/heads/master: 01de85e057328ecbef36e108673b1e81059d54c1 diff --git a/trunk/include/linux/fs.h b/trunk/include/linux/fs.h index d695ba2346a3..2fe6e3f900ba 100644 --- a/trunk/include/linux/fs.h +++ b/trunk/include/linux/fs.h @@ -1712,6 +1712,8 @@ extern void __iget(struct inode * inode); extern void clear_inode(struct inode *); extern void destroy_inode(struct inode *); extern struct inode *new_inode(struct super_block *); +extern int __remove_suid(struct dentry *, int); +extern int should_remove_suid(struct dentry *); extern int remove_suid(struct dentry *); extern void remove_dquot_ref(struct super_block *, int, struct list_head *); diff --git a/trunk/mm/filemap.c b/trunk/mm/filemap.c index 3464b681f844..7c7addb9333c 100644 --- a/trunk/mm/filemap.c +++ b/trunk/mm/filemap.c @@ -1884,11 +1884,10 @@ __grab_cache_page(struct address_space *mapping, unsigned long index, * if suid or (sgid and xgrp) * remove privs */ -int remove_suid(struct dentry *dentry) +int should_remove_suid(struct dentry *dentry) { mode_t mode = dentry->d_inode->i_mode; int kill = 0; - int result = 0; /* suid always must be killed */ if (unlikely(mode & S_ISUID)) @@ -1901,13 +1900,28 @@ int remove_suid(struct dentry *dentry) if (unlikely((mode & S_ISGID) && (mode & S_IXGRP))) kill |= ATTR_KILL_SGID; - if (unlikely(kill && !capable(CAP_FSETID))) { - struct iattr newattrs; + if (unlikely(kill && !capable(CAP_FSETID))) + return kill; - newattrs.ia_valid = ATTR_FORCE | kill; - result = notify_change(dentry, &newattrs); - } - return result; + return 0; +} + +int __remove_suid(struct dentry *dentry, int kill) +{ + struct iattr newattrs; + + newattrs.ia_valid = ATTR_FORCE | kill; + return notify_change(dentry, &newattrs); +} + +int remove_suid(struct dentry *dentry) +{ + int kill = should_remove_suid(dentry); + + if (unlikely(kill)) + return __remove_suid(dentry, kill); + + return 0; } EXPORT_SYMBOL(remove_suid);