|
|
43fe83 |
From 68580ef359c7940d5f4b88f2ed2612d99a32cbf0 Mon Sep 17 00:00:00 2001
|
|
|
43fe83 |
Message-Id: <68580ef359c7940d5f4b88f2ed2612d99a32cbf0.1377873640.git.jdenemar@redhat.com>
|
|
|
43fe83 |
From: "Daniel P. Berrange" <berrange@redhat.com>
|
|
|
43fe83 |
Date: Fri, 30 Aug 2013 11:16:07 +0100
|
|
|
43fe83 |
Subject: [PATCH] Add bounds checking on virConnectListAllStoragePools RPC call
|
|
|
43fe83 |
|
|
|
43fe83 |
For
|
|
|
43fe83 |
|
|
|
43fe83 |
https://bugzilla.redhat.com/show_bug.cgi?id=1002667
|
|
|
43fe83 |
|
|
|
43fe83 |
The return values for the virConnectListAllStoragePools call were not
|
|
|
43fe83 |
bounds checked. This is a robustness issue for clients if
|
|
|
43fe83 |
something where to cause corruption of the RPC stream data.
|
|
|
43fe83 |
|
|
|
43fe83 |
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
|
|
|
43fe83 |
(cherry picked from commit c853fa8febad5c4990936521f9426f3e3df74f98)
|
|
|
43fe83 |
---
|
|
|
43fe83 |
daemon/remote.c | 7 +++++++
|
|
|
43fe83 |
src/remote/remote_driver.c | 7 +++++++
|
|
|
43fe83 |
src/remote/remote_protocol.x | 10 +++++-----
|
|
|
43fe83 |
3 files changed, 19 insertions(+), 5 deletions(-)
|
|
|
43fe83 |
|
|
|
43fe83 |
diff --git a/daemon/remote.c b/daemon/remote.c
|
|
|
43fe83 |
index 8289cb5..42c1c47 100644
|
|
|
43fe83 |
--- a/daemon/remote.c
|
|
|
43fe83 |
+++ b/daemon/remote.c
|
|
|
43fe83 |
@@ -4073,6 +4073,13 @@ remoteDispatchConnectListAllStoragePools(virNetServerPtr server ATTRIBUTE_UNUSED
|
|
|
43fe83 |
args->flags)) < 0)
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
|
|
|
43fe83 |
+ if (npools > REMOTE_STORAGE_POOL_LIST_MAX) {
|
|
|
43fe83 |
+ virReportError(VIR_ERR_RPC,
|
|
|
43fe83 |
+ _("Too many storage pools '%d' for limit '%d'"),
|
|
|
43fe83 |
+ npools, REMOTE_STORAGE_POOL_LIST_MAX);
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+
|
|
|
43fe83 |
if (pools && npools) {
|
|
|
43fe83 |
if (VIR_ALLOC_N(ret->pools.pools_val, npools) < 0)
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c
|
|
|
43fe83 |
index cd2b9a9..622647b 100644
|
|
|
43fe83 |
--- a/src/remote/remote_driver.c
|
|
|
43fe83 |
+++ b/src/remote/remote_driver.c
|
|
|
43fe83 |
@@ -3276,6 +3276,13 @@ remoteConnectListAllStoragePools(virConnectPtr conn,
|
|
|
43fe83 |
(char *) &ret) == -1)
|
|
|
43fe83 |
goto done;
|
|
|
43fe83 |
|
|
|
43fe83 |
+ if (ret.pools.pools_len > REMOTE_STORAGE_POOL_LIST_MAX) {
|
|
|
43fe83 |
+ virReportError(VIR_ERR_RPC,
|
|
|
43fe83 |
+ _("Too many storage pools '%d' for limit '%d'"),
|
|
|
43fe83 |
+ ret.pools.pools_len, REMOTE_STORAGE_POOL_LIST_MAX);
|
|
|
43fe83 |
+ goto cleanup;
|
|
|
43fe83 |
+ }
|
|
|
43fe83 |
+
|
|
|
43fe83 |
if (pools) {
|
|
|
43fe83 |
if (VIR_ALLOC_N(tmp_pools, ret.pools.pools_len + 1) < 0)
|
|
|
43fe83 |
goto cleanup;
|
|
|
43fe83 |
diff --git a/src/remote/remote_protocol.x b/src/remote/remote_protocol.x
|
|
|
43fe83 |
index 718e398..6e996b4 100644
|
|
|
43fe83 |
--- a/src/remote/remote_protocol.x
|
|
|
43fe83 |
+++ b/src/remote/remote_protocol.x
|
|
|
43fe83 |
@@ -97,8 +97,8 @@ const REMOTE_INTERFACE_NAME_LIST_MAX = 16384;
|
|
|
43fe83 |
/* Upper limit on lists of defined interface names. */
|
|
|
43fe83 |
const REMOTE_DEFINED_INTERFACE_NAME_LIST_MAX = 16384;
|
|
|
43fe83 |
|
|
|
43fe83 |
-/* Upper limit on lists of storage pool names. */
|
|
|
43fe83 |
-const REMOTE_STORAGE_POOL_NAME_LIST_MAX = 4096;
|
|
|
43fe83 |
+/* Upper limit on lists of storage pools. */
|
|
|
43fe83 |
+const REMOTE_STORAGE_POOL_LIST_MAX = 4096;
|
|
|
43fe83 |
|
|
|
43fe83 |
/* Upper limit on lists of storage vol names. */
|
|
|
43fe83 |
const REMOTE_STORAGE_VOL_NAME_LIST_MAX = 16384;
|
|
|
43fe83 |
@@ -1604,7 +1604,7 @@ struct remote_connect_list_storage_pools_args {
|
|
|
43fe83 |
};
|
|
|
43fe83 |
|
|
|
43fe83 |
struct remote_connect_list_storage_pools_ret {
|
|
|
43fe83 |
- remote_nonnull_string names<REMOTE_STORAGE_POOL_NAME_LIST_MAX>; /* insert@1 */
|
|
|
43fe83 |
+ remote_nonnull_string names<REMOTE_STORAGE_POOL_LIST_MAX>; /* insert@1 */
|
|
|
43fe83 |
};
|
|
|
43fe83 |
|
|
|
43fe83 |
struct remote_connect_num_of_defined_storage_pools_ret {
|
|
|
43fe83 |
@@ -1616,7 +1616,7 @@ struct remote_connect_list_defined_storage_pools_args {
|
|
|
43fe83 |
};
|
|
|
43fe83 |
|
|
|
43fe83 |
struct remote_connect_list_defined_storage_pools_ret {
|
|
|
43fe83 |
- remote_nonnull_string names<REMOTE_STORAGE_POOL_NAME_LIST_MAX>; /* insert@1 */
|
|
|
43fe83 |
+ remote_nonnull_string names<REMOTE_STORAGE_POOL_LIST_MAX>; /* insert@1 */
|
|
|
43fe83 |
};
|
|
|
43fe83 |
|
|
|
43fe83 |
struct remote_connect_find_storage_pool_sources_args {
|
|
|
43fe83 |
@@ -2670,7 +2670,7 @@ struct remote_connect_list_all_storage_pools_args {
|
|
|
43fe83 |
};
|
|
|
43fe83 |
|
|
|
43fe83 |
struct remote_connect_list_all_storage_pools_ret {
|
|
|
43fe83 |
- remote_nonnull_storage_pool pools<>;
|
|
|
43fe83 |
+ remote_nonnull_storage_pool pools<REMOTE_STORAGE_POOL_LIST_MAX>;
|
|
|
43fe83 |
unsigned int ret;
|
|
|
43fe83 |
};
|
|
|
43fe83 |
|
|
|
43fe83 |
--
|
|
|
43fe83 |
1.8.3.2
|
|
|
43fe83 |
|