Re: [PATCH] kmod: prevent kmod_loop_msg overflow in__request_module()

From: Andrew Morton
Date: Thu Sep 29 2011 - 17:31:35 EST


On Thu, 29 Sep 2011 17:50:45 +0200 (CEST)
Jiri Kosina <jkosina@xxxxxxx> 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@xxxxxxx>
> ---
> 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!

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/