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

[PATCH 01/10] xeniface: fix NULL KernelVa dereference in GnttabFreeGrant notify


  • To: win-pv-devel@xxxxxxxxxxxxxxxxxxxx
  • From: david ambu <david.preetham@xxxxxxxxxx>
  • Date: Thu, 8 Oct 2026 13:01:53 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=citrix.com header.i="@citrix.com" header.h="Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From"
  • Cc: david ambu <david.preetham@xxxxxxxxxx>
  • Delivery-date: Thu, 08 Oct 2026 12:05:18 +0000
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

For V2 grants with user-supplied memory, KernelVa is NULL.
Fall back to UserVa for the notify offset write in that case.

Signed-off-by: david ambu <david.preetham@xxxxxxxxxx>
Assisted by Claude Sonnet 4.6
---
 src/xeniface/ioctl_gnttab.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/xeniface/ioctl_gnttab.c b/src/xeniface/ioctl_gnttab.c
index 770f0dc..35767a2 100644
--- a/src/xeniface/ioctl_gnttab.c
+++ b/src/xeniface/ioctl_gnttab.c
@@ -482,7 +482,17 @@ GnttabFreeGrant(
     ASSERT(KeGetCurrentIrql() <= APC_LEVEL);
 
     if (Context->Flags & XENIFACE_GNTTAB_USE_NOTIFY_OFFSET) {
-        ((PCHAR)Context->KernelVa)[Context->NotifyOffset] = 0;
+        if (Context->KernelVa != NULL) {
+            ((PCHAR)Context->KernelVa)[Context->NotifyOffset] = 0;
+        } else {
+#pragma prefast(suppress:6320)
+            try {
+                ((PCHAR)Context->UserVa)[Context->NotifyOffset] = 0;
+            } except(EXCEPTION_EXECUTE_HANDLER) {
+                Error("Failed to write notify offset 0x%x: 0x%x\n",
+                      Context->NotifyOffset, GetExceptionCode());
+            }
+        }
     }
 
     if (Context->Flags & XENIFACE_GNTTAB_USE_NOTIFY_PORT) {
-- 
2.51.0.windows.1




 


Rackspace

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