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: <20230614131746.3670303-1-songshuaishuai@tinylab.org>
Date:   Wed, 14 Jun 2023 21:17:46 +0800
From:   Song Shuai <songshuaishuai@...ylab.org>
To:     rppt@...nel.org, akpm@...ux-foundation.org
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        Song Shuai <songshuaishuai@...ylab.org>
Subject: [PATCH] memblock: Add error message when memblock_can_resize is not ready

The memblock APIs are always correct, thus the callers usually don't
handle the return code. But the failure caused by unready memblock_can_resize
is hard to recognize without the return code. Like this piece of log:

```
[    0.000000] memblock_phys_alloc_range: 4096 bytes align=0x1000 from=0x0000000000000000 max_addr=0x0000000000000000 alloc_pmd_fixmap+0x14/0x1c
[    0.000000] memblock_reserve: [0x000000017ffff000-0x000000017fffffff] memblock_alloc_range_nid+0xb8/0x128
[    0.000000] Oops - store (or AMO) access fault [#1]
```

So add an error message for this kind of failure:

```
[    0.000000] memblock_phys_alloc_range: 4096 bytes align=0x1000 from=0x0000000000000000 max_addr=0x0000000000000000 alloc_pmd_fixmap+0x14/0x1c
[    0.000000] memblock_reserve: [0x000000017ffff000-0x000000017fffffff] memblock_alloc_range_nid+0xb8/0x128
[    0.000000] memblock: Can't double reserved array for area start 0x000000017ffff000 size 4096
[    0.000000] Oops - store (or AMO) access fault [#1]
```

Signed-off-by: Song Shuai <songshuaishuai@...ylab.org>
---
 mm/memblock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 3feafea06ab2..ab952a164f62 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -418,8 +418,11 @@ static int __init_memblock memblock_double_array(struct memblock_type *type,
 	/* We don't allow resizing until we know about the reserved regions
 	 * of memory that aren't suitable for allocation
 	 */
-	if (!memblock_can_resize)
+	if (!memblock_can_resize) {
+		pr_err("memblock: Can't double %s array for area start %pa size %ld\n",
+			type->name, &new_area_start, (unsigned long)new_area_size);
 		return -1;
+	}
 
 	/* Calculate new doubled size */
 	old_size = type->max * sizeof(struct memblock_region);
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ