Re: [PATCH 1/3] driver core: add a faux bus for use when a simple device/bus is needed

From: Andy Shevchenko
Date: Mon Feb 03 2025 - 11:10:41 EST


On Mon, Feb 03, 2025 at 06:05:20PM +0200, Andy Shevchenko wrote:
> On Mon, Feb 03, 2025 at 04:35:45PM +0100, Greg Kroah-Hartman wrote:
> > On Mon, Feb 03, 2025 at 05:11:03PM +0200, Andy Shevchenko wrote:
> > > On Mon, Feb 03, 2025 at 03:25:17PM +0100, Greg Kroah-Hartman wrote:

...

> > > > + faux_obj = kzalloc(sizeof(*faux_obj) + strlen(name) + 1, GFP_KERNEL);
> > >
> > > Potential overflow. To avoid one may use struct_size() from overflow.h.
> >
> > Users should not be providing the string here. Again, this comes from
> > platform.c.
>
> I'm not sure I follow. The name parameter is not limited anyhow, so one may
> provide non-terminated string and strlen() will return an arbitrary number.
> Potentially this can lead to big numbers and become an overflow when gets
> to a parameter for kmalloc(). This most likely never happen in real life,
> but still the overflow is possible.

After reading your other messages I got what you are talking about here.
Now it's all clear.

--
With Best Regards,
Andy Shevchenko