Commit e7654c3f authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Paul E. McKenney

tools/nolibc: tests: use volatile to force stack smashing

Use a volatile pointer to write outside the buffer so the compiler can't
optimize it away.
Reported-by: default avatarAlexey Dobriyan <adobriyan@gmail.com>
Link: https://lore.kernel.org/lkml/c0584807-511c-4496-b062-1263ea38f349@p183/Signed-off-by: default avatarThomas Weißschuh <linux@weissschuh.net>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
Signed-off-by: default avatarPaul E. McKenney <paulmck@kernel.org>
parent ac9a7868
......@@ -667,17 +667,13 @@ int run_stdlib(int min, int max)
return ret;
}
#if defined(__clang__)
__attribute__((optnone))
#elif defined(__GNUC__)
__attribute__((optimize("O0")))
#endif
static int smash_stack(void)
{
char buf[100];
volatile char *ptr = buf;
for (size_t i = 0; i < 200; i++)
buf[i] = 'P';
ptr[i] = 'P';
return 1;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment