public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: richard@nod.at, viro@zeniv.linux.org.uk,
	linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH][Resend v2] Fix infinite loop in search_binary_handler()
Date: Wed, 6 Jul 2011 13:21:38 -0700	[thread overview]
Message-ID: <20110706132138.7e65a912.akpm@linux-foundation.org> (raw)
In-Reply-To: <201107062028.JFH82378.OLQHFFMVJtFOSO@I-love.SAKURA.ne.jp>

On Wed, 6 Jul 2011 20:28:18 +0900
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> wrote:

> Richard Weinberger wrote:
> > But IMHO adding a new attribute to task_struct is a bit overkill.
> Indeed. I came up with a simpler solution. ;-)
> ----------------------------------------
> [PATCH] exec: Do not call request_module() twice from search_binary_handler().
> 
> Currently, search_binary_handler() tries to load binary loader module using
> request_module() if a loader for the requested program is not yet loaded. But
> second attempt of request_module() does not affect the result of
> search_binary_handler().
> 
> If request_module() triggered recursion, calling request_module() twice causes
> 2 to the power of MAX_KMOD_CONCURRENT (= 50) repetitions. It is not an infinite
> loop but is sufficient for users to consider as a hang up.
> 
> Therefore, this patch changes not to call request_module() twice, making
> 1 to the power of MAX_KMOD_CONCURRENT repetitions in case of recursion.
> 
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> ---
> diff --git a/fs/exec.c b/fs/exec.c
> index 6075a1e..044c13f 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -1411,6 +1411,8 @@ int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
>  			    printable(bprm->buf[2]) &&
>  			    printable(bprm->buf[3]))
>  				break; /* -ENOEXEC */
> +			if (try)
> +				break; /* -ENOEXEC */
>  			request_module("binfmt-%04x", *(unsigned short *)(&bprm->buf[2]));
>  #endif
>  		}

What is that "for (try=0; try<2" loop actually there for?  To retry
after the request_module(), it appears.  Which is pointless if
!CONFIG_MODULES.



  parent reply	other threads:[~2011-07-06 20:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-04 11:30 [PATCH][Resend v2] Fix infinite loop in search_binary_handler() Richard Weinberger
2011-07-04 11:51 ` Tetsuo Handa
2011-07-04 11:57   ` Richard Weinberger
2011-07-04 12:10     ` Tetsuo Handa
2011-07-04 12:20       ` Richard Weinberger
2011-07-04 14:42         ` Tetsuo Handa
2011-07-04 14:59           ` Richard Weinberger
2011-07-04 15:07             ` Richard Weinberger
2011-07-04 22:03               ` Tetsuo Handa
2011-07-04 22:17                 ` Richard Weinberger
2011-07-05  1:24                   ` Tetsuo Handa
2011-07-05  9:55                     ` Richard Weinberger
2011-07-05 12:02                       ` Tetsuo Handa
2011-07-05 12:21                         ` Richard Weinberger
2011-07-06 11:28                           ` Tetsuo Handa
2011-07-06 11:36                             ` Richard Weinberger
2011-07-06 20:21                             ` Andrew Morton [this message]
2011-07-07  4:04                               ` Tetsuo Handa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110706132138.7e65a912.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=richard@nod.at \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox