Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 70761
b: refs/heads/master
c: e8e9615
h: refs/heads/master
i:
  70759: e2db253
v: v3
  • Loading branch information
Miklos Szeredi authored and Linus Torvalds committed Oct 17, 2007
1 parent d65d0e0 commit 04f8ab2
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 19 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: c9c9d7df5f8aed8b738f1ace45700e2001c1faeb
refs/heads/master: e8e961574b5b417d3fc277cbf436081fce4fc2e1
49 changes: 31 additions & 18 deletions trunk/fs/fuse/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,20 @@ static int fuse_do_getattr(struct inode *inode)
return err;
}

/*
* Check if attributes are still valid, and if not send a GETATTR
* request to refresh them.
*/
static int fuse_refresh_attributes(struct inode *inode)
{
struct fuse_inode *fi = get_fuse_inode(inode);

if (fi->i_time < get_jiffies_64())
return fuse_do_getattr(inode);
else
return 0;
}

/*
* Calling into a user-controlled filesystem gives the filesystem
* daemon ptrace-like capabilities over the requester process. This
Expand Down Expand Up @@ -770,20 +784,18 @@ static int fuse_access(struct inode *inode, int mask)
static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
{
struct fuse_conn *fc = get_fuse_conn(inode);
struct fuse_inode *fi = get_fuse_inode(inode);
bool refreshed = false;
int err = 0;

if (!fuse_allow_task(fc, current))
return -EACCES;

/*
* If attributes are needed, but are stale, refresh them
* before proceeding
* If attributes are needed, refresh them before proceeding
*/
if (((fc->flags & FUSE_DEFAULT_PERMISSIONS) || (mask & MAY_EXEC)) &&
fi->i_time < get_jiffies_64()) {
err = fuse_do_getattr(inode);
if ((fc->flags & FUSE_DEFAULT_PERMISSIONS) ||
((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) {
err = fuse_refresh_attributes(inode);
if (err)
return err;

Expand All @@ -806,14 +818,17 @@ static int fuse_permission(struct inode *inode, int mask, struct nameidata *nd)
exist. So if permissions are revoked this won't be
noticed immediately, only after the attribute
timeout has expired */

} else {
int mode = inode->i_mode;
if ((mask & MAY_EXEC) && !S_ISDIR(mode) && !(mode & S_IXUGO))
return -EACCES;

if (nd && (nd->flags & (LOOKUP_ACCESS | LOOKUP_CHDIR)))
return fuse_access(inode, mask);
} else if (nd && (nd->flags & (LOOKUP_ACCESS | LOOKUP_CHDIR))) {
err = fuse_access(inode, mask);
} else if ((mask & MAY_EXEC) && S_ISREG(inode->i_mode)) {
if (!(inode->i_mode & S_IXUGO)) {
if (refreshed)
return -EACCES;

err = fuse_do_getattr(inode);
if (!err && !(inode->i_mode & S_IXUGO))
return -EACCES;
}
}
return err;
}
Expand Down Expand Up @@ -1046,14 +1061,12 @@ static int fuse_getattr(struct vfsmount *mnt, struct dentry *entry,
struct inode *inode = entry->d_inode;
struct fuse_inode *fi = get_fuse_inode(inode);
struct fuse_conn *fc = get_fuse_conn(inode);
int err = 0;
int err;

if (!fuse_allow_task(fc, current))
return -EACCES;

if (fi->i_time < get_jiffies_64())
err = fuse_do_getattr(inode);

err = fuse_refresh_attributes(inode);
if (!err) {
generic_fillattr(inode, stat);
stat->mode = fi->orig_i_mode;
Expand Down

0 comments on commit 04f8ab2

Please sign in to comment.