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: <ZwA8OWFJhAuvWDJh@freebase>
Date: Fri, 4 Oct 2024 21:04:25 +0200
From: Olivier Dautricourt <olivierdautricourt@...il.com>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: Mathias Nyman <mathias.nyman@...el.com>, linux-usb@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	MichaƂ Pecio <michal.pecio@...il.com>
Subject: Re: [PATCH] usb: xhci: xhci_setup_port_arrays: early -ENODEV if
 maxports is 0.

Hello,

On Fri, Oct 04, 2024 at 10:07:01AM +0200, Greg Kroah-Hartman wrote:
> On Mon, Sep 30, 2024 at 07:23:29AM +0200, Olivier Dautricourt wrote:
> > If the controller reports HCSPARAMS1.maxports==0 then we can skip the
> > whole function: it would fail later after doing a bunch of unnecessary
> > stuff. It can occur on a buggy hardware (the value is driven by external
> > signals).
> 
> What "buggy hardware" is this that can not pass the USB testing for this
> type of issue?

This is a behaviour found while debugging a custom firmware where this
value happen to be controlled here, i don't know any hardware out there
with such issue, this change should be seen as a software nitpick and is
not trying to fix a specific hardware.

> 
> > 
> > Signed-off-by: Olivier Dautricourt <olivierdautricourt@...il.com>
> > ---
> >  drivers/usb/host/xhci-mem.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
> > index d2900197a49e..e8406db78782 100644
> > --- a/drivers/usb/host/xhci-mem.c
> > +++ b/drivers/usb/host/xhci-mem.c
> > @@ -2160,6 +2160,11 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
> >  	struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
> >  
> >  	num_ports = HCS_MAX_PORTS(xhci->hcs_params1);
> > +	if (num_ports == 0) {
> > +		xhci_warn(xhci, "Host controller has no port enabled\n");
> > +		return -ENODEV;
> > +	}
> 
> Should this be backported to older kernels, if so, how far back if this
> is common hardware?

I don't think this would have to be ported to stable trees: The function
handles the case without failure: the 0 value is propagated until line
2220 and fails on condition:
	if (xhci->usb2_rhub.num_ports == 0 && xhci->usb3_rhub.num_ports == 0) {
		xhci_warn(xhci, "No ports on the roothubs?\n");
		return -ENODEV;
	}

The change merely avoids passing 0 value through kcalloc_node calls and
unnecessary accesses to the capability structures of the controller.

Kr,
Olivier

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ