Re: [PATCH] Fix uninitialized spinlock of printk_ratelimited()
From: OGAWA Hirofumi
Date: Wed May 19 2010 - 16:45:15 EST
Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> writes:
>> #ifdef CONFIG_PRINTK
>> -#define printk_ratelimited(fmt, ...) ({ \
>> - static struct ratelimit_state _rs = { \
>> - .interval = DEFAULT_RATELIMIT_INTERVAL, \
>> - .burst = DEFAULT_RATELIMIT_BURST, \
>> - }; \
>> - \
>> - if (__ratelimit(&_rs)) \
>> - printk(fmt, ##__VA_ARGS__); \
>> +#define printk_ratelimited(fmt, ...) ({ \
>> + static DEFINE_RATELIMIT_STATE(_rs, \
>> + DEFAULT_RATELIMIT_INTERVAL, \
>> + DEFAULT_RATELIMIT_BURST); \
>> + \
>> + if (__ratelimit(&_rs)) \
>> + printk(fmt, ##__VA_ARGS__); \
>> })
>
> hm, yes, that spinlock will get the all-zeroes pattern.
>
> It's been like this since December 2009. I'm a bit surprised that none
> of our spinlock-debugging goodies picked this up. All the
> CONFIG_DEBUG_SPINLOCK spinlock fields end up zeroed out also.
The reason that dynamic analysis didn't pick up is simple - nobody is
using this for now :)
Thanks.
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>
--
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/