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: <0927ebf9-db17-49f5-a188-e0d486ae4bda@linux.microsoft.com>
Date: Thu, 16 Jan 2025 13:39:52 -0800
From: Roman Kisel <romank@...ux.microsoft.com>
To: Thorsten Blum <thorsten.blum@...ux.dev>,
 "K. Y. Srinivasan" <kys@...rosoft.com>,
 Haiyang Zhang <haiyangz@...rosoft.com>, Wei Liu <wei.liu@...nel.org>,
 Dexuan Cui <decui@...rosoft.com>, Andrew Lunn <andrew+netdev@...n.ch>,
 "David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
 Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>
Cc: linux-hardening@...r.kernel.org, linux-hyperv@...r.kernel.org,
 netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] hv_netvsc: Replace one-element array with flexible
 array member



On 1/16/2025 1:19 PM, Thorsten Blum wrote:
> Replace the deprecated one-element array with a modern flexible array
> member in the struct nvsp_1_message_send_receive_buffer_complete.
> 
> Use struct_size_t(,,1) instead of sizeof() to maintain the same size.

Thanks!

> 
> Compile-tested only.

The code change looks good to me now. I'll build a VM with this change
to clear my conscience (maybe the change triggers a compiler bug,
however unlikely that sounds) before replying with any tags. Likely next
Monday, but feel free to beat me to it, or perhaps, someone else will
tag this as reviewed by them and/or tested by them.

> 
> Link: https://github.com/KSPP/linux/issues/79
> Signed-off-by: Thorsten Blum <thorsten.blum@...ux.dev>
> ---
> Changes in v2:
> - Replace sizeof() with struct_size_t(,,1) to maintain the same size
>    after feedback from Roman Kisel (thanks!)
> - Link to v1: https://lore.kernel.org/r/20250116201635.47870-2-thorsten.blum@linux.dev/
> ---
>   drivers/net/hyperv/hyperv_net.h | 2 +-
>   drivers/net/hyperv/netvsc.c     | 3 ++-
>   2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
> index e690b95b1bbb..234db693cefa 100644
> --- a/drivers/net/hyperv/hyperv_net.h
> +++ b/drivers/net/hyperv/hyperv_net.h
> @@ -464,7 +464,7 @@ struct nvsp_1_message_send_receive_buffer_complete {
>   	 *  LargeOffset                            SmallOffset
>   	 */
>   
> -	struct nvsp_1_receive_buffer_section sections[1];
> +	struct nvsp_1_receive_buffer_section sections[];
>   } __packed;
>   
>   /*
> diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
> index 9afb08dbc350..d6f5b9ea3109 100644
> --- a/drivers/net/hyperv/netvsc.c
> +++ b/drivers/net/hyperv/netvsc.c
> @@ -866,7 +866,8 @@ static void netvsc_send_completion(struct net_device *ndev,
>   
>   	case NVSP_MSG1_TYPE_SEND_RECV_BUF_COMPLETE:
>   		if (msglen < sizeof(struct nvsp_message_header) +
> -				sizeof(struct nvsp_1_message_send_receive_buffer_complete)) {
> +				struct_size_t(struct nvsp_1_message_send_receive_buffer_complete,
> +					      sections, 1)) {
>   			netdev_err(ndev, "nvsp_msg1 length too small: %u\n",
>   				   msglen);
>   			return;

-- 
Thank you,
Roman


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ