[PATCH 09/12] Add bounds checking on virConnectListAllNodeDevices RPC call

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

 



From: "Daniel P. Berrange" <berrange@xxxxxxxxxx>

The return values for the virConnectListAllNodeDevices call were not
bounds checked. This is a robustness issue for clients if
something where to cause corruption of the RPC stream data.

Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
---
 daemon/remote.c              | 7 +++++++
 src/remote/remote_driver.c   | 7 +++++++
 src/remote/remote_protocol.x | 8 ++++----
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/daemon/remote.c b/daemon/remote.c
index 871b0df..697aa58 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4315,6 +4315,13 @@ remoteDispatchConnectListAllNodeDevices(virNetServerPtr server ATTRIBUTE_UNUSED,
                                                  args->flags)) < 0)
         goto cleanup;
 
+    if (ndevices > REMOTE_NODE_DEVICE_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many node devices '%d' for limit '%d'"),
+                       ndevices, REMOTE_NODE_DEVICE_LIST_MAX);
+        goto cleanup;
+    }
+
     if (devices && ndevices) {
         if (VIR_ALLOC_N(ret->devices.devices_val, ndevices) < 0)
             goto cleanup;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index 4d82452..b170a06 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2975,6 +2975,13 @@ remoteConnectListAllNodeDevices(virConnectPtr conn,
              (char *) &ret) == -1)
         goto done;
 
+    if (ret.devices.devices_len > REMOTE_NODE_DEVICE_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many node devices '%d' for limit '%d'"),
+                       ret.devices.devices_len, REMOTE_NODE_DEVICE_LIST_MAX);
+        goto cleanup;
+    }
+
     if (devices) {
         if (VIR_ALLOC_N(tmp_devices, ret.devices.devices_len + 1) < 0)
             goto cleanup;
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 573d63f..21059c8 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -100,8 +100,8 @@ const REMOTE_STORAGE_POOL_LIST_MAX = 4096;
 /* Upper limit on lists of storage vols. */
 const REMOTE_STORAGE_VOL_LIST_MAX = 16384;
 
-/* Upper limit on lists of node device names. */
-const REMOTE_NODE_DEVICE_NAME_LIST_MAX = 16384;
+/* Upper limit on lists of node devices. */
+const REMOTE_NODE_DEVICE_LIST_MAX = 16384;
 
 /* Upper limit on lists of node device capabilities. */
 const REMOTE_NODE_DEVICE_CAPS_LIST_MAX = 65536;
@@ -1863,7 +1863,7 @@ struct remote_node_list_devices_args {
 };
 
 struct remote_node_list_devices_ret {
-    remote_nonnull_string names<REMOTE_NODE_DEVICE_NAME_LIST_MAX>; /* insert@2 */
+    remote_nonnull_string names<REMOTE_NODE_DEVICE_LIST_MAX>; /* insert@2 */
 };
 
 struct remote_node_device_lookup_by_name_args {
@@ -2708,7 +2708,7 @@ struct remote_connect_list_all_node_devices_args {
 };
 
 struct remote_connect_list_all_node_devices_ret {
-    remote_nonnull_node_device devices<>;
+    remote_nonnull_node_device devices<REMOTE_NODE_DEVICE_LIST_MAX>;
     unsigned int ret;
 };
 
-- 
1.8.3.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]