• Oleg Nesterov's avatar
    exec: cleanup the error handling in search_binary_handler() · 6b3c538f
    Oleg Nesterov authored
    The error hanling and ret-from-loop look confusing and inconsistent.
    - "retval >= 0" simply returns
    - "!bprm->file" returns too but with read_unlock() because
       binfmt_lock was already re-acquired
    - "retval != -ENOEXEC || bprm->mm == NULL" does "break" and
      relies on the same check after the main loop
    Consolidate these checks into a single if/return statement.
    need_retry still checks "retval == -ENOEXEC", but this and -ENOENT before
    the main loop are not needed.  This is only for pathological and
    impossible list_empty(&formats) case.
    It is not clear why do we check "bprm->mm == NULL", probably this
    should be removed.
    Signed-off-by: 's avatarOleg Nesterov <oleg@redhat.com>
    Acked-by: 's avatarKees 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: 's avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: 's avatarLinus Torvalds <torvalds@linux-foundation.org>
exec.c 39.2 KB