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

[win-pv-devel] [PATCH] Dont include null terminator in synthesized VendorId identifier



From: Owen Smith <owen.smith@xxxxxxxxxx>

The VendorId identifier on SCSI page 83 is 16 bytes long (+header)
When synthesizing the inquiry data, either by global flag, or missing
xenstore data (sm-data/scsi/0x12/0x83), the NULL terminator on the
VendorId should not be included in the field. When this happens, any
query will decode 3 identifiers (VendorId, EUI64, VendorSpecific)
instead of the intended 2 (VendorId, VendorSpecific).
This breaks the XenServer VSS provider that uses the VendorSpecific
identifier to retrieve the vdi-uuid. This is only an issue when the inquiry
data is synthesized and additional identifiers are required, which is not
a common use case.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenvbd/pdoinquiry.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/xenvbd/pdoinquiry.c b/src/xenvbd/pdoinquiry.c
index be7dd84..4460f3d 100644
--- a/src/xenvbd/pdoinquiry.c
+++ b/src/xenvbd/pdoinquiry.c
@@ -42,7 +42,7 @@
 #define GUID_LENGTH     36 
 
 // 00 00 00 00 00 00 00 00 "XENSRC  00000000"
-#define PAGE83_MIN_SIZE (4 + 4 + 16 + 1)
+#define PAGE83_MIN_SIZE (4 + 4 + 16)
 
 // 00 00 00 00 + GUID_LENGTH
 #define VDI_ID_LENGTH   (4 + GUID_LENGTH)
@@ -331,13 +331,14 @@ __HandlePage83(
     PCHAR   Data = (PCHAR)Srb->DataBuffer;
     ULONG   Length = Srb->DataTransferLength;
 
-       RtlZeroMemory(Data, Length);
-       if (DriverParameters.SynthesizeInquiry ||
+    RtlZeroMemory(Data, Length);
+    if (DriverParameters.SynthesizeInquiry ||
         Inquiry == NULL || 
         Inquiry->Page83.Data == NULL || 
         Inquiry->Page83.Length == 0) {
         // generate the id page data
         PVPD_IDENTIFICATION_DESCRIPTOR  Id;
+        CHAR    Buffer[17];
 
         if (Length < PAGE83_MIN_SIZE)
             return FALSE;
@@ -349,7 +350,8 @@ __HandlePage83(
         Id->CodeSet             = VpdCodeSetAscii;
         Id->IdentifierType      = VpdIdentifierTypeVendorId;
         Id->IdentifierLength    = 16;
-        (VOID) RtlStringCchPrintfA((PCHAR)Id->Identifier, 17, "XENSRC  %08u", 
TargetId);
+        (VOID)RtlStringCchPrintfA(Buffer, 17, "XENSRC  %08u", TargetId);
+        RtlCopyMemory((PCHAR)Id->Identifier, Buffer, 16);
 
         Verbose("Target[%u] : INQUIRY Using Fake Page83 Data\n", TargetId);
 
-- 
2.8.3


_______________________________________________
win-pv-devel mailing list
win-pv-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/cgi-bin/mailman/listinfo/win-pv-devel

 


Rackspace

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