* [PATCH] lkdtm: Missing kmalloc check
@ 2017-11-23 16:00 Vasyl Gomonovych
2017-11-27 16:04 ` Kees Cook
0 siblings, 1 reply; 3+ messages in thread
From: Vasyl Gomonovych @ 2017-11-23 16:00 UTC (permalink / raw)
To: keescook, arnd, gregkh; +Cc: linux-kernel, gomonovych
Handling a possible memory allocation failure.
Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
---
drivers/misc/lkdtm_heap.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/misc/lkdtm_heap.c b/drivers/misc/lkdtm_heap.c
index f5494a6d4be5..65026d7de130 100644
--- a/drivers/misc/lkdtm_heap.c
+++ b/drivers/misc/lkdtm_heap.c
@@ -16,6 +16,8 @@ void lkdtm_OVERWRITE_ALLOCATION(void)
{
size_t len = 1020;
u32 *data = kmalloc(len, GFP_KERNEL);
+ if (!data)
+ return;
data[1024 / sizeof(u32)] = 0x12345678;
kfree(data);
@@ -33,6 +35,8 @@ void lkdtm_WRITE_AFTER_FREE(void)
size_t offset = (len / sizeof(*base)) / 2;
base = kmalloc(len, GFP_KERNEL);
+ if (!base)
+ return;
pr_info("Allocated memory %p-%p\n", base, &base[offset * 2]);
pr_info("Attempting bad write to freed memory at %p\n",
&base[offset]);
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] lkdtm: Missing kmalloc check
2017-11-23 16:00 [PATCH] lkdtm: Missing kmalloc check Vasyl Gomonovych
@ 2017-11-27 16:04 ` Kees Cook
2017-11-27 16:08 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Kees Cook @ 2017-11-27 16:04 UTC (permalink / raw)
To: Vasyl Gomonovych, Greg KH; +Cc: Arnd Bergmann, LKML
On Thu, Nov 23, 2017 at 8:00 AM, Vasyl Gomonovych <gomonovych@gmail.com> wrote:
> Handling a possible memory allocation failure.
>
> Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Acked-by: Kees Cook <keescook@chromium.org>
Greg, can you please take this?
-Kees
> ---
> drivers/misc/lkdtm_heap.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/misc/lkdtm_heap.c b/drivers/misc/lkdtm_heap.c
> index f5494a6d4be5..65026d7de130 100644
> --- a/drivers/misc/lkdtm_heap.c
> +++ b/drivers/misc/lkdtm_heap.c
> @@ -16,6 +16,8 @@ void lkdtm_OVERWRITE_ALLOCATION(void)
> {
> size_t len = 1020;
> u32 *data = kmalloc(len, GFP_KERNEL);
> + if (!data)
> + return;
>
> data[1024 / sizeof(u32)] = 0x12345678;
> kfree(data);
> @@ -33,6 +35,8 @@ void lkdtm_WRITE_AFTER_FREE(void)
> size_t offset = (len / sizeof(*base)) / 2;
>
> base = kmalloc(len, GFP_KERNEL);
> + if (!base)
> + return;
> pr_info("Allocated memory %p-%p\n", base, &base[offset * 2]);
> pr_info("Attempting bad write to freed memory at %p\n",
> &base[offset]);
> --
> 1.9.1
>
--
Kees Cook
Pixel Security
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] lkdtm: Missing kmalloc check
2017-11-27 16:04 ` Kees Cook
@ 2017-11-27 16:08 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2017-11-27 16:08 UTC (permalink / raw)
To: Kees Cook; +Cc: Vasyl Gomonovych, Arnd Bergmann, LKML
On Mon, Nov 27, 2017 at 08:04:05AM -0800, Kees Cook wrote:
> On Thu, Nov 23, 2017 at 8:00 AM, Vasyl Gomonovych <gomonovych@gmail.com> wrote:
> > Handling a possible memory allocation failure.
> >
> > Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
>
> Acked-by: Kees Cook <keescook@chromium.org>
>
> Greg, can you please take this?
Will do, thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-27 16:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-23 16:00 [PATCH] lkdtm: Missing kmalloc check Vasyl Gomonovych
2017-11-27 16:04 ` Kees Cook
2017-11-27 16:08 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.