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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5jJ2dM0X=ZYOL_Qwt4jr8Bh-LuQb1UkutecObGX00rzmHg@mail.gmail.com>
Date:   Mon, 27 Nov 2017 08:04:05 -0800
From:   Kees Cook <keescook@...omium.org>
To:     Vasyl Gomonovych <gomonovych@...il.com>,
        Greg KH <gregkh@...uxfoundation.org>
Cc:     Arnd Bergmann <arnd@...db.de>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] lkdtm: Missing kmalloc check

On Thu, Nov 23, 2017 at 8:00 AM, Vasyl Gomonovych <gomonovych@...il.com> wrote:
> Handling a possible memory allocation failure.
>
> Signed-off-by: Vasyl Gomonovych <gomonovych@...il.com>

Acked-by: Kees Cook <keescook@...omium.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ