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

[PATCH] Avoid EINVAL from XenStore


  • To: <win-pv-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Owen Smith <owen.smith@xxxxxxxxxx>
  • Date: Tue, 5 Jan 2021 08:12:20 +0000
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Owen Smith <owen.smith@xxxxxxxxxx>
  • Delivery-date: Tue, 05 Jan 2021 08:12:52 +0000
  • Ironport-sdr: 5z87oHXJ089Yt6Nvw0MD1ceAXArJlzHvNFU2nc2Sxmu4471OSa66p2uxUWm2NZP8UVumRq/5nW hfav2Jr9kqc9FsQFrmAsk/q0hPMxuqp45zZNb+AkG+62ITK3kTIKpWusO6H/8FJoRMoTccguWa hwopWV5oeTV8k+bntKsTCsGkNyBCA4kZpaYuXbTJ4iUs5tmi5lAlLVIiP3jci3+9iBZ5hc/8Cg VwTiOIP40t4j4UXNmon1E8NGXEoGQ94LkIzv0NiLVsF+i1oUg8U0BAwH4g0JOuPHbn/6xr/oZN phY=
  • List-id: Developer list for the Windows PV Drivers subproject <win-pv-devel.lists.xenproject.org>

XenStore Directory can return an empty string as the first element of
its buffer, which is converted into a 1 element array of (valid)
ANSI_STRINGs with length 0. When this 0 length string is passed to
XenStore Read, it attempts to read an invalid path (e.g. "~/drivers/")
which fails with EINVAL.
Add a check to skip 0 length strings in FdoClearDistribution.

Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
---
 src/xenbus/fdo.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/xenbus/fdo.c b/src/xenbus/fdo.c
index 21de867..9c5decc 100644
--- a/src/xenbus/fdo.c
+++ b/src/xenbus/fdo.c
@@ -2606,6 +2606,11 @@ FdoClearDistribution(
     for (Index = 0; Distributions[Index].Buffer != NULL; Index++) {
         PANSI_STRING    Distribution = &Distributions[Index];
 
+        // If ~/drivers has no children, an empty string could be returned.
+        // Note: Distribution->Buffer is 1 CHAR of "\0"
+        if (Distribution[Index].Length == 0)
+            continue;
+
         status = XENBUS_STORE(Read,
                               &Fdo->StoreInterface,
                               NULL,
-- 
2.28.0.windows.1




 


Rackspace

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