From: Willy Tarreau <w@1wt.eu>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: linux@weissschuh.net, linux-kernel@vger.kernel.org,
Alexey Dobriyan <adobriyan@gmail.com>, Willy Tarreau <w@1wt.eu>
Subject: [PATCH 1/1] tools/nolibc: tests: use volatile to force stack smashing
Date: Tue, 28 Mar 2023 18:18:45 +0200 [thread overview]
Message-ID: <20230328161845.9584-2-w@1wt.eu> (raw)
In-Reply-To: <20230328161845.9584-1-w@1wt.eu>
From: Thomas Weißschuh <linux@weissschuh.net>
Use a volatile pointer to write outside the buffer so the compiler can't
optimize it away.
Reported-by: Alexey Dobriyan <adobriyan@gmail.com>
Link: https://lore.kernel.org/lkml/c0584807-511c-4496-b062-1263ea38f349@p183/
Signed-off-by: Thomas Weißschuh <linux@weissschuh.net>
Signed-off-by: Willy Tarreau <w@1wt.eu>
---
tools/testing/selftests/nolibc/nolibc-test.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index 21bacc928bf7..47013b78972e 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -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;
}
--
2.17.5
next prev parent reply other threads:[~2023-03-28 16:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-28 16:18 [PATCH 0/1] tools/nolibc: tests: use volatile to force stack smashing Willy Tarreau
2023-03-28 16:18 ` Willy Tarreau [this message]
2023-03-28 18:29 ` Paul E. McKenney
2023-03-28 18:51 ` Willy Tarreau
2023-03-28 20:01 ` Paul E. McKenney
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230328161845.9584-2-w@1wt.eu \
--to=w@1wt.eu \
--cc=adobriyan@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=paulmck@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox