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]
Message-ID: <7ymkjjcssj3c5pd43rnswly6nyozmvukcw5kaxzmjpul4trwtz@pksjoiaemiq7>
Date: Wed, 21 May 2025 10:39:36 -0400
From: Kent Overstreet <kent.overstreet@...ux.dev>
To: Ye Chey <yechey@...sast.com>
Cc: linux-bcachefs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] bcachefs: fix potential NULL pointer dereference in
 bch2_bkey_buf_realloc

On Wed, May 21, 2025 at 10:30:33PM +0800, Ye Chey wrote:
> Add error checking for mempool_alloc return value to avoid potential NULL
> pointer dereference when memory allocation fails.

I suggest you go learn how mempools work and what they're for.


> Signed-off-by: Ye Chey <yechey@...sast.com>
> ---
>  fs/bcachefs/bkey_buf.h | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/bcachefs/bkey_buf.h b/fs/bcachefs/bkey_buf.h
> index a30c4ae8e..8272a1830 100644
> --- a/fs/bcachefs/bkey_buf.h
> +++ b/fs/bcachefs/bkey_buf.h
> @@ -16,6 +16,8 @@ static inline void bch2_bkey_buf_realloc(struct bkey_buf *s,
>  	if (s->k == (void *) s->onstack &&
>  	    u64s > ARRAY_SIZE(s->onstack)) {
>  		s->k = mempool_alloc(&c->large_bkey_pool, GFP_NOFS);
> +		if (!s->k)
> +			return;
>  		memcpy(s->k, s->onstack, sizeof(s->onstack));
>  	}
>  }
> -- 
> 2.44.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ