From nobody Sat Feb 7 21:08:18 2026 Received: from out-182.mta0.migadu.com (out-182.mta0.migadu.com [91.218.175.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6AB91D54E9 for ; Thu, 16 Jan 2025 21:21:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737062466; cv=none; b=mgo4z/YTHsWAqIY4im1w1OpdID11y3kT3c5PvdmGADCoLtM70HNXREeyrlbF56zBIs0cjBFAhdMr2sWJAzN2wP7IuyMIw4NX8syUyCbAN98VFoLLjz+Aj7IXHNrEjo++kRZdFCxS0hiTkbKXq4MOC9pn1ziqwwMxT4AcPOzd36E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737062466; c=relaxed/simple; bh=MjLB8cGPzHtA3JKM+gbMrilrolSPKow+VzxyU+G4jko=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=IH8fQ3l2Dys6k9U0yrE6oKkmCwQSr7GOrk4A4xnE1ZQD1LDWLrPkXzoHq7ZIGplJiWjp2H1rTfJyL49HZgfc/klRK3hYsCc9tKJn4yihteckeNwb1DeQiQT82qFckp7VTe3kTmGlQwdRPbR+Am0JE5ESqb1hQEPdjLUtl1UuMRo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=PnHTtpth; arc=none smtp.client-ip=91.218.175.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="PnHTtpth" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1737062446; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=2Syu9PoY8qUbezBkyLynlw3MObrHBcpVaz9Wa9zY10Q=; b=PnHTtpthJIwc1z9MljiV1oUxKhACxW70+pfWhahgBpTN8qBaJy4W7uXZHIPbNZSTlxbJko gB/A2PGO6mxxtviZ4B72ZbiquVCNSF4c1+LoXobKOEOdGTPAYPbNbZs+D9GbYQW7gz81Ww +YTqKbFAAufys3rJac5s7S2yF0DcNaw= From: Thorsten Blum To: "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: linux-hardening@vger.kernel.org, Roman Kisel , Thorsten Blum , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] hv_netvsc: Replace one-element array with flexible array member Date: Thu, 16 Jan 2025 22:19:32 +0100 Message-ID: <20250116211932.139564-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" 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. Compile-tested only. Link: https://github.com/KSPP/linux/issues/79 Signed-off-by: Thorsten Blum Reviewed-by: Roman Kisel Tested-by: Roman Kisel --- 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.blu= m@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_ne= t.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 */ =20 - struct nvsp_1_receive_buffer_section sections[1]; + struct nvsp_1_receive_buffer_section sections[]; } __packed; =20 /* 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 *n= dev, =20 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; --=20 2.48.0