[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080128175736.GC22487@elte.hu>
Date: Mon, 28 Jan 2008 18:57:36 +0100
From: Ingo Molnar <mingo@...e.hu>
To: Greg KH <gregkh@...e.de>
Cc: linux-kernel@...r.kernel.org, Yinghai Lu <yhlu.kernel@...il.com>,
Jacob Shin <jacob.shin@....com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Alexander Viro <viro@....linux.org.uk>
Subject: Re: [PATCH 2/5] x86: fix runtime error in
arch/x86/kernel/cpu/mcheck/mce_amd_64.c
* Greg KH <gregkh@...e.de> wrote:
> I have added a lot more "robustness" checks to the kobject core now,
> see the lkml messages about the maple bus for examples of where it is
> catching real problems already. And the kobject debugging code is now
> "unified", printing out everything in a standard, easy to understand
> manner.
>
> I really don't want to get into adding a "magic value" to a kobject
> field, and then checking it for every call, that too would have died
> on this kind of bug, just like the debug printk did :)
>
> But if there's anything that you think I can add to make it easier to
> understand, please let me know.
anything that just causes the function to die on that bug reliably
during normal use, without having to enable DEBUG_KOBJECT which just
kills the system due to its verbosity. A magic value would be perfect.
Are kobjects protected against accidental copying? If not add &kobj to
the 'magic value' too, and check that - it becomes copying-resistent
that way and has the same cost to check. (which is negligible anyway)
> The root problem of this bug was us using a goto to call forward into
> a major code block within a function. Not just using a goto for error
> cleanup, like the kernel code "normally" does. Because of that, I
> totally missed this code path when reading the function many times.
> It's nasty code complexity for no reason at all that causes more
> problems than is needed, combined with a total lack of documentation
> for how this kobject userspace interface is supposed to be used, that
> needs to be fixed.
no argument about that at all! This is exactly the same problem that the
spinlock/mutex/rwlock/etc. APIs were facing: it's used everywhere, and
that means dubious places as well that are not that well-known and are
rarely used. The more widely used a piece of kernel infrastructure is,
the more 'hardened' it must be against intentional or accidental abuse.
(at least with certain magic debug options enabled)
So please regard this a good thing - obscure APIs need no debugging
infrastructure - widely used ones do need quite extensive debugging
infrastructure.
For example locks currently have 4000 lines of code of debugging
infrastructure and 1500 lines of code of self-tests. The total amount of
core locking code is less 1000 lines of code. So for every line of
locking code there's more than 5 lines of debugging infrastructure (!).
And we only print to the console if we think there is a bug. That
extensive infrastructure is _good_, because locks are so central to all
our data structures that catching bugs as soon as possible (in fact
sooner than they trigger) aids in keeping bad code out of the kernel
ASAP.
Ingo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists