Harshit Sharma has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/43938 )
Change subject: [DONOTSUBMIT]lib: Introduce memory bugs to help test ASan ......................................................................
[DONOTSUBMIT]lib: Introduce memory bugs to help test ASan
Introduces a few memory bugs into cbfs code to make testing easier for the ones who are willing to try out ASan on their hardware.
Change-Id: I0839f2fd2863934ec28e2322bab04b9cc33363b4 Signed-off-by: Harshit Sharma harshitsharmajs@gmail.com --- M src/lib/cbfs.c 1 file changed, 21 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/38/43938/1
diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c index cb66f81..839de94 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -330,9 +330,30 @@ return 0; }
+#if ENV_RAMSTAGE + int global_array[5] = {-1}; +#endif + int cbfs_boot_region_device(struct region_device *rdev) { + int stack_array[5], i, *p; boot_device_init(); + + /* global out-of-bounds */ +#if ENV_RAMSTAGE + for (i = 10; i > 0; i--) + global_array[i] = i; +#endif + /* stack out-of-bounds */ + for (i = 10; i > 0; i--) + stack_array[i] = i; + + /* use-after-scope */ + { + int x = 5; + p = &x; + } + *p = 10; return vboot_locate_cbfs(rdev) && fmap_locate_area_as_rdev("COREBOOT", rdev); }