lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 2 Jan 2024 12:56:52 -0800
From: RD Babiera <rdbabiera@...gle.com>
To: "Christian A. Ehrhardt" <lk@...e.de>
Cc: linux-kernel@...r.kernel.org, 
	Chris Bainbridge <chris.bainbridge@...il.com>, 
	Heikki Krogerus <heikki.krogerus@...ux.intel.com>, 
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH] usb: typec: Fix double free in typec_altmode_put_partner

Hi Christian,

I believe commit 9c6b789e954fae73c548f39332bcc56bdf0d4373 would
need to be reverted to apply this patch, but I'm not sure if that's preferred
over submitting a new version of the problematic patch that combines this
solution instead. Regardless I was able to verify the refcount on my setup.

On Tue, Jan 2, 2024 at 11:30 AM Christian A. Ehrhardt <lk@...e.de> wrote:
>
> The altmode device nodes of a port partner and of cable
> plugs hold a reference to the altmode of a port. The port's
> altmode contains various back pointers but these do not
> contribute to the reference count.
>
> Thus, free the port's altmode device instead of doing a
> double free on ourself.
>
> Reported-By: Chris Bainbridge <chris.bainbridge@...il.com>
> Fixes: b17b7fe6dd5c (usb: typec: class: fix typec_altmode_put_partner to put plugs)
> Cc: RD Babiera <rdbabiera@...gle.com>
> Cc: Heikki Krogerus <heikki.krogerus@...ux.intel.com>
> Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
> Cc: stable@...r.kernel.org
> Signed-off-by: Christian A. Ehrhardt <lk@...e.de>

Tested-by: RD Babiera <rdbabiera@...gle.com>

> ---
>  drivers/usb/typec/class.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c
> index 16a670828dde..2da19feacd91 100644
> --- a/drivers/usb/typec/class.c
> +++ b/drivers/usb/typec/class.c
> @@ -263,11 +263,13 @@ static void typec_altmode_put_partner(struct altmode *altmode)
>  {
>         struct altmode *partner = altmode->partner;
>         struct typec_altmode *adev;
> +       struct typec_altmode *partner_adev;
>
>         if (!partner)
>                 return;
>
>         adev = &altmode->adev;
> +       partner_adev = &partner->adev;
>
>         if (is_typec_plug(adev->dev.parent)) {
>                 struct typec_plug *plug = to_typec_plug(adev->dev.parent);
> @@ -276,7 +278,7 @@ static void typec_altmode_put_partner(struct altmode *altmode)
>         } else {
>                 partner->partner = NULL;
>         }
> -       put_device(&adev->dev);
> +       put_device(&partner_adev->dev);
>  }
>
>  /**
> --
> 2.40.1
>

Thanks,
---
rd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ