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

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


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Date: Mon, 12 Oct 2026 12:23:32 +0200
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID"
  • Cc: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
  • Delivery-date: Mon, 12 Oct 2026 10:23:59 +0000
  • Feedback-id: default:8631fc262581453bbf619ec5b2062170:Sweego
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

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®.