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] [day] [month] [year] [list]
Date:   Wed, 24 Apr 2019 13:24:07 +0100
From:   Mark Rutland <mark.rutland@....com>
To:     Weikang shi <swkhack@...il.com>
Cc:     keescook@...omium.org, arnd@...db.de, gregkh@...uxfoundation.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lkdtm: fix potential use after free

Hi,

On Wed, Apr 24, 2019 at 05:59:52PM +0800, Weikang shi wrote:
> From: swkhack <swkhack@...il.com>
> 
> The function lkdtm_READ_AFTER_FREE calls kfree(base) to free the memory
> of base. However, following kfree(base),
> it access the memory which base point to via base[offset]. This may result in a
> use-after-free bug. 

This is deliberate; the test is designed to provoke a use-after-free to
verify that this can be detected by tools such as KASAN.

> This patch moves kfree(base) after the dereference.

Doing this would break the test, so we should not make this change.

Was this something you spotted with a static analysis tool?

> Signed-off-by: swkhack <swkhack@...il.com>

A signed-off-by line should have your real name rather than an alias.

Thanks,
Mark.

> ---
>  drivers/misc/lkdtm/heap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/lkdtm/heap.c b/drivers/misc/lkdtm/heap.c
> index 65026d7de..3e2f1580a 100644
> --- a/drivers/misc/lkdtm/heap.c
> +++ b/drivers/misc/lkdtm/heap.c
> @@ -77,7 +77,6 @@ void lkdtm_READ_AFTER_FREE(void)
>  	base[offset] = *val;
>  	pr_info("Value in memory before free: %x\n", base[offset]);
>  
> -	kfree(base);
>  
>  	pr_info("Attempting bad read from freed memory\n");
>  	saw = base[offset];
> @@ -88,6 +87,7 @@ void lkdtm_READ_AFTER_FREE(void)
>  	}
>  	pr_info("Memory was not poisoned\n");
>  
> +	kfree(base);
>  	kfree(val);
>  }
>  
> -- 
> 2.17.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ