[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 20/21] xenvif: Check the statistic name in frontend


  • To: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>, "win-pv-devel@xxxxxxxxxxxxxxxxxxxx" <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Mon, 12 Oct 2026 12:14:02 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=YWXlNkkG9v18nKvsD277BIUw8zgHaWhW+YaPfpyHM8o=; b=JtajcCK/Udxw5oRU9iHgHRZPfX8w9Ys4x8rjyqPYYe8CTo+Y43m9EpZ8bgYG3caBHdrkXh8kgdTcjZK24qKY31+ONOSHozaIcgqYar5dTFjzsHlwowDmSnY7Wh/bTbCt+kUA7UMZUloxs13k+FEXW/HGtXNXraollb6xmyWooOi5HIEN1p0tPBVqeMQUovDxgVqXURyLFWyeeTJXkQVRW0IYNiKLmsPjDFvy6AYz3iWkr4LZJMgROE9o2xFeNgSks8XbyupDTcfxL4NoLz2UCML2Yk/eeFMfPw5OYOFuARInmc7UUFdg1tMPn4blhbMA3XlFJsTdzRvojSSFGpDGaA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=RFTXMDK7ubhJovtA6mbMArRCTGAejpXc6vNj/MKN0mr8IcJGCz/4YJJQANW2bcmEHILe7xATBstLbsqE8tp7Ol4Jl7r/SkUneIGpX1Z0lUXRoQSI5GebpCaPfzRJPy9iRQXUbb5Zmr5pLt2U3iXtzd2QxgvzrtyAmuaCyIZeDl6A1mRNHA1YiCFDckj7yPmaXOM1JN2i5Pi6K6Nv+tTCGCw9wFO47e7idktefK0PVhRkAMJlEo9oJmnPwBDpkv4v7Ww47g3AMMWA/fpPjFTWY0MhlyR0ABBn6sZK3k6AiUHVOpK+yVbzoiaxnfp3xY5k0LOxG1fEkHIFKEuOnFfivg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=citrix.com header.i="@citrix.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Delivery-date: Mon, 12 Oct 2026 12:14:09 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>
  • Msip_labels:
  • Thread-index: AQHdWjPRSGxRzJFFf06oQ8kYqWnWvLb5zXYW
  • Thread-topic: [PATCH 20/21] xenvif: Check the statistic name in frontend

This change isnt strictly necessary - the only callers of 
__FrontendQueryStatistic
are the debug callback, which loops over all values of XENVIF_VIF_STATISTIC_*
and VifQueryStatistic, which already validates the statistic index is within
range (an additional check in the Query path is negligible difference)

I do get warnings where Name is cast to a ULONG
xenvif\src\xenvif\frontend.c(1811): warning C33010: Unchecked lower bound for 
enum Name used as index
xenvif\src\xenvif\frontend.c(1845): warning C33010: Unchecked lower bound for 
enum Name used as index

I'll post a follow up patch to resolve this

Owen

________________________________________
From: win-pv-devel <win-pv-devel-bounces@xxxxxxxxxxxxxxxxxxxx> on behalf of 
Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
Sent: 12 October 2026 11:23 AM
To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
Cc: Césaire Mounah
Subject: [PATCH 20/21] xenvif: Check the statistic name in frontend

CodeAnalysis raised a warning on this condition.
Name comes from the VIF interface caller and was only checked with an
ASSERT, so a release build could read past the end of the statistics
array. Return early when the name is out of range.

Signed-off-by: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
---
 src/xenvif/frontend.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/xenvif/frontend.c b/src/xenvif/frontend.c
index a35ed78..4b4e69f 100644
--- a/src/xenvif/frontend.c
+++ b/src/xenvif/frontend.c
@@ -1800,6 +1800,10 @@ __FrontendQueryStatistic(
     ASSERT3U(Name, <, XENVIF_VIF_STATISTIC_COUNT);

     *Value = 0;
+
+    if (Name >= XENVIF_VIF_STATISTIC_COUNT)
+        return;
+
     for (Index = 0; Index < Frontend->StatisticsCount; Index++) {
         PXENVIF_FRONTEND_STATISTICS Statistics;

--
2.55.0.windows.5



--
Césaire Mounah | Vates Windows Guest Tools Engineer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.