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-next>] [day] [month] [year] [list]
Message-Id: <20230324052351.31106-1-jhb_ee@163.com>
Date:   Fri, 24 Mar 2023 13:23:51 +0800
From:   Hongbin Ji <jhb_ee@....com>
To:     rppt@...nel.org
Cc:     akpm@...ux-foundation.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, Hongbin Ji <jhb_ee@....com>
Subject: [PATCH] memblock: Correct calculation method for overflowing range @size

When memblock users to specify range where @base + @size overflows
and automatically cap it at maximum, The new size should be
PHYS_ADDR_MAX - @base + 1.

Assuming that base is 0, PHYS_ADDR_MAX is 0xff, which is 255 in decimal,
then @size should be 256 instead of 255

Signed-off-by: Hongbin Ji <jhb_ee@....com>
---
 mm/memblock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 25fd0626a9e7..f1683d1dae65 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -169,7 +169,7 @@ static enum memblock_flags __init_memblock choose_memblock_flags(void)
 /* adjust *@...e so that (@base + *@...e) doesn't overflow, return new size */
 static inline phys_addr_t memblock_cap_size(phys_addr_t base, phys_addr_t *size)
 {
-	return *size = min(*size, PHYS_ADDR_MAX - base);
+	return *size = min(*size, PHYS_ADDR_MAX - base + 1);
 }
 
 /*
-- 
2.34.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ