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]
Date:   Wed, 16 Jun 2021 12:05:01 -0600
From:   Rob Herring <robh@...nel.org>
To:     Geert Uytterhoeven <geert+renesas@...der.be>
Cc:     linux-kernel@...r.kernel.org, devicetree@...r.kernel.org,
        Frank Rowand <frowand.list@...il.com>,
        Rob Herring <robh+dt@...nel.org>,
        Marek Szyprowski <m.szyprowski@...sung.com>
Subject: Re: [PATCH 1/3] of: Fix truncation of memory sizes on 32-bit
 platforms

On Wed, 16 Jun 2021 11:27:44 +0200, Geert Uytterhoeven wrote:
> Variable "size" has type "phys_addr_t", which can be either 32-bit or
> 64-bit on 32-bit systems, while "unsigned long" is always 32-bit on
> 32-bit systems.  Hence the cast in
> 
>     (unsigned long)size / SZ_1M
> 
> may truncate a 64-bit size to 32-bit, as casts have a higher operator
> precedence than divisions.
> 
> Fix this by inverting the order of the cast and division, which should
> be safe for memory blocks smaller than 4 PiB.  Note that the division is
> actually a shift, as SZ_1M is a power-of-two constant, hence there is no
> need to use div_u64().
> 
> While at it, use "%lu" to format "unsigned long".
> 
> Fixes: e8d9d1f5485b52ec ("drivers: of: add initialization code for static reserved memory")
> Fixes: 3f0c8206644836e4 ("drivers: of: add initialization code for dynamic reserved memory")
> Signed-off-by: Geert Uytterhoeven <geert+renesas@...der.be>
> ---
>  drivers/of/fdt.c             | 8 ++++----
>  drivers/of/of_reserved_mem.c | 8 ++++----
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 

Applied, thanks!

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ