aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2013-09-11 17:24:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-11 18:59:04 -0400
commit131b2f9f1214f338f0bf7c0d9760019f2b1d0c20 (patch)
treeb60a498414e259fe4e81f210378538f90ada9224 /fs
parent5d1baf3b63bfc8c709dc44df85ff1475c7ef489d (diff)
exec: kill "int depth" in search_binary_handler()
Nobody except search_binary_handler() should touch ->recursion_depth, "int depth" buys nothing but complicates the code, kill it. Probably we should also kill "fn" and the !NULL check, ->load_binary should be always defined. And it can not go away after read_unlock() or this code is buggy anyway. Signed-off-by: Oleg Nesterov <oleg@redhat.com> Acked-by: Kees Cook <keescook@chromium.org> Cc: Al Viro <viro@ZenIV.linux.org.uk> Cc: Evgeniy Polyakov <zbr@ioremap.net> Cc: Zach Levis <zml@linux.vnet.ibm.com> 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/exec.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/fs/exec.c b/fs/exec.c
index 4d95b4709ea0..b6e35ec818a2 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1370,12 +1370,11 @@ EXPORT_SYMBOL(remove_arg_zero);
1370 */ 1370 */
1371int search_binary_handler(struct linux_binprm *bprm) 1371int search_binary_handler(struct linux_binprm *bprm)
1372{ 1372{
1373 unsigned int depth = bprm->recursion_depth; 1373 int try, retval;
1374 int try,retval;
1375 struct linux_binfmt *fmt; 1374 struct linux_binfmt *fmt;
1376 1375
1377 /* This allows 4 levels of binfmt rewrites before failing hard. */ 1376 /* This allows 4 levels of binfmt rewrites before failing hard. */
1378 if (depth > 5) 1377 if (bprm->recursion_depth > 5)
1379 return -ELOOP; 1378 return -ELOOP;
1380 1379
1381 retval = security_bprm_check(bprm); 1380 retval = security_bprm_check(bprm);
@@ -1396,9 +1395,9 @@ int search_binary_handler(struct linux_binprm *bprm)
1396 if (!try_module_get(fmt->module)) 1395 if (!try_module_get(fmt->module))
1397 continue; 1396 continue;
1398 read_unlock(&binfmt_lock); 1397 read_unlock(&binfmt_lock);
1399 bprm->recursion_depth = depth + 1; 1398 bprm->recursion_depth++;
1400 retval = fn(bprm); 1399 retval = fn(bprm);
1401 bprm->recursion_depth = depth; 1400 bprm->recursion_depth--;
1402 if (retval >= 0) { 1401 if (retval >= 0) {
1403 put_binfmt(fmt); 1402 put_binfmt(fmt);
1404 allow_write_access(bprm->file); 1403 allow_write_access(bprm->file);