Re: [PATCH] Make taint bit reliable

From: Andrew Morton
Date: Tue Sep 02 2008 - 20:43:20 EST


On Mon, 1 Sep 2008 18:46:32 +0200
Andi Kleen <andi@xxxxxxxxxxxxxx> wrote:

> Make taint bit reliable
>
> It's somewhat unlikely that it happens, but right now a race window
> between interrupts or machine checks or oopses could corrupt the tainted
> bitmap because it is modified in a non atomic fashion.
>
> Convert the taint variable to an unsigned long and use only atomic bit
> operations on it.
>
> Unfortunately this means the intvec sysctl functions cannot be used on
> it anymore.
>
> It turned out the taint sysctl handler could actually be simplified
> a bit (since it only increases capabilities) so this patch actually
> removes code.
>
> Signed-off-by: Andi Kleen <ak@xxxxxxxxxxxxxxx>
>
> ---
> include/linux/kernel.h | 2 -
> kernel/panic.c | 5 ++-
> kernel/sysctl.c | 67 +++++++++++++++++++++----------------------------
> 3 files changed, 33 insertions(+), 41 deletions(-)

You missed one:

./arch/x86/kernel/smpboot.c: tainted &= ~TAINT_UNSAFE_SMP;


To prevent reoccurrences we could/should rename `tainted' to something else.

Also, it would end up with a beter result if we were to change

- #define TAINT_PROPRIETARY_MODULE (1<<0)
- #define TAINT_FORCED_MODULE (1<<1)
...
+ #define TAINT_PROPRIETARY_MODULE 0
+ #define TAINT_FORCED_MODULE 1
...


and remove that ungainly log2() you had to add, and just prevent all
open-coded access to the 'tainted' global. ie: add `int get_taint(void)'?

--
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/