Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 40101
b: refs/heads/master
c: 01de85e
h: refs/heads/master
i:
  40099: 7b970d7
v: v3
  • Loading branch information
Jens Axboe authored and Jens Axboe committed Oct 19, 2006
1 parent 252f5ad commit 7ed85d0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6da61809822c22634a3de2dcb3c60283b836a88a
refs/heads/master: 01de85e057328ecbef36e108673b1e81059d54c1
2 changes: 2 additions & 0 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down
30 changes: 22 additions & 8 deletions trunk/mm/filemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);

Expand Down

0 comments on commit 7ed85d0

Please sign in to comment.