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]
Date:   Sat, 7 Oct 2023 11:22:41 +0100
From:   Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
To:     Loic Poulain <loic.poulain@...aro.org>
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH] nvmem: core: Fix possible buffer overflow on nvmem cell
 write

Thanks Loic for the patch,

On 03/10/2023 14:13, Loic Poulain wrote:
> Nothing prevents a nvmem consumer to try writing excessive data to a
> given nvmem cell (except when bit_offset is 0). The allocated buffer
> of size 'cell->bytes' in nvmem_cell_prepare_write_buffer may not be
> large enough to host the copied 'len' bytes.
> 
Did you hit this path?

  __nvmem_cell_entry_write already has a check for (cell->bit_offset == 
0 && len != cell->bytes))

What is the bit_offset in your case?

Can you provide more details?

thanks,
srini

> Signed-off-by: Loic Poulain <loic.poulain@...aro.org>
> ---
>   drivers/nvmem/core.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
> index eaf6a3fe8ca6..0b27ab3b3b86 100644
> --- a/drivers/nvmem/core.c
> +++ b/drivers/nvmem/core.c
> @@ -1654,6 +1654,9 @@ static void *nvmem_cell_prepare_write_buffer(struct nvmem_cell_entry *cell,
>   	int i, rc, nbits, bit_offset = cell->bit_offset;
>   	u8 v, *p, *buf, *b, pbyte, pbits;
>   
> +	if (len > cell->bytes)
> +		return ERR_PTR(-EINVAL);
> +
>   	nbits = cell->nbits;
>   	buf = kzalloc(cell->bytes, GFP_KERNEL);
>   	if (!buf)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ