lkml.org 
[lkml]   [2021]   [Dec]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] lkdtm: potential dereference of null pointer
Date
The return value of kmalloc() needs to be checked.
To avoid use in execute_location() in case of the failure of alloc.

Fixes: 039a1c42058d ("lkdtm: Relocate code to subdirectory")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
drivers/misc/lkdtm/perms.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/misc/lkdtm/perms.c b/drivers/misc/lkdtm/perms.c
index 2dede2ef658f..ef87d9cc2e96 100644
--- a/drivers/misc/lkdtm/perms.c
+++ b/drivers/misc/lkdtm/perms.c
@@ -138,6 +138,8 @@ void lkdtm_EXEC_STACK(void)
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);
}
@@ -145,6 +147,8 @@ void lkdtm_EXEC_KMALLOC(void)
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.25.1
\
 
 \ /
  Last update: 2021-12-16 03:01    [W:0.042 / U:1.876 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site