diff options
author | Oleg Nesterov <oleg@redhat.com> | 2013-09-11 17:24:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-09-11 18:59:07 -0400 |
commit | 4e0621a07ea58a0dc15859be3b743bdeb194a51b (patch) | |
tree | 954721cb1776b325b74a48b1858d1b0ac6ff580b | |
parent | cb7b6b1cbc20a970c7124efae1c2478155604b54 (diff) |
exec: don't retry if request_module() fails
A separate one-liner for better documentation.
It doesn't make sense to retry if request_module() fails to exec
/sbin/modprobe, add the additional "request_module() < 0" check.
However, this logic still doesn't look exactly right:
1. It would be better to check "request_module() != 0", the user
space modprobe process should report the correct exit code.
But I didn't dare to add the user-visible change.
2. The whole ENOEXEC logic looks suboptimal. Suppose that we try
to exec a "#!path-to-unsupported-binary" script. In this case
request_module() + "retry" will be done twice: first by the
"depth == 1" code, and then again by the "depth == 0" caller
which doesn't make sense.
3. And note that in the case above bprm->buf was already changed
by load_script()->prepare_binprm(), so this looks even more
ugly.
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>
-rw-r--r-- | fs/exec.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -1418,7 +1418,8 @@ int search_binary_handler(struct linux_binprm *bprm) | |||
1418 | if (printable(bprm->buf[0]) && printable(bprm->buf[1]) && | 1418 | if (printable(bprm->buf[0]) && printable(bprm->buf[1]) && |
1419 | printable(bprm->buf[2]) && printable(bprm->buf[3])) | 1419 | printable(bprm->buf[2]) && printable(bprm->buf[3])) |
1420 | return retval; | 1420 | return retval; |
1421 | request_module("binfmt-%04x", *(ushort *)(bprm->buf + 2)); | 1421 | if (request_module("binfmt-%04x", *(ushort *)(bprm->buf + 2)) < 0) |
1422 | return retval; | ||
1422 | need_retry = false; | 1423 | need_retry = false; |
1423 | goto retry; | 1424 | goto retry; |
1424 | } | 1425 | } |