aboutsummaryrefslogtreecommitdiffstats
path: root/fs/9p
diff options
context:
space:
mode:
authorChengguang Xu <cgxu519@gmx.com>2018-06-07 20:05:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-07 20:34:34 -0400
commit478ae0ca08c239e83803191317ae99d66708306c (patch)
treecf5b694e217e98f2103e2086576063d394b295bc /fs/9p
parent8d856c72b42d585fb17a8aa18454e03a0cf9b2b8 (diff)
fs/9p: detect invalid options as much as possible
Currently when detecting invalid options in option parsing, some options(e.g. msize) just set errno and allow to continuously validate other options so that it can detect invalid options as much as possible and give proper error messages together. This patch applies same rule to option 'cache' and 'access' when detecting -EINVAL. Link: http://lkml.kernel.org/r/1525340676-34072-2-git-send-email-cgxu519@gmx.com Signed-off-by: Chengguang Xu <cgxu519@gmx.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Eric Van Hensbergen <ericvh@gmail.com> Cc: Ron Minnich <rminnich@sandia.gov> Cc: Latchesar Ionkov <lucho@ionkov.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/9p')
-rw-r--r--fs/9p/v9fs.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/fs/9p/v9fs.c b/fs/9p/v9fs.c
index e622f0f10502..0429c8ee58f1 100644
--- a/fs/9p/v9fs.c
+++ b/fs/9p/v9fs.c
@@ -210,12 +210,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
210 p9_debug(P9_DEBUG_ERROR, 210 p9_debug(P9_DEBUG_ERROR,
211 "integer field, but no integer?\n"); 211 "integer field, but no integer?\n");
212 ret = r; 212 ret = r;
213 continue; 213 } else {
214 } 214 v9ses->debug = option;
215 v9ses->debug = option;
216#ifdef CONFIG_NET_9P_DEBUG 215#ifdef CONFIG_NET_9P_DEBUG
217 p9_debug_level = option; 216 p9_debug_level = option;
218#endif 217#endif
218 }
219 break; 219 break;
220 220
221 case Opt_dfltuid: 221 case Opt_dfltuid:
@@ -231,7 +231,6 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
231 p9_debug(P9_DEBUG_ERROR, 231 p9_debug(P9_DEBUG_ERROR,
232 "uid field, but not a uid?\n"); 232 "uid field, but not a uid?\n");
233 ret = -EINVAL; 233 ret = -EINVAL;
234 continue;
235 } 234 }
236 break; 235 break;
237 case Opt_dfltgid: 236 case Opt_dfltgid:
@@ -247,7 +246,6 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
247 p9_debug(P9_DEBUG_ERROR, 246 p9_debug(P9_DEBUG_ERROR,
248 "gid field, but not a gid?\n"); 247 "gid field, but not a gid?\n");
249 ret = -EINVAL; 248 ret = -EINVAL;
250 continue;
251 } 249 }
252 break; 250 break;
253 case Opt_afid: 251 case Opt_afid:
@@ -256,9 +254,9 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
256 p9_debug(P9_DEBUG_ERROR, 254 p9_debug(P9_DEBUG_ERROR,
257 "integer field, but no integer?\n"); 255 "integer field, but no integer?\n");
258 ret = r; 256 ret = r;
259 continue; 257 } else {
258 v9ses->afid = option;
260 } 259 }
261 v9ses->afid = option;
262 break; 260 break;
263 case Opt_uname: 261 case Opt_uname:
264 kfree(v9ses->uname); 262 kfree(v9ses->uname);
@@ -306,13 +304,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
306 "problem allocating copy of cache arg\n"); 304 "problem allocating copy of cache arg\n");
307 goto free_and_return; 305 goto free_and_return;
308 } 306 }
309 ret = get_cache_mode(s); 307 r = get_cache_mode(s);
310 if (ret == -EINVAL) { 308 if (r < 0)
311 kfree(s); 309 ret = r;
312 goto free_and_return; 310 else
313 } 311 v9ses->cache = r;
314 312
315 v9ses->cache = ret;
316 kfree(s); 313 kfree(s);
317 break; 314 break;
318 315
@@ -341,14 +338,12 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)
341 pr_info("Unknown access argument %s\n", 338 pr_info("Unknown access argument %s\n",
342 s); 339 s);
343 kfree(s); 340 kfree(s);
344 goto free_and_return; 341 continue;
345 } 342 }
346 v9ses->uid = make_kuid(current_user_ns(), uid); 343 v9ses->uid = make_kuid(current_user_ns(), uid);
347 if (!uid_valid(v9ses->uid)) { 344 if (!uid_valid(v9ses->uid)) {
348 ret = -EINVAL; 345 ret = -EINVAL;
349 pr_info("Uknown uid %s\n", s); 346 pr_info("Uknown uid %s\n", s);
350 kfree(s);
351 goto free_and_return;
352 } 347 }
353 } 348 }
354 349