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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240814231117.5ikgxensdubor7uz@synopsys.com>
Date: Wed, 14 Aug 2024 23:11:22 +0000
From: Thinh Nguyen <Thinh.Nguyen@...opsys.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
CC: Patrice Chotard <patrice.chotard@...s.st.com>,
        Thinh Nguyen <Thinh.Nguyen@...opsys.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Felipe Balbi <balbi@...com>, Peter Griffin <peter.griffin@...aro.org>,
        Giuseppe Cavallaro <peppe.cavallaro@...com>,
        Lee Jones <lee@...nel.org>,
        "linux-arm-kernel@...ts.infradead.org" <linux-arm-kernel@...ts.infradead.org>,
        "linux-usb@...r.kernel.org" <linux-usb@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "stable@...r.kernel.org" <stable@...r.kernel.org>
Subject: Re: [PATCH 1/2] usb: dwc3: st: fix probed platform device ref count
 on probe error path

On Wed, Aug 14, 2024, Krzysztof Kozlowski wrote:
> The probe function never performs any paltform device allocation, thus
> error path "undo_platform_dev_alloc" is entirely bogus.  It drops the
> reference count from the platform device being probed.  If error path is
> triggered, this will lead to unbalanced device reference counts and
> premature release of device resources, thus possible use-after-free when
> releasing remaining devm-managed resources.
> 
> Fixes: f83fca0707c6 ("usb: dwc3: add ST dwc3 glue layer to manage dwc3 HC")
> Cc: <stable@...r.kernel.org>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
> ---
>  drivers/usb/dwc3/dwc3-st.c | 11 +++--------
>  1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-st.c b/drivers/usb/dwc3/dwc3-st.c
> index 211360eee95a..a9cb04043f08 100644
> --- a/drivers/usb/dwc3/dwc3-st.c
> +++ b/drivers/usb/dwc3/dwc3-st.c
> @@ -219,10 +219,8 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  	dwc3_data->regmap = regmap;
>  
>  	res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "syscfg-reg");
> -	if (!res) {
> -		ret = -ENXIO;
> -		goto undo_platform_dev_alloc;
> -	}
> +	if (!res)
> +		return -ENXIO;
>  
>  	dwc3_data->syscfg_reg_off = res->start;
>  
> @@ -233,8 +231,7 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  		devm_reset_control_get_exclusive(dev, "powerdown");
>  	if (IS_ERR(dwc3_data->rstc_pwrdn)) {
>  		dev_err(&pdev->dev, "could not get power controller\n");
> -		ret = PTR_ERR(dwc3_data->rstc_pwrdn);
> -		goto undo_platform_dev_alloc;
> +		return PTR_ERR(dwc3_data->rstc_pwrdn);
>  	}
>  
>  	/* Manage PowerDown */
> @@ -300,8 +297,6 @@ static int st_dwc3_probe(struct platform_device *pdev)
>  	reset_control_assert(dwc3_data->rstc_rst);
>  undo_powerdown:
>  	reset_control_assert(dwc3_data->rstc_pwrdn);
> -undo_platform_dev_alloc:
> -	platform_device_put(pdev);
>  	return ret;
>  }
>  
> -- 
> 2.43.0
> 

Acked-by: Thinh Nguyen <Thinh.Nguyen@...opsys.com>

Thanks,
Thinh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ