From: Heiko Carstens <hca@linux.ibm.com>
To: Kees Cook <keescook@chromium.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Popov <alex.popov@linux.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] stackleak: allow to specify arch specific stackleak poison function
Date: Wed, 5 Apr 2023 15:08:40 +0200 [thread overview]
Message-ID: <20230405130841.1350565-2-hca@linux.ibm.com> (raw)
In-Reply-To: <20230405130841.1350565-1-hca@linux.ibm.com>
Factor out the code that fills the stack with the stackleak poison value
in order to allow architectures to provide a faster implementation.
Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
---
kernel/stackleak.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/kernel/stackleak.c b/kernel/stackleak.c
index c2c33d2202e9..34c9d81eea94 100644
--- a/kernel/stackleak.c
+++ b/kernel/stackleak.c
@@ -70,6 +70,18 @@ late_initcall(stackleak_sysctls_init);
#define skip_erasing() false
#endif /* CONFIG_STACKLEAK_RUNTIME_DISABLE */
+#ifndef __stackleak_poison
+static __always_inline void __stackleak_poison(unsigned long erase_low,
+ unsigned long erase_high,
+ unsigned long poison)
+{
+ while (erase_low < erase_high) {
+ *(unsigned long *)erase_low = poison;
+ erase_low += sizeof(unsigned long);
+ }
+}
+#endif
+
static __always_inline void __stackleak_erase(bool on_task_stack)
{
const unsigned long task_stack_low = stackleak_task_low_bound(current);
@@ -101,10 +113,7 @@ static __always_inline void __stackleak_erase(bool on_task_stack)
else
erase_high = task_stack_high;
- while (erase_low < erase_high) {
- *(unsigned long *)erase_low = STACKLEAK_POISON;
- erase_low += sizeof(unsigned long);
- }
+ __stackleak_poison(erase_low, erase_high, STACKLEAK_POISON);
/* Reset the 'lowest_stack' value for the next syscall */
current->lowest_stack = task_stack_high;
--
2.37.2
next prev parent reply other threads:[~2023-04-05 13:09 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-05 13:08 [PATCH 0/2] stackleak: allow to specify arch specific stackleak poison function Heiko Carstens
2023-04-05 13:08 ` Heiko Carstens [this message]
2023-04-12 9:03 ` [PATCH 1/2] " Mark Rutland
2023-04-12 9:58 ` Heiko Carstens
2023-04-12 10:06 ` Mark Rutland
2023-04-05 13:08 ` [PATCH 2/2] s390/stackleak: provide fast __stackleak_poison() implementation Heiko Carstens
2023-04-12 9:02 ` Mark Rutland
2023-04-18 17:21 ` [PATCH 0/2] stackleak: allow to specify arch specific stackleak poison function Heiko Carstens
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=20230405130841.1350565-2-hca@linux.ibm.com \
--to=hca@linux.ibm.com \
--cc=alex.popov@linux.com \
--cc=gor@linux.ibm.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
/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