Re: [PATCH -next 1/2] kobject: fix memory leak in kset_register() due to uninitialized kset->kobj.ktype

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 26, 2024 at 10:56:24AM +0800, cuigaosheng wrote:
> On 2024/9/25 20:19, Greg KH wrote:
> 
> > On Wed, Sep 25, 2024 at 08:07:46PM +0800, Gaosheng Cui wrote:
> > > If a kset with uninitialized kset->kobj.ktype be registered,
> > Does that happen today with any in-kernel code?  If so, let's fix those
> > kset instances, right?
> 
> I didn't find this kset instance in kernel code,itwas discovered through code review.

Great, then it is not a real issue :)

> > > kset_register() will return error, and the kset.kobj.name allocated
> > > by kobject_set_name() will be leaked.
> > > 
> > > To mitigate this, we free the name in kset_register() when an error
> > > is encountered due to uninitialized kset->kobj.ktype.
> > How did you hit this?
> 
> I am testing kernel functionality through fault injection, and I discovered
> it whenI was locating the issue fixed by another patch, I haven't found this
> wrong usage in the kernel, but we can construct it by fault injection,

"fault injection" also shows things that are impossible to ever have
happen as well, so our "need" to fix them is usually very low, right?

thanks,

greg k-h




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux