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: <20200213090959.GA2123@ninjato>
Date:   Thu, 13 Feb 2020 10:09:59 +0100
From:   Wolfram Sang <wsa@...-dreams.de>
To:     "Gustavo A. R. Silva" <gustavo@...eddedor.com>
Cc:     Thor Thayer <thor.thayer@...ux.intel.com>,
        Andy Shevchenko <andy.shevchenko@...il.com>,
        David Laight <David.Laight@...LAB.COM>,
        linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] i2c: altera: Fix potential integer overflow

On Tue, Feb 11, 2020 at 08:47:04AM -0600, Gustavo A. R. Silva wrote:
> Factor out 100 from the equation and do 32-bit arithmetic (3 * clk_mhz / 10)
> instead of 64-bit.
> 
> Notice that clk_mhz is MHz, so the multiplication will never wrap 32 bits
> and there is no need for div_u64().

Was there ever? With

	u32 clk_mhz = clk_get_rate(idev->i2c_clk) / 1000000;

a later multiplication with 300 should not wrap u32?

>  	/* SDA Hold Time, 300ns */
> -	writel(div_u64(300 * clk_mhz, 1000), idev->base + ALTR_I2C_SDA_HOLD);
> +	writel(3 * clk_mhz / 10, idev->base + ALTR_I2C_SDA_HOLD);

The change itself is OK, yet I wonder about the comment above:

'clk_mhz * 0.3' will not give a constant 300ns, or?


Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ