|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [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
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |