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: <1e5dcc30-47b1-45c7-8cbe-0c72d07b88ed@trager.us>
Date: Fri, 7 Mar 2025 14:59:13 -0800
From: Lee Trager <lee@...ger.us>
To: Dan Carpenter <dan.carpenter@...aro.org>
Cc: Alexander Duyck <alexanderduyck@...com>, Jakub Kicinski
 <kuba@...nel.org>, kernel-team@...a.com, Andrew Lunn
 <andrew+netdev@...n.ch>, "David S. Miller" <davem@...emloft.net>,
 Eric Dumazet <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>,
 netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
 kernel-janitors@...r.kernel.org
Subject: Re: [PATCH net-next] eth: fbnic: fix memory corruption in
 fbnic_tlv_attr_get_string()

On 3/7/25 1:28 AM, Dan Carpenter wrote:

> This code is trying to ensure that the last byte of the buffer is a NUL
> terminator.  However, the problem is that attr->value[] is an array of
> __le32, not char, so it zeroes out 4 bytes way beyond the end of the
> buffer.  Cast the buffer to char to address this.
>
> Fixes: e5cf5107c9e4 ("eth: fbnic: Update fbnic_tlv_attr_get_string() to work like nla_strscpy()")
> Signed-off-by: Dan Carpenter <dan.carpenter@...aro.org>
> ---
>   drivers/net/ethernet/meta/fbnic/fbnic_tlv.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c b/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c
> index d558d176e0df..517ed8b2f1cb 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_tlv.c
> @@ -261,7 +261,7 @@ ssize_t fbnic_tlv_attr_get_string(struct fbnic_tlv_msg *attr, char *dst,
>   		return -E2BIG;
>   
>   	srclen = le16_to_cpu(attr->hdr.len) - sizeof(*attr);
> -	if (srclen > 0 && attr->value[srclen - 1] == '\0')
> +	if (srclen > 0 && ((char *)attr->value)[srclen - 1] == '\0')
>   		srclen--;
>   
>   	if (srclen >= dstsize) {

Thanks for catching that. While I didn't see any negative effect without 
it I have verified on hardware this patch works.

Reviewed-by: Lee Trager <lee@...ger.us>



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ