Re: [Bug? Report] kref problem

Dave Hansen
2006-03-16T17:32:13Z

On Thu, 2006-03-16 at 08:53 -0800, Greg KH wrote:
> On Thu, Mar 16, 2006 at 02:41:19PM +0300, Artem B. Bityutskiy wrote:
> > struct my_obj_a
> > {
> > struct kobject kobj;
> > } a;
> >
> > struct my_obj_b
> > {
> > struct kobject kobj;
> > } b;
>
> Don't statically create kobjects, it's not nice. But the real problem
> is below...

This seems to be one of those top ten sysfs snafus. Could we take the
definitions from include/asm-generic/sections.h, and make a kobject
verification function to put in the critical generic kernel functions
that deal with kobjects, like kobject_init()?

Somthing like...

void verify_dynamic_kobject_allocation(struct kobject *kobj)
{
if (kobj >= &_data && kobj < &_edata)
goto warn;
if (kobj >= &_bss_start && kobj < &_bss_end)
goto warn;
...
return;
warn:
printk(KERN_WARN "statically allocated kobject, you suck...\n");
}

I'm not sure that all of the architectures fill in all of the values,
but we could at least support the warnings for the ones that do. That
includes at least i386, so it could be a relatively effective tool.

I'll cook up a real patch in a bit.

-- Dave