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: <20180706114216.GA31180@wintermute>
Date:   Fri, 6 Jul 2018 13:42:16 +0200
From:   Jan Glauber <jglauber@...ium.com>
To:     Kees Cook <keescook@...omium.org>
Cc:     Borislav Petkov <bp@...en8.de>,
        Mauro Carvalho Chehab <mchehab@...nel.org>,
        linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] EDAC, thunderx: Remove VLA usage

On Fri, Jun 29, 2018 at 11:48:50AM -0700, Kees Cook wrote:
> In the quest to remove all stack VLA usage from the kernel[1], this
> switches to using a kmalloc-allocated buffer instead of stack space.
> This should be fine since the existing routine is allocating memory
> too.
> 
> [1] https://lkml.kernel.org/r/CA+55aFzCG-zNmZwX4A2FQpadafLfEzK6CC=qPXydAacU1RqZWA@mail.gmail.com
> 
> Cc: David Daney <david.daney@...ium.com>
> Cc: Jan Glauber <jglauber@...ium.com>
> Cc: Borislav Petkov <bp@...en8.de>
> Cc: Mauro Carvalho Chehab <mchehab@...nel.org>
> Cc: linux-edac@...r.kernel.org
> Signed-off-by: Kees Cook <keescook@...omium.org>

Acked-by: Jan Glauber <jglauber@...ium.com>

thanks,
Jan

> ---
>  drivers/edac/thunderx_edac.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/edac/thunderx_edac.c b/drivers/edac/thunderx_edac.c
> index 4803c6468bab..c009d94f40c5 100644
> --- a/drivers/edac/thunderx_edac.c
> +++ b/drivers/edac/thunderx_edac.c
> @@ -408,26 +408,29 @@ static ssize_t thunderx_lmc_inject_ecc_write(struct file *file,
>  					     size_t count, loff_t *ppos)
>  {
>  	struct thunderx_lmc *lmc = file->private_data;
> -
>  	unsigned int cline_size = cache_line_size();
> -
> -	u8 tmp[cline_size];
> +	u8 *tmp;
>  	void __iomem *addr;
>  	unsigned int offs, timeout = 100000;
>  
>  	atomic_set(&lmc->ecc_int, 0);
>  
>  	lmc->mem = alloc_pages_node(lmc->node, GFP_KERNEL, 0);
> -
>  	if (!lmc->mem)
>  		return -ENOMEM;
>  
> +	tmp = kmalloc(cline_size, GFP_KERNEL);
> +	if (!tmp) {
> +		__free_pages(lmc->mem, 0);
> +		return -ENOMEM;
> +	}
> +
>  	addr = page_address(lmc->mem);
>  
>  	while (!atomic_read(&lmc->ecc_int) && timeout--) {
>  		stop_machine(inject_ecc_fn, lmc, NULL);
>  
> -		for (offs = 0; offs < PAGE_SIZE; offs += sizeof(tmp)) {
> +		for (offs = 0; offs < PAGE_SIZE; offs += cline_size) {
>  			/*
>  			 * Do a load from the previously rigged location
>  			 * This should generate an error interrupt.
> @@ -437,6 +440,7 @@ static ssize_t thunderx_lmc_inject_ecc_write(struct file *file,
>  		}
>  	}
>  
> +	kfree(tmp);
>  	__free_pages(lmc->mem, 0);
>  
>  	return count;
> -- 
> 2.17.1
> 
> 
> -- 
> Kees Cook
> Pixel Security

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ