blob: 1e26193e88b054abba8f70f57047fd54537015ca [file] [log] [blame]
Joel Peshkin4e9bce12021-04-11 11:21:58 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2021 Broadcom
4 */
5
6#include <common.h>
7#include <command.h>
8
9static int do_test_stackprot_fail(struct cmd_tbl *cmdtp, int flag, int argc,
10 char *const argv[])
11{
Tom Rini2fc62f22021-05-24 14:19:05 -040012 /*
13 * In order to avoid having the compiler optimize away the stack smashing
14 * we need to do a little something here.
15 */
Joel Peshkin4e9bce12021-04-11 11:21:58 +020016 char a[128];
17
18 memset(a, 0xa5, 512);
Tom Rini2fc62f22021-05-24 14:19:05 -040019
20 printf("We have smashed our stack as this should not exceed 128: sizeof(a) = %ld\n", strlen(a));
21
Joel Peshkin4e9bce12021-04-11 11:21:58 +020022 return 0;
23}
24
25U_BOOT_CMD(stackprot_test, 1, 1, do_test_stackprot_fail,
26 "test stack protector fail", "");