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]
Message-ID: <Pine.LNX.4.44L0.1006281017460.1977-100000@iolanthe.rowland.org>
Date:	Mon, 28 Jun 2010 10:18:56 -0400 (EDT)
From:	Alan Stern <stern@...land.harvard.edu>
To:	Andrea Righi <arighi@...eler.com>
cc:	Rodolfo Giometti <giometti@...eenne.com>,
	Amit Walambe <amit.walambe@...otech.com>,
	Chris Leahy <leahycm@...il.com>,
	Giovanni Bajo <rasky@...eler.com>, <linux-usb@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] USB: EHCI: fix NULL pointer dererence in HCDs that use
 HCD_LOCAL_MEM

On Mon, 28 Jun 2010, Andrea Righi wrote:

> If we use the HCD_LOCAL_MEM flag and dma_declare_coherent_memory() to
> enforce the host controller's local memory utilization we also need to
> disable native scatter-gather support, otherwise hcd_alloc_coherent() in
> map_urb_for_dma() is called with urb->transfer_buffer == NULL, that
> triggers a NULL pointer dereference.
> 
> We can also consider to add a WARN_ON() and return an error code to
> better catch this problem in the future.
> 
> Signed-off-by: Andrea Righi <arighi@...eler.com>
> ---
>  drivers/usb/core/hcd.c      |    5 +++++
>  drivers/usb/host/ehci-hcd.c |    3 ++-
>  2 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
> index 12742f1..161c757 100644
> --- a/drivers/usb/core/hcd.c
> +++ b/drivers/usb/core/hcd.c
> @@ -1219,6 +1219,11 @@ static int hcd_alloc_coherent(struct usb_bus *bus,
>  {
>  	unsigned char *vaddr;
>  
> +	if (*vaddr_handle == NULL) {
> +		WARN_ON_ONCE(1);
> +		return -EFAULT;
> +	}
> +
>  	vaddr = hcd_buffer_alloc(bus, size + sizeof(vaddr),
>  				 mem_flags, dma_handle);
>  	if (!vaddr)
> diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
> index a3ef2a9..27e0351 100644
> --- a/drivers/usb/host/ehci-hcd.c
> +++ b/drivers/usb/host/ehci-hcd.c
> @@ -606,7 +606,8 @@ static int ehci_init(struct usb_hcd *hcd)
>  	ehci->command = temp;
>  
>  	/* Accept arbitrarily long scatter-gather lists */
> -	hcd->self.sg_tablesize = ~0;
> +	if (!(hcd->driver->flags & HCD_LOCAL_MEM))
> +		hcd->self.sg_tablesize = ~0;
>  	return 0;
>  }

Looks okay to me.  You can add my Acked-by: when you submit this to 
Greg KH.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ