public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm00@gmail.com>
To: Jiri Kosina <jkosina@suse.cz>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] kmod: prevent kmod_loop_msg overflow in __request_module()
Date: Thu, 29 Sep 2011 14:31:29 -0700	[thread overview]
Message-ID: <20110929143129.e7c3c7e2.akpm00@gmail.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1109291749000.24692@pobox.suse.cz>

On Thu, 29 Sep 2011 17:50:45 +0200 (CEST)
Jiri Kosina <jkosina@suse.cz> wrote:

> Due to post-decrement

(post-increment)

> in condition of kmod_loop_msg in __request_module(),
> the system log can be spammed by much more than 5 instances of the 'runaway
> loop' message if the number of events triggering it makes the kmod_loop_msg
> to overflow.
> 
> Fix that by making sure we never increment it past the threshold.
> 
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
> ---
>  kernel/kmod.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/kernel/kmod.c b/kernel/kmod.c
> index ddc7644..a4bea97 100644
> --- a/kernel/kmod.c
> +++ b/kernel/kmod.c
> @@ -114,10 +114,12 @@ int __request_module(bool wait, const char *fmt, ...)
>  	atomic_inc(&kmod_concurrent);
>  	if (atomic_read(&kmod_concurrent) > max_modprobes) {
>  		/* We may be blaming an innocent here, but unlikely */
> -		if (kmod_loop_msg++ < 5)
> +		if (kmod_loop_msg < 5) {
>  			printk(KERN_ERR
>  			       "request_module: runaway loop modprobe %s\n",
>  			       module_name);
> +			kmod_loop_msg++;
> +		}
>  		atomic_dec(&kmod_concurrent);
>  		return -ENOMEM;
>  	}

Well, it will take two billion passes through here to cause the
overflow.  I really hope you found this problem by inspection!


  reply	other threads:[~2011-09-29 21:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-29 15:50 [PATCH] kmod: prevent kmod_loop_msg overflow in __request_module() Jiri Kosina
2011-09-29 21:31 ` Andrew Morton [this message]
2011-09-29 22:18   ` Jiri Kosina
2011-10-04  0:17     ` Rusty Russell
2011-10-04  9:37       ` Jiri Kosina

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=20110929143129.e7c3c7e2.akpm00@gmail.com \
    --to=akpm00@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rusty@rustcorp.com.au \
    /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