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:   Thu,  6 Apr 2023 16:14:29 +0100
From:   Lucas Tanure <tanure@...ux.com>
To:     Rob Herring <robh+dt@...nel.org>,
        Frank Rowand <frowand.list@...il.com>,
        Mike Rapoport <rppt@...nel.org>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, jbrunet@...libre.com,
        linux-amlogic@...ts.infradead.org,
        linux-arm-kernel@...ts.infradead.org,
        martin.blumenstingl@...glemail.com, narmstrong@...libre.com,
        stefan@...er.ch, Lucas Tanure <tanure@...ux.com>
Subject: [PATCH 2/2] of: fdt: Allow the kernel to mark nomap regions received from fdt

Reserved regions can be described in FDT and device trees, but FDT doesn't
provide the related flags, like nomap.
So allow the kernel to mark regions where the base and size received from
the device tree are the same as the base and region on FDT.
Here we trust that the device tree has a more updated description of the
region than the one received from FDT.

Signed-off-by: Lucas Tanure <tanure@...ux.com>
---
 drivers/of/fdt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d1a68b6d03b3..754a7ea4f45c 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -482,11 +482,13 @@ static int __init early_init_dt_reserve_memory(phys_addr_t base,
 	if (nomap) {
 		/*
 		 * If the memory is already reserved (by another region), we
-		 * should not allow it to be marked nomap, but don't worry
-		 * if the region isn't memory as it won't be mapped.
+		 * should not allow it to be marked nomap, unless is the exact same region
+		 * (same base and size), which the kernel knows better and should be allowed to mark
+		 *  it as nomap.
+		 * But don't worry if the region isn't memory as it won't be mapped.
 		 */
-		if (memblock_overlaps_region(&memblock.memory, base, size) &&
-		    memblock_is_region_reserved(base, size))
+		if (memblock_overlaps_region(&memblock.memory, base, size) == MEMBLOCK_OVERLAPS &&
+		    memblock_is_region_reserved(base, size) == MEMBLOCK_OVERLAPS)
 			return -EBUSY;
 
 		return memblock_mark_nomap(base, size);
-- 
2.40.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ