Re: [BUG 2.6.36-rc6] list corruption in module_bug_finalize

From: Rusty Russell
Date: Tue Oct 05 2010 - 00:18:47 EST


On Mon, 4 Oct 2010 06:21:08 am Thomas Gleixner wrote:
> Current mainline triggers a list corruption bug in
> module_bug_finalize(). dmesg excerpt below.
>
> The corresponding code says:
>
> /*
> * Strictly speaking this should have a spinlock to protect against
> * traversals, but since we only traverse on BUG()s, a spinlock
> * could potentially lead to deadlock and thus be counter-productive.
> */
> list_add(&mod->bug_list, &module_bug_list);
>
> I can see the traversal problem vs. BUG(), but what's protecting the
> list_add() ? BKL probably did, but is that true anymore ?

I've never even *seen* this code before :(

Looks like it went through Adrian Bunk to Andrew, but despite the fact that
it (foolishly) doesn't touch kernel/module.c, it's generic code and I should
have seen it. It did change the linux/module.h header.

So, it used to be protected by module_mutex, but Linus and I cleaned that up.

So, we need a lock around this list for adding and removal. I'd use
list_add_rcu to try to help the lockless traversal too...

And moving it from all the archs into kernel/module.c would be a nice bonus.

Nice catch!
Rusty.
--
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/