Re: [PATCH] kobject: Access kobject name with caution if state is not initialized

From: Greg Kroah-Hartman
Date: Mon Aug 20 2018 - 15:22:55 EST


On Mon, Aug 20, 2018 at 10:39:47PM +0530, Srikar Dronamraju wrote:
> If kobject state is not initialized, then its not even certain that
> kobject'name is initialized. Hence when accessing the kobject's name
> tread carefully.
>
> A stupid module test like
> https://github.com/srikard/tests/blob/master/modules/kobject_test.c
> can panic the system.

Lots of stupid modules can do dumb things. Just don't do that. The
kernel is not built to keep you from doing stupid things in kernel code
:)

So I fail to see why this patch is needed. What in-kernel code path is
trying to print a kobject's name before it is initialized? Why not fix
that obvious bug instead of forcing the kernel core to protect from
stupid code?

thanks,

greg k-h