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] [day] [month] [year] [list]
Message-ID: <2025090651-unifier-award-3e0a@gregkh>
Date: Sat, 6 Sep 2025 14:15:31 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Kuen-Han Tsai <khtsai@...gle.com>
Cc: zack.rusin@...adcom.com, krzysztof.kozlowski@...aro.org,
	namcao@...utronix.de, yauheni.kaliuta@...ia.com,
	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
	stable@...nel.org
Subject: Re: [PATCH] usb: gadget: f_ncm: Fix NPE in ncm_bind error path

On Thu, Sep 04, 2025 at 07:46:13PM +0800, Kuen-Han Tsai wrote:
> When an ncm_bind/unbind cycle occurs, the ncm->notify_req pointer is
> left pointing to a stale address. If a subsequent call to ncm_bind()
> fails to allocate the endpoints, the function jumps to the unified error
> label. The cleanup code sees the stale ncm->notify_req pointer and calls
> usb_ep_free_request().
> 
> This results in a NPE because it attempts to access the free_request
> function through the endpoint's operations table (ep->ops), which is
> NULL.
> 
> Refactor the error path to use cascading goto labels, ensuring that
> resources are freed in reverse order of allocation. Besides, explicitly
> set pointers to NULL after freeing them.

Why must the pointers be set to NULL?  What is checking and requiring
that?

And this unwinding is tailor-made for the guard() type of logic, why not
convert this code to do that instead, which will fix all of these bugs
automatically, right?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ