diff options
author | Timo Savola <tsavola@movial.fi> | 2007-04-08 19:04:00 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-08 22:47:55 -0400 |
commit | a5bfffac645a7b2d8119f8bbae34df5c94832799 (patch) | |
tree | 20081cd9ae9afebd6899dd35d5d685ed6fca5440 /fs | |
parent | d354d2f4a6fc1b722c2e464a8b3cfd2f6afb304b (diff) |
[PATCH] fuse: validate rootmode mount option
If rootmode isn't valid, we hit the BUG() in fuse_init_inode. Now
EINVAL is returned.
Signed-off-by: Timo Savola <tsavola@movial.fi>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fuse/dir.c | 5 | ||||
-rw-r--r-- | fs/fuse/fuse_i.h | 5 | ||||
-rw-r--r-- | fs/fuse/inode.c | 2 |
3 files changed, 10 insertions, 2 deletions
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 406bf61ed510..8890eba1db52 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -195,7 +195,7 @@ static struct dentry_operations fuse_dentry_operations = { | |||
195 | .d_revalidate = fuse_dentry_revalidate, | 195 | .d_revalidate = fuse_dentry_revalidate, |
196 | }; | 196 | }; |
197 | 197 | ||
198 | static int valid_mode(int m) | 198 | int fuse_valid_type(int m) |
199 | { | 199 | { |
200 | return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) || | 200 | return S_ISREG(m) || S_ISDIR(m) || S_ISLNK(m) || S_ISCHR(m) || |
201 | S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m); | 201 | S_ISBLK(m) || S_ISFIFO(m) || S_ISSOCK(m); |
@@ -248,7 +248,8 @@ static struct dentry *fuse_lookup(struct inode *dir, struct dentry *entry, | |||
248 | fuse_put_request(fc, req); | 248 | fuse_put_request(fc, req); |
249 | /* Zero nodeid is same as -ENOENT, but with valid timeout */ | 249 | /* Zero nodeid is same as -ENOENT, but with valid timeout */ |
250 | if (!err && outarg.nodeid && | 250 | if (!err && outarg.nodeid && |
251 | (invalid_nodeid(outarg.nodeid) || !valid_mode(outarg.attr.mode))) | 251 | (invalid_nodeid(outarg.nodeid) || |
252 | !fuse_valid_type(outarg.attr.mode))) | ||
252 | err = -EIO; | 253 | err = -EIO; |
253 | if (!err && outarg.nodeid) { | 254 | if (!err && outarg.nodeid) { |
254 | inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, | 255 | inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, |
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index b98b20de7405..68ae87cbafab 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -552,3 +552,8 @@ int fuse_ctl_add_conn(struct fuse_conn *fc); | |||
552 | * Remove connection from control filesystem | 552 | * Remove connection from control filesystem |
553 | */ | 553 | */ |
554 | void fuse_ctl_remove_conn(struct fuse_conn *fc); | 554 | void fuse_ctl_remove_conn(struct fuse_conn *fc); |
555 | |||
556 | /** | ||
557 | * Is file type valid? | ||
558 | */ | ||
559 | int fuse_valid_type(int m); | ||
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 5ab8e50e7808..608db81219a0 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -330,6 +330,8 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev) | |||
330 | case OPT_ROOTMODE: | 330 | case OPT_ROOTMODE: |
331 | if (match_octal(&args[0], &value)) | 331 | if (match_octal(&args[0], &value)) |
332 | return 0; | 332 | return 0; |
333 | if (!fuse_valid_type(value)) | ||
334 | return 0; | ||
333 | d->rootmode = value; | 335 | d->rootmode = value; |
334 | d->rootmode_present = 1; | 336 | d->rootmode_present = 1; |
335 | break; | 337 | break; |