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: <YgurCSqIL/VkaBmR@kroah.com>
Date:   Tue, 15 Feb 2022 14:30:49 +0100
From:   Greg KH <gregKH@...uxfoundation.org>
To:     Oliver Neukum <oneukum@...e.com>
Cc:     davem@...emloft.net, kuba@...nel.org, netdev@...r.kernel.org,
        linux-usb@...r.kernel.org
Subject: Re: [PATCH] CDC-NCM: avoid overflow in sanity checking

On Tue, Feb 15, 2022 at 11:35:47AM +0100, Oliver Neukum wrote:
> A broken device may give an extreme offset like 0xFFF0
> and a reasonable length for a fragment. In the sanity
> check as formulated now, this will create an integer
> overflow, defeating the sanity check. Both offset
> and offset + len need to be checked in such a manner
> that no overflow can occur.
> And those quantities should be unsigned.
> 
> Signed-off-by: Oliver Neukum <oneukum@...e.com>
> ---
>  drivers/net/usb/cdc_ncm.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
> index e303b522efb5..15f91d691bba 100644
> --- a/drivers/net/usb/cdc_ncm.c
> +++ b/drivers/net/usb/cdc_ncm.c
> @@ -1715,10 +1715,10 @@ int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
>  {
>  	struct sk_buff *skb;
>  	struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
> -	int len;
> +	unsigned int len;
>  	int nframes;
>  	int x;
> -	int offset;
> +	unsigned int offset;
>  	union {
>  		struct usb_cdc_ncm_ndp16 *ndp16;
>  		struct usb_cdc_ncm_ndp32 *ndp32;
> @@ -1790,8 +1790,8 @@ int cdc_ncm_rx_fixup(struct usbnet *dev, struct sk_buff *skb_in)
>  			break;
>  		}
>  
> -		/* sanity checking */
> -		if (((offset + len) > skb_in->len) ||
> +		/* sanity checking - watch out for integer wrap*/
> +		if ((offset > skb_in->len) || (len > skb_in->len - offset) ||
>  				(len > ctx->rx_max) || (len < ETH_HLEN)) {
>  			netif_dbg(dev, rx_err, dev->net,
>  				  "invalid frame detected (ignored) offset[%u]=%u, length=%u, skb=%p\n",
> -- 
> 2.34.1
> 

Reviewed-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc: stable <stable@...r.kernel.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ