diff options
author | Paolo \'Blaisorblade\' Giarrusso <blaisorblade@yahoo.it> | 2005-03-30 16:36:12 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-03-30 16:36:12 -0800 |
commit | ade05d5c38568078b747d3c192125c6d768d94be (patch) | |
tree | e90904f9b3f6252e68287e95cb22ec23f0a1aebe | |
parent | b5ee361de4568bc22f11673476c8b0df04e5e366 (diff) | |
download | history-ade05d5c38568078b747d3c192125c6d768d94be.tar.gz |
[PATCH] uml: fix hostfs special perm handling
When opening devices nodes on hostfs, it does not make sense to call access(),
since we are not going to open the file on the host.
If the device node is owned by root, the root user in UML should succeed in
opening it, even if UML won't be able to open the file.
As reported by Rob Landley, UML currently does not follow this, so here's a
fix.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
CC: Rob Landley <rob@landley.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | fs/hostfs/hostfs_kern.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c index cfb9801f6ccffb..a88ad292485110 100644 --- a/fs/hostfs/hostfs_kern.c +++ b/fs/hostfs/hostfs_kern.c @@ -806,15 +806,21 @@ int hostfs_permission(struct inode *ino, int desired, struct nameidata *nd) char *name; int r = 0, w = 0, x = 0, err; - if(desired & MAY_READ) r = 1; - if(desired & MAY_WRITE) w = 1; - if(desired & MAY_EXEC) x = 1; + if (desired & MAY_READ) r = 1; + if (desired & MAY_WRITE) w = 1; + if (desired & MAY_EXEC) x = 1; name = inode_name(ino, 0); - if(name == NULL) return(-ENOMEM); - err = access_file(name, r, w, x); + if (name == NULL) return(-ENOMEM); + + if (S_ISCHR(ino->i_mode) || S_ISBLK(ino->i_mode) || + S_ISFIFO(ino->i_mode) || S_ISSOCK(ino->i_mode)) + err = 0; + else + err = access_file(name, r, w, x); kfree(name); - if(!err) err = generic_permission(ino, desired, NULL); - return(err); + if(!err) + err = generic_permission(ino, desired, NULL); + return err; } int hostfs_setattr(struct dentry *dentry, struct iattr *attr) |