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: <2025051109-corner-womanless-e400@gregkh>
Date: Sun, 11 May 2025 07:52:10 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Siddarth Gundu <siddarthsgml@...il.com>
Cc: b-liu@...com, linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org,
	skhan@...uxfoundation.org
Subject: Re: [PATCH] usb: musb: Fix signed integer overflow

On Sun, May 11, 2025 at 02:42:17AM +0530, Siddarth Gundu wrote:
> Shifting 1 << 31 on a 32-bit int causes signed integer overflow, which
> leads to undefined behavior.
> 
> Cast 1 to u32 before performing the shift, eliminating the
> undefined behavior.
> 
> Signed-off-by: Siddarth Gundu <siddarthsgml@...il.com>
> ---
>  drivers/usb/musb/cppi_dma.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/musb/cppi_dma.h b/drivers/usb/musb/cppi_dma.h
> index 3606be897cb2..33bf5f83f08d 100644
> --- a/drivers/usb/musb/cppi_dma.h
> +++ b/drivers/usb/musb/cppi_dma.h
> @@ -38,7 +38,7 @@ struct cppi_rx_stateram {
>  };
>  
>  /* hw_options bits in CPPI buffer descriptors */
> -#define CPPI_SOP_SET	((u32)(1 << 31))
> +#define CPPI_SOP_SET	((u32)1 << 31)

Why not just use the proper BIT() macro instead?

And does this actually overflow and cause problems?  What is the result
of the original code where it is an issue in the driver?  Have you
tested it?  Is the assembly output actually different?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ