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:   Mon, 20 May 2019 09:30:06 -0700
From:   Kees Cook <keescook@...omium.org>
To:     Pi-Hsun Shih <pihsun@...omium.org>
Cc:     Anton Vorontsov <anton@...msg.org>,
        Colin Cross <ccross@...roid.com>,
        Tony Luck <tony.luck@...el.com>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] pstore: Set tfm to NULL on free_buf_for_compression.

On Mon, May 20, 2019 at 02:51:19PM +0800, Pi-Hsun Shih wrote:
> Set tfm to NULL on free_buf_for_compression after crypto_free_comp.
> 
> This avoid a use-after-free when allocate_buf_for_compression and
> free_buf_for_compression are called twice. Although
> free_buf_for_compression freed the tfm, allocate_buf_for_compression
> won't reinitialize the tfm since the tfm pointer is not NULL.
> 
> Fixes: 95047b0519c1 ("pstore: Refactor compression initialization")
> Signed-off-by: Pi-Hsun Shih <pihsun@...omium.org>

Thank you! Yes, without this, reloading pstore backend modules would
cause bad behavior. :)

Applied; will send to Linus shortly.

-Kees

> ---
>  fs/pstore/platform.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
> index 75887a269b64..8355a46638d0 100644
> --- a/fs/pstore/platform.c
> +++ b/fs/pstore/platform.c
> @@ -347,8 +347,10 @@ static void allocate_buf_for_compression(void)
>  
>  static void free_buf_for_compression(void)
>  {
> -	if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm)
> +	if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm) {
>  		crypto_free_comp(tfm);
> +		tfm = NULL;
> +	}
>  	kfree(big_oops_buf);
>  	big_oops_buf = NULL;
>  	big_oops_buf_sz = 0;
> -- 
> 2.21.0.1020.gf2820cf01a-goog
> 

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ