diff options
author | Prem Karat <prem.karat@linux.vnet.ibm.com> | 2011-05-06 08:54:18 -0400 |
---|---|---|
committer | Eric Van Hensbergen <ericvh@gmail.com> | 2011-07-23 10:32:48 -0400 |
commit | a2dd43bb0d7b9ce28f8a39254c25840c0730498e (patch) | |
tree | 83b487379263d273549aefd0528edf24b602e47e | |
parent | fd2421f54423f307ecd31bdebdca6bc317e0c492 (diff) |
fs/9p: Fix invalid mount options/args
Without this fix, if any invalid mount options/args are passed while mouting
the 9p fs, no error (-EINVAL) is returned and default arg value is assigned.
This fix returns -EINVAL when an invalid arguement is found while parsing
mount options.
Signed-off-by: Prem Karat <prem.karat@linux.vnet.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>
-rw-r--r-- | fs/9p/v9fs.c | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c index 8b7c6be2450b..ef9661886112 100644 --- a/fs/9p/v9fs.c +++ b/fs/9p/v9fs.c | |||
@@ -78,6 +78,25 @@ static const match_table_t tokens = { | |||
78 | {Opt_err, NULL} | 78 | {Opt_err, NULL} |
79 | }; | 79 | }; |
80 | 80 | ||
81 | /* Interpret mount options for cache mode */ | ||
82 | static int get_cache_mode(char *s) | ||
83 | { | ||
84 | int version = -EINVAL; | ||
85 | |||
86 | if (!strcmp(s, "loose")) { | ||
87 | version = CACHE_LOOSE; | ||
88 | P9_DPRINTK(P9_DEBUG_9P, "Cache mode: loose\n"); | ||
89 | } else if (!strcmp(s, "fscache")) { | ||
90 | version = CACHE_FSCACHE; | ||
91 | P9_DPRINTK(P9_DEBUG_9P, "Cache mode: fscache\n"); | ||
92 | } else if (!strcmp(s, "none")) { | ||
93 | version = CACHE_NONE; | ||
94 | P9_DPRINTK(P9_DEBUG_9P, "Cache mode: none\n"); | ||
95 | } else | ||
96 | printk(KERN_INFO "9p: Unknown Cache mode %s.\n", s); | ||
97 | return version; | ||
98 | } | ||
99 | |||
81 | /** | 100 | /** |
82 | * v9fs_parse_options - parse mount options into session structure | 101 | * v9fs_parse_options - parse mount options into session structure |
83 | * @v9ses: existing v9fs session information | 102 | * @v9ses: existing v9fs session information |
@@ -97,7 +116,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
97 | /* setup defaults */ | 116 | /* setup defaults */ |
98 | v9ses->afid = ~0; | 117 | v9ses->afid = ~0; |
99 | v9ses->debug = 0; | 118 | v9ses->debug = 0; |
100 | v9ses->cache = 0; | 119 | v9ses->cache = CACHE_NONE; |
101 | #ifdef CONFIG_9P_FSCACHE | 120 | #ifdef CONFIG_9P_FSCACHE |
102 | v9ses->cachetag = NULL; | 121 | v9ses->cachetag = NULL; |
103 | #endif | 122 | #endif |
@@ -171,13 +190,13 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
171 | "problem allocating copy of cache arg\n"); | 190 | "problem allocating copy of cache arg\n"); |
172 | goto free_and_return; | 191 | goto free_and_return; |
173 | } | 192 | } |
193 | ret = get_cache_mode(s); | ||
194 | if (ret == -EINVAL) { | ||
195 | kfree(s); | ||
196 | goto free_and_return; | ||
197 | } | ||
174 | 198 | ||
175 | if (strcmp(s, "loose") == 0) | 199 | v9ses->cache = ret; |
176 | v9ses->cache = CACHE_LOOSE; | ||
177 | else if (strcmp(s, "fscache") == 0) | ||
178 | v9ses->cache = CACHE_FSCACHE; | ||
179 | else | ||
180 | v9ses->cache = CACHE_NONE; | ||
181 | kfree(s); | 200 | kfree(s); |
182 | break; | 201 | break; |
183 | 202 | ||
@@ -200,9 +219,15 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts) | |||
200 | } else { | 219 | } else { |
201 | v9ses->flags |= V9FS_ACCESS_SINGLE; | 220 | v9ses->flags |= V9FS_ACCESS_SINGLE; |
202 | v9ses->uid = simple_strtoul(s, &e, 10); | 221 | v9ses->uid = simple_strtoul(s, &e, 10); |
203 | if (*e != '\0') | 222 | if (*e != '\0') { |
204 | v9ses->uid = ~0; | 223 | ret = -EINVAL; |
224 | printk(KERN_INFO "9p: Unknown access " | ||
225 | "argument %s.\n", s); | ||
226 | kfree(s); | ||
227 | goto free_and_return; | ||
228 | } | ||
205 | } | 229 | } |
230 | |||
206 | kfree(s); | 231 | kfree(s); |
207 | break; | 232 | break; |
208 | 233 | ||