From 0c0ab54756999324d57973ff4b0102a54bc0b7af Mon Sep 17 00:00:00 2001
Message-Id: <0c0ab54756999324d57973ff4b0102a54bc0b7af.1377873640.git.jdenemar@redhat.com>
From: "Daniel P. Berrange" <berrange@redhat.com>
Date: Fri, 30 Aug 2013 11:16:10 +0100
Subject: [PATCH] Add bounds checking on virConnectListAllInterfaces RPC call
For
https://bugzilla.redhat.com/show_bug.cgi?id=1002667
The return values for the virConnectListAllInterfaces 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@redhat.com>
(cherry picked from commit 8be2172897c272ead150ad59a63946ab97562a11)
---
daemon/remote.c | 7 +++++++
src/remote/remote_driver.c | 7 +++++++
src/remote/remote_protocol.x | 13 +++++--------
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/daemon/remote.c b/daemon/remote.c
index b6501e0..871b0df 100644
--- a/daemon/remote.c
+++ b/daemon/remote.c
@@ -4256,6 +4256,13 @@ remoteDispatchConnectListAllInterfaces(virNetServerPtr server ATTRIBUTE_UNUSED,
args->flags)) < 0)
goto cleanup;
+ if (nifaces > REMOTE_INTERFACE_LIST_MAX) {
+ virReportError(VIR_ERR_RPC,
+ _("Too many interfaces '%d' for limit '%d'"),
+ nifaces, REMOTE_INTERFACE_LIST_MAX);
+ goto cleanup;
+ }
+
if (ifaces && nifaces) {
if (VIR_ALLOC_N(ret->ifaces.ifaces_val, nifaces) < 0)
goto cleanup;
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
index e555704..4d82452 100644
--- a/src/remote/remote_driver.c
+++ b/src/remote/remote_driver.c
@@ -2909,6 +2909,13 @@ remoteConnectListAllInterfaces(virConnectPtr conn,
(char *) &ret) == -1)
goto done;
+ if (ret.ifaces.ifaces_len > REMOTE_INTERFACE_LIST_MAX) {
+ virReportError(VIR_ERR_RPC,
+ _("Too many interfaces '%d' for limit '%d'"),
+ ret.ifaces.ifaces_len, REMOTE_INTERFACE_LIST_MAX);
+ goto cleanup;
+ }
+
if (ifaces) {
if (VIR_ALLOC_N(tmp_ifaces, ret.ifaces.ifaces_len + 1) < 0)
goto cleanup;
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
index f1e27fa..573d63f 100644
--- a/src/remote/remote_protocol.x
+++ b/src/remote/remote_protocol.x
@@ -91,11 +91,8 @@ const REMOTE_MIGRATE_COOKIE_MAX = 16384;
/* Upper limit on lists of networks. */
const REMOTE_NETWORK_LIST_MAX = 16384;
-/* Upper limit on lists of interface names. */
-const REMOTE_INTERFACE_NAME_LIST_MAX = 16384;
-
-/* Upper limit on lists of defined interface names. */
-const REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX = 16384;
+/* Upper limit on lists of interfaces. */
+const REMOTE_INTERFACE_LIST_MAX = 16384;
/* Upper limit on lists of storage pools. */
const REMOTE_STORAGE_POOL_LIST_MAX = 4096;
@@ -1478,7 +1475,7 @@ struct remote_connect_list_interfaces_args {
};
struct remote_connect_list_interfaces_ret {
- remote_nonnull_string names<REMOTE_INTERFACE_NAME_LIST_MAX>; /* insert@1 */
+ remote_nonnull_string names<REMOTE_INTERFACE_LIST_MAX>; /* insert@1 */
};
struct remote_connect_num_of_defined_interfaces_ret {
@@ -1490,7 +1487,7 @@ struct remote_connect_list_defined_interfaces_args {
};
struct remote_connect_list_defined_interfaces_ret {
- remote_nonnull_string names<REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX>; /* insert@1 */
+ remote_nonnull_string names<REMOTE_INTERFACE_LIST_MAX>; /* insert@1 */
};
struct remote_interface_lookup_by_name_args {
@@ -2701,7 +2698,7 @@ struct remote_connect_list_all_interfaces_args {
};
struct remote_connect_list_all_interfaces_ret {
- remote_nonnull_interface ifaces<>;
+ remote_nonnull_interface ifaces<REMOTE_INTERFACE_LIST_MAX>;
unsigned int ret;
};
--
1.8.3.2