* [PATCH] lkdtm/fortify: Swap memcpy() for strncpy()
@ 2022-02-16 20:25 Kees Cook
2022-02-18 10:02 ` Muhammad Usama Anjum
0 siblings, 1 reply; 2+ messages in thread
From: Kees Cook @ 2022-02-16 20:25 UTC (permalink / raw)
To: Muhammad Usama Anjum
Cc: Kees Cook, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel,
linux-hardening
The memcpy() runtime defenses are still not landed, so test with
strncpy() for now.
Reported-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/misc/lkdtm/fortify.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/lkdtm/fortify.c b/drivers/misc/lkdtm/fortify.c
index d06458a4858e..ab33bb5e2e7a 100644
--- a/drivers/misc/lkdtm/fortify.c
+++ b/drivers/misc/lkdtm/fortify.c
@@ -44,14 +44,14 @@ void lkdtm_FORTIFIED_SUBOBJECT(void)
strscpy(src, "over ten bytes", size);
size = strlen(src) + 1;
- pr_info("trying to strcpy past the end of a member of a struct\n");
+ pr_info("trying to strncpy past the end of a member of a struct\n");
/*
- * memcpy(target.a, src, 20); will hit a compile error because the
+ * strncpy(target.a, src, 20); will hit a compile error because the
* compiler knows at build time that target.a < 20 bytes. Use a
* volatile to force a runtime error.
*/
- memcpy(target.a, src, size);
+ strncpy(target.a, src, size);
/* Store result to global to prevent the code from being eliminated */
fortify_scratch_space = target.a[3];
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] lkdtm/fortify: Swap memcpy() for strncpy()
2022-02-16 20:25 [PATCH] lkdtm/fortify: Swap memcpy() for strncpy() Kees Cook
@ 2022-02-18 10:02 ` Muhammad Usama Anjum
0 siblings, 0 replies; 2+ messages in thread
From: Muhammad Usama Anjum @ 2022-02-18 10:02 UTC (permalink / raw)
To: Kees Cook
Cc: usama.anjum, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel,
linux-hardening
On 2/17/22 1:25 AM, Kees Cook wrote:
> The memcpy() runtime defenses are still not landed, so test with
> strncpy() for now.
>
> Reported-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-18 10:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 20:25 [PATCH] lkdtm/fortify: Swap memcpy() for strncpy() Kees Cook
2022-02-18 10:02 ` Muhammad Usama Anjum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®