2021-04-11 09:21:58 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Copyright 2021 Broadcom
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
|
|
|
|
static int do_test_stackprot_fail(struct cmd_tbl *cmdtp, int flag, int argc,
|
|
|
|
char *const argv[])
|
|
|
|
{
|
2021-05-24 18:19:05 +00:00
|
|
|
/*
|
|
|
|
* In order to avoid having the compiler optimize away the stack smashing
|
|
|
|
* we need to do a little something here.
|
|
|
|
*/
|
2021-04-11 09:21:58 +00:00
|
|
|
char a[128];
|
|
|
|
|
|
|
|
memset(a, 0xa5, 512);
|
2021-05-24 18:19:05 +00:00
|
|
|
|
2022-02-04 09:50:04 +00:00
|
|
|
printf("We have smashed our stack as this should not exceed 128: sizeof(a) = %zd\n",
|
|
|
|
strlen(a));
|
2021-05-24 18:19:05 +00:00
|
|
|
|
2021-04-11 09:21:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
U_BOOT_CMD(stackprot_test, 1, 1, do_test_stackprot_fail,
|
|
|
|
"test stack protector fail", "");
|