bl33: uboot 2023 need enbale uasan [1/1]
PD#SWPL-126938
Problem:
uboot 2023 need enbale uasan
Solution:
enable uasan for uboot 2023
Verify:
s4_ap222
BUG: UASAN: malloc-out-of-bounds in hexport_r
Write of size 126972 at addr 0000000077571844
Memory state around the buggy address: 000000006eeae308
0000000077571700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0000000077571780: 00 00 00 00 f1 f1 f1 f1 00 f3 f3 f3 00 00 00 00
0000000077571800: fe fe fe fe f1 f1 f1 f1 fe fe fe fe fe fe fe fe
^
0000000077571880: fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe fe
0000000077571900: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Call trace:
[<000000007f5b62b0>] dump_backtrace+0x0/0x1dc
[<000000007f702240>] uasan_report+0x10c/0x2e4
[<000000007f702720>] memset+0x2c/0x4c
[<000000007f6fb040>] hexport_r+0x294/0x3d0
[<000000007f697cdc>] env_export+0xa0/0x110
[<000000007f699750>] env_storage_save+0xf4/0x13c
[<000000007f698274>] env_save+0xa4/0xe4
[<000000007f60a524>] do_env_save+0x8/0x1c
[<000000007f61d7ac>] cmd_process+0x1d8/0x240
[<000000007f60db98>] run_list_real+0x998/0x9e0
Change-Id: I6fd02b3fa3370f9adc32415a0a14968a31822c01
Signed-off-by: Bo Lv <bo.lv@amlogic.com>
diff --git a/common/board_r.c b/common/board_r.c
index f67545c..5444a31 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -220,6 +220,10 @@
* reserve_noncached().
*/
malloc_start = gd->relocaddr - TOTAL_MALLOC_LEN;
+#ifdef CONFIG_AML_UASAN
+ /* skip red zone size */
+ malloc_start -= MEM_SECTION_RED_ZONE_SIZE;
+#endif
mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN),
TOTAL_MALLOC_LEN);
return 0;