From: akpm@linux-foundation.org Subject: + exec-dont-retry-if-request_module-fails.patch added to -mm tree Date: Mon, 05 Aug 2013 13:45:14 -0700 Message-ID: <52000eda.871OnNu4napsas2R%akpm@linux-foundation.org> Reply-To: linux-kernel@vger.kernel.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Return-path: Received: from mail.linuxfoundation.org ([140.211.169.12]:42545 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752295Ab3HEUpP (ORCPT ); Mon, 5 Aug 2013 16:45:15 -0400 Sender: mm-commits-owner@vger.kernel.org List-Id: mm-commits@vger.kernel.org To: mm-commits@vger.kernel.org, zml@linux.vnet.ibm.com, zbr@ioremap.net, viro@ZenIV.linux.org.uk, keescook@chromium.org, oleg@redhat.com Subject: + exec-dont-retry-if-request_module-fails.patch added to -mm tree To: oleg@redhat.com,keescook@chromium.org,viro@ZenIV.linux.org.uk,zbr@ioremap.net,zml@linux.vnet.ibm.com From: akpm@linux-foundation.org Date: Mon, 05 Aug 2013 13:45:14 -0700 The patch titled Subject: exec: don't retry if request_module() fails has been added to the -mm tree. Its filename is exec-dont-retry-if-request_module-fails.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/exec-dont-retry-if-request_module-fails.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/exec-dont-retry-if-request_module-fails.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Oleg Nesterov Subject: 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 Acked-by: Kees Cook Cc: Al Viro Cc: Evgeniy Polyakov Cc: Zach Levis Signed-off-by: Andrew Morton --- fs/exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff -puN fs/exec.c~exec-dont-retry-if-request_module-fails fs/exec.c --- a/fs/exec.c~exec-dont-retry-if-request_module-fails +++ a/fs/exec.c @@ -1418,7 +1418,8 @@ int search_binary_handler(struct linux_b if (printable(bprm->buf[0]) && printable(bprm->buf[1]) && printable(bprm->buf[2]) && printable(bprm->buf[3])) return retval; - request_module("binfmt-%04x", *(ushort *)(bprm->buf + 2)); + if (request_module("binfmt-%04x", *(ushort *)(bprm->buf + 2)) < 0) + return retval; need_retry = false; goto retry; } _ Patches currently in -mm which might be from oleg@redhat.com are x86-get_unmapped_area-use-proper-mmap-base-for-bottom-up-direction.patch include-linux-schedh-dont-use-task-pid-tgid-in-same_thread_group-has_group_leader_pid.patch mm-mempolicy-turn-vma_set_policy-into-vma_dup_policy.patch mm-shift-vm_grows-check-from-mmap_region-to-do_mmap_pgoff-v2.patch mm-do_mmap_pgoff-cleanup-the-usage-of-file_inode.patch mm-mmap_region-kill-correct_wcount-inode-use-allow_write_access.patch kernel-wide-fix-missing-validations-on-__get-__put-__copy_to-__copy_from_user.patch autofs4-allow-autofs-to-work-outside-the-initial-pid-namespace.patch autofs4-translate-pids-to-the-right-namespace-for-the-daemon.patch signals-eventpoll-set-saved_sigmask-at-the-start.patch move-exit_task_namespaces-outside-of-exit_notify-fix.patch exec-introduce-exec_binprm-for-depth-==-0-code.patch exec-kill-int-depth-in-search_binary_handler.patch exec-proc_exec_connector-should-be-called-only-once.patch exec-move-allow_write_access-fput-to-exec_binprm.patch exec-kill-load_binary-=-null-check-in-search_binary_handler.patch exec-cleanup-the-config_modules-logic.patch exec-dont-retry-if-request_module-fails.patch exec-cleanup-the-error-handling-in-search_binary_handler.patch linux-next.patch