All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] usb: typec: ucsi: Fix NULL pointer dereference
@ 2023-09-06  8:48 Heikki Krogerus
  2023-09-06  8:57 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Heikki Krogerus @ 2023-09-06  8:48 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, Dave Hansen, Mario Limonciello, Saranya Gopal

Making sure the UCSI debugfs entry actually exists before
attempting to remove it.

Fixes: df0383ffad64 ("usb: typec: ucsi: Add debugfs for ucsi commands")
Reported-by: Dave Hansen <dave.hansen@intel.com>
Closes: https://lore.kernel.org/linux-usb/700df3c4-2f6c-85f9-6c61-065bc5b2db3a@intel.com/
Suggested-by: Dave Hansen <dave.hansen@intel.com>
Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
Cc: Saranya Gopal <saranya.gopal@intel.com>
Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
---
 drivers/usb/typec/ucsi/debugfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/typec/ucsi/debugfs.c b/drivers/usb/typec/ucsi/debugfs.c
index 0c7bf88d4a7f..f67733cecfdf 100644
--- a/drivers/usb/typec/ucsi/debugfs.c
+++ b/drivers/usb/typec/ucsi/debugfs.c
@@ -84,6 +84,9 @@ void ucsi_debugfs_register(struct ucsi *ucsi)
 
 void ucsi_debugfs_unregister(struct ucsi *ucsi)
 {
+	if (IS_ERR_OR_NULL(ucsi) || !ucsi->debugfs)
+		return;
+
 	debugfs_remove_recursive(ucsi->debugfs->dentry);
 	kfree(ucsi->debugfs);
 }
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: typec: ucsi: Fix NULL pointer dereference
  2023-09-06  8:48 [PATCH] usb: typec: ucsi: Fix NULL pointer dereference Heikki Krogerus
@ 2023-09-06  8:57 ` Greg Kroah-Hartman
  2023-09-06 12:05   ` Mario Limonciello
  0 siblings, 1 reply; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-09-06  8:57 UTC (permalink / raw)
  To: Heikki Krogerus
  Cc: Mario Limonciello, Dave Hansen, LKML, Andy Shevchenko,
	Saranya Gopal, Rajaram Regupathy, Uwe Kleine-König,
	Wayne Chang, Hans de Goede, Neil Armstrong, linux-usb

On Wed, Sep 06, 2023 at 11:48:42AM +0300, Heikki Krogerus wrote:
> Making sure the UCSI debugfs entry actually exists before
> attempting to remove it.
> 
> Fixes: df0383ffad64 ("usb: typec: ucsi: Add debugfs for ucsi commands")
> Reported-by: Dave Hansen <dave.hansen@intel.com>
> Closes: https://lore.kernel.org/linux-usb/700df3c4-2f6c-85f9-6c61-065bc5b2db3a@intel.com/
> Suggested-by: Dave Hansen <dave.hansen@intel.com>
> Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
> Cc: Saranya Gopal <saranya.gopal@intel.com>
> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
>  drivers/usb/typec/ucsi/debugfs.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/typec/ucsi/debugfs.c b/drivers/usb/typec/ucsi/debugfs.c
> index 0c7bf88d4a7f..f67733cecfdf 100644
> --- a/drivers/usb/typec/ucsi/debugfs.c
> +++ b/drivers/usb/typec/ucsi/debugfs.c
> @@ -84,6 +84,9 @@ void ucsi_debugfs_register(struct ucsi *ucsi)
>  
>  void ucsi_debugfs_unregister(struct ucsi *ucsi)
>  {
> +	if (IS_ERR_OR_NULL(ucsi) || !ucsi->debugfs)
> +		return;
> +
>  	debugfs_remove_recursive(ucsi->debugfs->dentry);

Why are you saving the dentry at all?  Why not just have debugfs look it
up when you want to remove it based on the filename?

Anyway, not a big deal here, just a comment.  I'll queue this up after
-rc1 is out.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: typec: ucsi: Fix NULL pointer dereference
  2023-09-06  8:57 ` Greg Kroah-Hartman
@ 2023-09-06 12:05   ` Mario Limonciello
  2023-09-11  9:46     ` Thorsten Leemhuis
  0 siblings, 1 reply; 5+ messages in thread
From: Mario Limonciello @ 2023-09-06 12:05 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Heikki Krogerus
  Cc: Dave Hansen, LKML, Andy Shevchenko, Saranya Gopal,
	Rajaram Regupathy, Uwe Kleine-König, Wayne Chang,
	Hans de Goede, Neil Armstrong, linux-usb

On 9/6/2023 03:57, Greg Kroah-Hartman wrote:
> On Wed, Sep 06, 2023 at 11:48:42AM +0300, Heikki Krogerus wrote:
>> Making sure the UCSI debugfs entry actually exists before
>> attempting to remove it.
>>
>> Fixes: df0383ffad64 ("usb: typec: ucsi: Add debugfs for ucsi commands")
>> Reported-by: Dave Hansen <dave.hansen@intel.com>
>> Closes: https://lore.kernel.org/linux-usb/700df3c4-2f6c-85f9-6c61-065bc5b2db3a@intel.com/
>> Suggested-by: Dave Hansen <dave.hansen@intel.com>
>> Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
>> Cc: Saranya Gopal <saranya.gopal@intel.com>
>> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

I could also reproduce it with 7733171926cc336ddf0c8f847eefaff569dbff86 
on two different laptops.

>> ---
>>   drivers/usb/typec/ucsi/debugfs.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/usb/typec/ucsi/debugfs.c b/drivers/usb/typec/ucsi/debugfs.c
>> index 0c7bf88d4a7f..f67733cecfdf 100644
>> --- a/drivers/usb/typec/ucsi/debugfs.c
>> +++ b/drivers/usb/typec/ucsi/debugfs.c
>> @@ -84,6 +84,9 @@ void ucsi_debugfs_register(struct ucsi *ucsi)
>>   
>>   void ucsi_debugfs_unregister(struct ucsi *ucsi)
>>   {
>> +	if (IS_ERR_OR_NULL(ucsi) || !ucsi->debugfs)
>> +		return;
>> +
>>   	debugfs_remove_recursive(ucsi->debugfs->dentry);
> 
> Why are you saving the dentry at all?  Why not just have debugfs look it
> up when you want to remove it based on the filename?
> 
> Anyway, not a big deal here, just a comment.  I'll queue this up after
> -rc1 is out.

It might be worth sending before rc1 if it ends up being widespread.

> 
> thanks,
> 
> greg k-h


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: typec: ucsi: Fix NULL pointer dereference
  2023-09-06 12:05   ` Mario Limonciello
@ 2023-09-11  9:46     ` Thorsten Leemhuis
  2023-09-11 11:52       ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Thorsten Leemhuis @ 2023-09-11  9:46 UTC (permalink / raw)
  To: Mario Limonciello, Greg Kroah-Hartman, Heikki Krogerus
  Cc: Dave Hansen, LKML, Andy Shevchenko, Saranya Gopal,
	Rajaram Regupathy, Uwe Kleine-König, Wayne Chang,
	Hans de Goede, Neil Armstrong, linux-usb,
	Linux kernel regressions list

On 06.09.23 14:05, Mario Limonciello wrote:
> On 9/6/2023 03:57, Greg Kroah-Hartman wrote:
>> On Wed, Sep 06, 2023 at 11:48:42AM +0300, Heikki Krogerus wrote:
>>> Making sure the UCSI debugfs entry actually exists before
>>> attempting to remove it.
>>>
>>> Fixes: df0383ffad64 ("usb: typec: ucsi: Add debugfs for ucsi commands")
>>> Reported-by: Dave Hansen <dave.hansen@intel.com>
>>> Closes:
>>> https://lore.kernel.org/linux-usb/700df3c4-2f6c-85f9-6c61-065bc5b2db3a@intel.com/
>>> Suggested-by: Dave Hansen <dave.hansen@intel.com>
>>> Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
>>> Cc: Saranya Gopal <saranya.gopal@intel.com>
>>> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> 
> I could also reproduce it with 7733171926cc336ddf0c8f847eefaff569dbff86
> on two different laptops.
> 
>>> ---
>>>   drivers/usb/typec/ucsi/debugfs.c | 3 +++
>>>   1 file changed, 3 insertions(+)
>>>
>>> diff --git a/drivers/usb/typec/ucsi/debugfs.c
>>> b/drivers/usb/typec/ucsi/debugfs.c
>>> index 0c7bf88d4a7f..f67733cecfdf 100644
>>> --- a/drivers/usb/typec/ucsi/debugfs.c
>>> +++ b/drivers/usb/typec/ucsi/debugfs.c
>>> @@ -84,6 +84,9 @@ void ucsi_debugfs_register(struct ucsi *ucsi)
>>>     void ucsi_debugfs_unregister(struct ucsi *ucsi)
>>>   {
>>> +    if (IS_ERR_OR_NULL(ucsi) || !ucsi->debugfs)
>>> +        return;
>>> +
>>>       debugfs_remove_recursive(ucsi->debugfs->dentry);
>>
>> Why are you saving the dentry at all?  Why not just have debugfs look it
>> up when you want to remove it based on the filename?
>>
>> Anyway, not a big deal here, just a comment.  I'll queue this up after
>> -rc1 is out.
> 
> It might be worth sending before rc1 if it ends up being widespread.

FWIW, as someone that afaics just ran into the regression fixed by this
patch with -rc1, I would have liked that patch to be in -rc1 as well...

Ciao, Thorsten

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] usb: typec: ucsi: Fix NULL pointer dereference
  2023-09-11  9:46     ` Thorsten Leemhuis
@ 2023-09-11 11:52       ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2023-09-11 11:52 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: Mario Limonciello, Heikki Krogerus, Dave Hansen, LKML,
	Andy Shevchenko, Saranya Gopal, Rajaram Regupathy,
	Uwe Kleine-König, Wayne Chang, Hans de Goede,
	Neil Armstrong, linux-usb, Linux kernel regressions list

On Mon, Sep 11, 2023 at 11:46:17AM +0200, Thorsten Leemhuis wrote:
> On 06.09.23 14:05, Mario Limonciello wrote:
> > On 9/6/2023 03:57, Greg Kroah-Hartman wrote:
> >> On Wed, Sep 06, 2023 at 11:48:42AM +0300, Heikki Krogerus wrote:
> >>> Making sure the UCSI debugfs entry actually exists before
> >>> attempting to remove it.
> >>>
> >>> Fixes: df0383ffad64 ("usb: typec: ucsi: Add debugfs for ucsi commands")
> >>> Reported-by: Dave Hansen <dave.hansen@intel.com>
> >>> Closes:
> >>> https://lore.kernel.org/linux-usb/700df3c4-2f6c-85f9-6c61-065bc5b2db3a@intel.com/
> >>> Suggested-by: Dave Hansen <dave.hansen@intel.com>
> >>> Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
> >>> Cc: Saranya Gopal <saranya.gopal@intel.com>
> >>> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> > 
> > I could also reproduce it with 7733171926cc336ddf0c8f847eefaff569dbff86
> > on two different laptops.
> > 
> >>> ---
> >>>   drivers/usb/typec/ucsi/debugfs.c | 3 +++
> >>>   1 file changed, 3 insertions(+)
> >>>
> >>> diff --git a/drivers/usb/typec/ucsi/debugfs.c
> >>> b/drivers/usb/typec/ucsi/debugfs.c
> >>> index 0c7bf88d4a7f..f67733cecfdf 100644
> >>> --- a/drivers/usb/typec/ucsi/debugfs.c
> >>> +++ b/drivers/usb/typec/ucsi/debugfs.c
> >>> @@ -84,6 +84,9 @@ void ucsi_debugfs_register(struct ucsi *ucsi)
> >>>     void ucsi_debugfs_unregister(struct ucsi *ucsi)
> >>>   {
> >>> +    if (IS_ERR_OR_NULL(ucsi) || !ucsi->debugfs)
> >>> +        return;
> >>> +
> >>>       debugfs_remove_recursive(ucsi->debugfs->dentry);
> >>
> >> Why are you saving the dentry at all?  Why not just have debugfs look it
> >> up when you want to remove it based on the filename?
> >>
> >> Anyway, not a big deal here, just a comment.  I'll queue this up after
> >> -rc1 is out.
> > 
> > It might be worth sending before rc1 if it ends up being widespread.
> 
> FWIW, as someone that afaics just ran into the regression fixed by this
> patch with -rc1, I would have liked that patch to be in -rc1 as well...

It's now queued up and will go to Linus this week.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-09-11 11:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-06  8:48 [PATCH] usb: typec: ucsi: Fix NULL pointer dereference Heikki Krogerus
2023-09-06  8:57 ` Greg Kroah-Hartman
2023-09-06 12:05   ` Mario Limonciello
2023-09-11  9:46     ` Thorsten Leemhuis
2023-09-11 11:52       ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.