Re: [PATCH v1 1/2] platform/x86: wmi: Break possible infinite loop when parsing GUID

From: Andy Shevchenko
Date: Thu Jun 22 2023 - 04:46:42 EST


On Wed, Jun 21, 2023 at 11:50:51PM +0200, Armin Wolf wrote:
> Am 21.06.23 um 23:29 schrieb Barnabás Pőcze:
> > 2023. június 21., szerda 23:20 keltezéssel, Armin Wolf <W_Armin@xxxxxx> írta:

[...]

> > > > - if (WARN_ON(guid_parse(id->guid_string, &driver_guid)))
> > >
> > > just an idea: how about printing an error/debug message in case of an
> > > malformed GUID? This could be useful when searching for typos in GUIDs
> > > used by WMI drivers.

[...]

> > Wouldn't it be better to change `__wmi_driver_register()` to check that?
>
> Good point, i guess we can just forget this idea. The original motivation for
> it was the WARN_ON() inside wmi_dev_match(), but your right that this is the
> wrong place to check the GUID formating.

I'm not sure what do you want me to do since patches are tested already.

I think that WARN_ON() is a bit bogus. First of all, it can be easily
transformed to BUG()-equivalent with panic_on_oops and hence kill the
entire system. If we need the message about wrong GUID format, it should
be done elsewhere (modpost ?). I.o.w. we shan't expect that code,
controlled by us, shoots to our foot.

--
With Best Regards,
Andy Shevchenko