lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 25 Jul 2022 16:11:53 +0800
From:   Ren Yu <renyu@...china.com>
To:     keescook@...omium.org, arnd@...db.de, gregkh@...uxfoundation.org,
        linux-kernel@...r.kernel.org
Cc:     liqiong@...china.com, yuzhe@...china.com,
        Ren Yu <renyu@...china.com>
Subject: [PATCH 2/3] lkdtm/perms: Check possible NULL pointer returned by kmalloc(),vmalloc()

As the possible alloc failure of the kmalloc() and vmalloc(),the
return pointer could be NULL.therefore it should be better to check it.

Signed-off-by: Ren Yu <renyu@...china.com>
---
 drivers/misc/lkdtm/perms.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/misc/lkdtm/perms.c b/drivers/misc/lkdtm/perms.c
index b93404d65650..34b43b9ea1f1 100644
--- a/drivers/misc/lkdtm/perms.c
+++ b/drivers/misc/lkdtm/perms.c
@@ -180,6 +180,9 @@ static void lkdtm_EXEC_STACK(void)
 static void lkdtm_EXEC_KMALLOC(void)
 {
 	u32 *kmalloc_area = kmalloc(EXEC_SIZE, GFP_KERNEL);
+	if (!kmalloc_area)
+		return;
+
 	execute_location(kmalloc_area, CODE_WRITE);
 	kfree(kmalloc_area);
 }
@@ -187,6 +190,9 @@ static void lkdtm_EXEC_KMALLOC(void)
 static void lkdtm_EXEC_VMALLOC(void)
 {
 	u32 *vmalloc_area = vmalloc(EXEC_SIZE);
+	if (!vmalloc_area)
+		return;
+
 	execute_location(vmalloc_area, CODE_WRITE);
 	vfree(vmalloc_area);
 }
-- 
2.11.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ