Re: [RFC] Suspicious bug in module refcounting
From: Karsten Keil
Date: Fri Feb 06 2009 - 17:41:26 EST
Hi Rusty,
On Wed, Feb 04, 2009 at 02:18:08PM +1030, Rusty Russell wrote:
> On Wednesday 04 February 2009 00:17:21 Karsten Keil wrote:
> > The refcount is a per CPU atomic variable, module_refcount() simple add
> > in a fully unprotected loop (not disabled irqs, not protected against
> > scheduling) all per cpu values.
>
> Hi Karsten,
>
> Yes, the BUG_ON() is overly aggressive. And I really hate __module_get,
> and it looks like most of the callers are completely bogus. The watchdog
> drivers use it to nail themselves in place in their open routines: this is
> OK, if a bit weird.
>
...
>
> Meanwhile, I'll remove the BUG_ON for 2.6.29.
>
> Thanks,
> Rusty.
Seems that this was not picked up yet for 2.6.29, but I think it really should
go in random triggering BUG() is not very nice, maybe it should also added to
the stable trees.
Can you please submit it again ?
>
> module: remove over-zealous check in __module_get()
>
> module_refcount() isn't reliable outside stop_machine(), as demonstrated
> by Karsten Keil <kkeil@xxxxxxx>, networking can trigger it under load
> (an inc on one cpu and dec on another while module_refcount() is tallying
> can give false results, for example).
>
> Almost noone should be using __module_get, but that's another issue.
>
> Signed-off-by: Rusty Russell <rusty@xxxxxxxxxxxxxxx>
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -407,7 +407,6 @@ static inline void __module_get(struct m
> static inline void __module_get(struct module *module)
> {
> if (module) {
> - BUG_ON(module_refcount(module) == 0);
> local_inc(__module_ref_addr(module, get_cpu()));
> put_cpu();
> }
> --
> 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/
--
Karsten Keil
SuSE Labs
ISDN and VOIP development
SUSE LINUX Products GmbH, Maxfeldstr.5 90409 Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg)
--
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/