mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
common: cmd_boot: Add stack canary test command.
This change will add stack canary test command in u-boot command list. The stack canary test command format like as : canary <string>. The string must be 10 bytes long. e.g " #canary Helloworldhelloworld". After this command we can see the below print. Stack Canary test start. stack-protector: U-boot stack is corrupted. Resetting CPU ... If stack-protection not enabled and stack overflow occure then we will get the following print. prefetch abort pc : [<4a006f72>] lr : [<4a90faf0>] reloc pc : [<4a006f72>] lr : [<4a90faf0>] sp : 4a77f948 ip : 20f14495 fp : 4a90fab4 r10: 00000002 r9 : 4a77fea0 r8 : 00000000 r7 : 4a983d20 r6 : 6f6f6f6f r5 : 6f6f6f6f r4 : 6f6f6f6f r3 : 00000000 r2 : 4a77f946 r1 : 4a78233b r0 : 00000000 Flags: nZCv IRQs off FIQs off Mode SVC_32 Resetting CPU ... Change-Id: If36d1da3ecc1d0038cd1a6bad6ab3d265b47dac8 Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
This commit is contained in:
parent
8aef0ad840
commit
f80127f8a7
2 changed files with 20 additions and 0 deletions
|
|
@ -82,6 +82,7 @@ typedef struct {
|
||||||
void __stack_chk_fail(void)
|
void __stack_chk_fail(void)
|
||||||
{
|
{
|
||||||
printf("stack-protector: U-boot stack is corrupted.\n");
|
printf("stack-protector: U-boot stack is corrupted.\n");
|
||||||
|
bad_mode ();
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Set the root device and bootargs for mounting root filesystem.
|
* Set the root device and bootargs for mounting root filesystem.
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,25 @@ static int do_go(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||||
printf ("## Application terminated, rc = 0x%lX\n", rc);
|
printf ("## Application terminated, rc = 0x%lX\n", rc);
|
||||||
return rcode;
|
return rcode;
|
||||||
}
|
}
|
||||||
|
static int do_canary(cmd_tbl_t *cmdtp, int flag, int argc,
|
||||||
|
char * const argv[])
|
||||||
|
{
|
||||||
|
char Buffer[10] = {'\0'};
|
||||||
|
printf("Stack Canary test start.\n");
|
||||||
|
|
||||||
|
if (argc < 2 || argc > 2)
|
||||||
|
return CMD_RET_USAGE;
|
||||||
|
|
||||||
|
strlcpy(Buffer, argv[1], strlen(argv[1]));
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
U_BOOT_CMD(
|
||||||
|
canary, 2, 0, do_canary,
|
||||||
|
"test stack canary",
|
||||||
|
"\n canary HelloworldHelloWorld \n"
|
||||||
|
);
|
||||||
|
|
||||||
/* -------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue