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: <e4246b25-628e-de5e-56ba-8d45ad9c9fa6@arm.com>
Date:   Thu, 14 Feb 2019 13:51:51 +0000
From:   Steven Price <steven.price@....com>
To:     Christoph Hellwig <hch@....de>,
        Andrew Morton <akpm@...ux-foundation.org>
Cc:     linux-arch@...r.kernel.org,
        Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will.deacon@....com>,
        Russell King <linux@...linux.org.uk>,
        linux-kernel@...r.kernel.org, linux-mm@...ck.org,
        Alexander Viro <viro@...iv.linux.org.uk>,
        Guan Xuetao <gxt@....edu.cn>,
        linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH 2/8] initramfs: free initrd memory if opening
 /initrd.image fails

On 13/02/2019 17:46, Christoph Hellwig wrote:
> We free the initrd memory for all successful or error cases except
> for the case where opening /initrd.image fails, which looks like an
> oversight.

This also changes the behaviour when CONFIG_INITRAMFS_FORCE is enabled -
specifically it means that the initrd is freed (previously it was
ignored and never freed). But that seems like reasonable behaviour and
the previous behaviour looks like another oversight. FWIW:

Reviewed-by: Steven Price <steven.price@....com>

> Signed-off-by: Christoph Hellwig <hch@....de>
> ---
>  init/initramfs.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/init/initramfs.c b/init/initramfs.c
> index 7cea802d00ef..1cba6bbeeb75 100644
> --- a/init/initramfs.c
> +++ b/init/initramfs.c
> @@ -610,13 +610,12 @@ static int __init populate_rootfs(void)
>  		printk(KERN_INFO "Trying to unpack rootfs image as initramfs...\n");
>  		err = unpack_to_rootfs((char *)initrd_start,
>  			initrd_end - initrd_start);
> -		if (!err) {
> -			free_initrd();
> +		if (!err)
>  			goto done;
> -		} else {
> -			clean_rootfs();
> -			unpack_to_rootfs(__initramfs_start, __initramfs_size);
> -		}
> +
> +		clean_rootfs();
> +		unpack_to_rootfs(__initramfs_start, __initramfs_size);
> +
>  		printk(KERN_INFO "rootfs image is not initramfs (%s)"
>  				"; looks like an initrd\n", err);
>  		fd = ksys_open("/initrd.image",
> @@ -630,7 +629,6 @@ static int __init populate_rootfs(void)
>  				       written, initrd_end - initrd_start);
>  
>  			ksys_close(fd);
> -			free_initrd();
>  		}
>  	done:
>  		/* empty statement */;
> @@ -642,9 +640,9 @@ static int __init populate_rootfs(void)
>  			printk(KERN_EMERG "Initramfs unpacking failed: %s\n", err);
>  			clean_rootfs();
>  		}
> -		free_initrd();
>  #endif
>  	}
> +	free_initrd();
>  	flush_delayed_fput();
>  	return 0;
>  }
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ