* [PATCH] lkdtm: perms: Increase pointer assignment check
@ 2023-02-17 18:58 Li zeming
0 siblings, 0 replies; only message in thread
From: Li zeming @ 2023-02-17 18:58 UTC (permalink / raw)
To: keescook, arnd, gregkh; +Cc: linux-kernel, Li zeming
Increase the check after the pointer allocates memory. If these two
functions are used, at least increase some robustness.
Signed-off-by: Li zeming <zeming@nfschina.com>
---
drivers/misc/lkdtm/perms.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/misc/lkdtm/perms.c b/drivers/misc/lkdtm/perms.c
index b93404d65650..a5d8dce5ce49 100644
--- a/drivers/misc/lkdtm/perms.c
+++ b/drivers/misc/lkdtm/perms.c
@@ -180,15 +180,19 @@ static void lkdtm_EXEC_STACK(void)
static void lkdtm_EXEC_KMALLOC(void)
{
u32 *kmalloc_area = kmalloc(EXEC_SIZE, GFP_KERNEL);
- execute_location(kmalloc_area, CODE_WRITE);
- kfree(kmalloc_area);
+ if (kmalloc_area) {
+ execute_location(kmalloc_area, CODE_WRITE);
+ kfree(kmalloc_area);
+ }
}
static void lkdtm_EXEC_VMALLOC(void)
{
u32 *vmalloc_area = vmalloc(EXEC_SIZE);
- execute_location(vmalloc_area, CODE_WRITE);
- vfree(vmalloc_area);
+ if (vmalloc_area) {
+ execute_location(vmalloc_area, CODE_WRITE);
+ vfree(vmalloc_area);
+ }
}
static void lkdtm_EXEC_RODATA(void)
--
2.18.2
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-16 2:26 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-17 18:58 [PATCH] lkdtm: perms: Increase pointer assignment check Li zeming
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®