[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230217183740.3039-1-zeming@nfschina.com>
Date: Sat, 18 Feb 2023 02:37:40 +0800
From: Li zeming <zeming@...china.com>
To: keescook@...omium.org, arnd@...db.de, gregkh@...uxfoundation.org
Cc: linux-kernel@...r.kernel.org, Li zeming <zeming@...china.com>
Subject: [PATCH] fortify: Increase pointer assignment check
Increase the check after the src pointer allocates memory. If these two
functions are used, at least increase some robustness.
Signed-off-by: Li zeming <zeming@...china.com>
---
drivers/misc/lkdtm/fortify.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/misc/lkdtm/fortify.c b/drivers/misc/lkdtm/fortify.c
index 015927665678..5c32e4e81d37 100644
--- a/drivers/misc/lkdtm/fortify.c
+++ b/drivers/misc/lkdtm/fortify.c
@@ -44,6 +44,9 @@ 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 +112,9 @@ 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.18.2
Powered by blists - more mailing lists