* [PATCH] lkdtm: fortify: Fix potential NULL dereference on kmalloc failure
@ 2025-08-14 6:06 Junjie Cao
2025-08-25 13:32 ` Kees Cook
0 siblings, 1 reply; 2+ messages in thread
From: Junjie Cao @ 2025-08-14 6:06 UTC (permalink / raw)
To: Kees Cook; +Cc: Arnd Bergmann, Greg Kroah-Hartman, linux-kernel, Junjie Cao
Add missing NULL pointer checks after kmalloc() calls in
lkdtm_FORTIFY_STR_MEMBER() and lkdtm_FORTIFY_MEM_MEMBER() functions.
Signed-off-by: Junjie Cao <junjie.cao@intel.com>
---
drivers/misc/lkdtm/fortify.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/misc/lkdtm/fortify.c b/drivers/misc/lkdtm/fortify.c
index 015927665678..715598226037 100644
--- a/drivers/misc/lkdtm/fortify.c
+++ b/drivers/misc/lkdtm/fortify.c
@@ -44,6 +44,10 @@ static void lkdtm_FORTIFY_STR_MEMBER(void)
char *src;
src = kmalloc(size, GFP_KERNEL);
+
+ if (src == NULL)
+ return;
+
strscpy(src, "over ten bytes", size);
size = strlen(src) + 1;
@@ -109,6 +113,10 @@ static void lkdtm_FORTIFY_MEM_MEMBER(void)
char *src;
src = kmalloc(size, GFP_KERNEL);
+
+ if (src == NULL)
+ return;
+
strscpy(src, "over ten bytes", size);
size = strlen(src) + 1;
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-25 13:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-14 6:06 [PATCH] lkdtm: fortify: Fix potential NULL dereference on kmalloc failure Junjie Cao
2025-08-25 13:32 ` Kees Cook
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®