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] [thread-next>] [day] [month] [year] [list]
Message-ID: <d24a4b7f-0d3a-4c24-9de3-5f14297b0904@rowland.harvard.edu>
Date: Thu, 25 Jul 2024 14:23:25 -0400
From: Alan Stern <stern@...land.harvard.edu>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: crwulff@...il.com, linux-usb@...r.kernel.org,
	Roy Luo <royluo@...gle.com>,
	Krishna Kurapati <quic_kriskura@...cinc.com>,
	Michael Grzeschik <m.grzeschik@...gutronix.de>,
	yuan linyu <yuanlinyu@...onor.com>,
	Paul Cercueil <paul@...pouillou.net>,
	Felipe Balbi <balbi@...nel.org>, linux-kernel@...r.kernel.org,
	stable@...r.kernel.org
Subject: Re: [PATCH v2] usb: gadget: core: Check for unset descriptor

On Thu, Jul 25, 2024 at 06:56:19AM +0200, Greg Kroah-Hartman wrote:
> On Wed, Jul 24, 2024 at 09:04:20PM -0400, crwulff@...il.com wrote:
> > From: Chris Wulff <crwulff@...il.com>
> > 
> > Make sure the descriptor has been set before looking at maxpacket.
> > This fixes a null pointer panic in this case.
> > 
> > This may happen if the gadget doesn't properly set up the endpoint
> > for the current speed, or the gadget descriptors are malformed and
> > the descriptor for the speed/endpoint are not found.
> > 
> > No current gadget driver is known to have this problem, but this
> > may cause a hard-to-find bug during development of new gadgets.
> > 
> > Fixes: 54f83b8c8ea9 ("USB: gadget: Reject endpoints with 0 maxpacket value")
> > Cc: stable@...r.kernel.org
> > Signed-off-by: Chris Wulff <crwulff@...il.com>
> > ---
> > v2: Added WARN_ONCE message & clarification on causes
> > v1: https://lore.kernel.org/all/20240721192048.3530097-2-crwulff@gmail.com/
> > ---
> >  drivers/usb/gadget/udc/core.c | 10 ++++------
> >  1 file changed, 4 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> > index 2dfae7a17b3f..81f9140f3681 100644
> > --- a/drivers/usb/gadget/udc/core.c
> > +++ b/drivers/usb/gadget/udc/core.c
> > @@ -118,12 +118,10 @@ int usb_ep_enable(struct usb_ep *ep)
> >  		goto out;
> >  
> >  	/* UDC drivers can't handle endpoints with maxpacket size 0 */
> > -	if (usb_endpoint_maxp(ep->desc) == 0) {
> > -		/*
> > -		 * We should log an error message here, but we can't call
> > -		 * dev_err() because there's no way to find the gadget
> > -		 * given only ep.
> > -		 */
> > +	if (!ep->desc || usb_endpoint_maxp(ep->desc) == 0) {
> > +		WARN_ONCE(1, "%s: ep%d (%s) has %s\n", __func__, ep->address, ep->name,
> > +			  (!ep->desc) ? "NULL descriptor" : "maxpacket 0");
> 
> So you just rebooted a machine that hit this, that's not good at all.
> Please log the error and recover, don't crash a system (remember,
> panic-on-warn is enabled in billions of Linux systems.)

That should not be a problem.  This WARN_ONCE is expected never to be 
triggered except by a buggy gadget driver.  It's a debugging tool; the 
developer will get an indication in the kernel log of where the problem 
is instead of just a panic.

However, if you feel strongly about this, Chris probably won't mind 
changing it to pr_err() plus dump_stack() instead of WARN_ONCE().

Alan Stern

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ