[PATCH 10/12] Add bounds checking on virConnectListAllNWFilters 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 virConnectListAllNWFilters 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 697aa58..e19b42d 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4374,6 +4374,13 @@ remoteDispatchConnectListAllNWFilters(virNetServerPtr server ATTRIBUTE_UNUSED,
                                                args->flags)) < 0)
         goto cleanup;
 
+    if (nfilters > REMOTE_NWFILTER_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many network filters '%d' for limit '%d'"),
+                       nfilters, REMOTE_NWFILTER_LIST_MAX);
+        goto cleanup;
+    }
+
     if (filters && nfilters) {
         if (VIR_ALLOC_N(ret->filters.filters_val, nfilters) < 0)
             goto cleanup;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index b170a06..d486fa5 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -3041,6 +3041,13 @@ remoteConnectListAllNWFilters(virConnectPtr conn,
              (char *) &ret) == -1)
         goto done;
 
+    if (ret.filters.filters_len > REMOTE_NWFILTER_LIST_MAX) {
+        virReportError(VIR_ERR_RPC,
+                       _("Too many network filters '%d' for limit '%d'"),
+                       ret.filters.filters_len, REMOTE_NWFILTER_LIST_MAX);
+        goto cleanup;
+    }
+
     if (filters) {
         if (VIR_ALLOC_N(tmp_filters, ret.filters.filters_len + 1) < 0)
             goto cleanup;
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index 21059c8..b2841a7 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -106,8 +106,8 @@ const REMOTE_NODE_DEVICE_LIST_MAX = 16384;
 /* Upper limit on lists of node device capabilities. */
 const REMOTE_NODE_DEVICE_CAPS_LIST_MAX = 65536;
 
-/* Upper limit on lists of network filter names. */
-const REMOTE_NWFILTER_NAME_LIST_MAX = 1024;
+/* Upper limit on lists of network filters. */
+const REMOTE_NWFILTER_LIST_MAX = 1024;
 
 /* Upper limit on list of scheduler parameters. */
 const REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX = 16;
@@ -1423,7 +1423,7 @@ struct remote_connect_list_nwfilters_args {
 };
 
 struct remote_connect_list_nwfilters_ret {
-    remote_nonnull_string names<REMOTE_NWFILTER_NAME_LIST_MAX>; /* insert@1 */
+    remote_nonnull_string names<REMOTE_NWFILTER_LIST_MAX>; /* insert@1 */
 };
 
 struct remote_nwfilter_lookup_by_uuid_args {
@@ -2718,7 +2718,7 @@ struct remote_connect_list_all_nwfilters_args {
 };
 
 struct remote_connect_list_all_nwfilters_ret {
-    remote_nonnull_nwfilter filters<>;
+    remote_nonnull_nwfilter filters<REMOTE_NWFILTER_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]