|
| 1 | +From f0fbb57dae0b9328f53c9d8ba9d672bfc9fd5cf3 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Aninda <v-anipradhan@microsoft.com> |
| 3 | +Date: Thu, 22 May 2025 22:27:55 -0400 |
| 4 | +Subject: [PATCH] Address CVE-2024-2494 |
| 5 | +Upstream Patch Reference: https://gitlab.com/libvirt/libvirt/-/commit/8a3f8d957507c1f8223fdcf25a3ff885b15557f2.patch |
| 6 | + |
| 7 | +--- |
| 8 | + src/remote/remote_daemon_dispatch.c | 65 +++++++++++++++++++++++++++++ |
| 9 | + src/rpc/gendispatch.pl | 5 +++ |
| 10 | + 2 files changed, 70 insertions(+) |
| 11 | + |
| 12 | +diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c |
| 13 | +index 7daf503..7542caa 100644 |
| 14 | +--- a/src/remote/remote_daemon_dispatch.c |
| 15 | ++++ b/src/remote/remote_daemon_dispatch.c |
| 16 | +@@ -2291,6 +2291,10 @@ remoteDispatchDomainGetSchedulerParameters(virNetServer *server G_GNUC_UNUSED, |
| 17 | + if (!conn) |
| 18 | + goto cleanup; |
| 19 | + |
| 20 | ++ if (args->nparams < 0) { |
| 21 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 22 | ++ goto cleanup; |
| 23 | ++ } |
| 24 | + if (args->nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) { |
| 25 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 26 | + goto cleanup; |
| 27 | +@@ -2339,6 +2343,10 @@ remoteDispatchDomainGetSchedulerParametersFlags(virNetServer *server G_GNUC_UNUS |
| 28 | + if (!conn) |
| 29 | + goto cleanup; |
| 30 | + |
| 31 | ++ if (args->nparams < 0) { |
| 32 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 33 | ++ goto cleanup; |
| 34 | ++ } |
| 35 | + if (args->nparams > REMOTE_DOMAIN_SCHEDULER_PARAMETERS_MAX) { |
| 36 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 37 | + goto cleanup; |
| 38 | +@@ -2497,6 +2505,10 @@ remoteDispatchDomainBlockStatsFlags(virNetServer *server G_GNUC_UNUSED, |
| 39 | + goto cleanup; |
| 40 | + flags = args->flags; |
| 41 | + |
| 42 | ++ if (args->nparams < 0) { |
| 43 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 44 | ++ goto cleanup; |
| 45 | ++ } |
| 46 | + if (args->nparams > REMOTE_DOMAIN_BLOCK_STATS_PARAMETERS_MAX) { |
| 47 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 48 | + goto cleanup; |
| 49 | +@@ -2717,6 +2729,14 @@ remoteDispatchDomainGetVcpuPinInfo(virNetServer *server G_GNUC_UNUSED, |
| 50 | + if (!(dom = get_nonnull_domain(conn, args->dom))) |
| 51 | + goto cleanup; |
| 52 | + |
| 53 | ++ if (args->ncpumaps < 0) { |
| 54 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("ncpumaps must be non-negative")); |
| 55 | ++ goto cleanup; |
| 56 | ++ } |
| 57 | ++ if (args->maplen < 0) { |
| 58 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("maplen must be non-negative")); |
| 59 | ++ goto cleanup; |
| 60 | ++ } |
| 61 | + if (args->ncpumaps > REMOTE_VCPUINFO_MAX) { |
| 62 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("ncpumaps > REMOTE_VCPUINFO_MAX")); |
| 63 | + goto cleanup; |
| 64 | +@@ -2811,6 +2831,11 @@ remoteDispatchDomainGetEmulatorPinInfo(virNetServer *server G_GNUC_UNUSED, |
| 65 | + if (!(dom = get_nonnull_domain(conn, args->dom))) |
| 66 | + goto cleanup; |
| 67 | + |
| 68 | ++ if (args->maplen < 0) { |
| 69 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("maplen must be non-negative")); |
| 70 | ++ goto cleanup; |
| 71 | ++ } |
| 72 | ++ |
| 73 | + /* Allocate buffers to take the results */ |
| 74 | + if (args->maplen > 0) |
| 75 | + cpumaps = g_new0(unsigned char, args->maplen); |
| 76 | +@@ -2858,6 +2883,14 @@ remoteDispatchDomainGetVcpus(virNetServer *server G_GNUC_UNUSED, |
| 77 | + if (!(dom = get_nonnull_domain(conn, args->dom))) |
| 78 | + goto cleanup; |
| 79 | + |
| 80 | ++ if (args->maxinfo < 0) { |
| 81 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo must be non-negative")); |
| 82 | ++ goto cleanup; |
| 83 | ++ } |
| 84 | ++ if (args->maplen < 0) { |
| 85 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo must be non-negative")); |
| 86 | ++ goto cleanup; |
| 87 | ++ } |
| 88 | + if (args->maxinfo > REMOTE_VCPUINFO_MAX) { |
| 89 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo > REMOTE_VCPUINFO_MAX")); |
| 90 | + goto cleanup; |
| 91 | +@@ -3096,6 +3129,10 @@ remoteDispatchDomainGetMemoryParameters(virNetServer *server G_GNUC_UNUSED, |
| 92 | + |
| 93 | + flags = args->flags; |
| 94 | + |
| 95 | ++ if (args->nparams < 0) { |
| 96 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 97 | ++ goto cleanup; |
| 98 | ++ } |
| 99 | + if (args->nparams > REMOTE_DOMAIN_MEMORY_PARAMETERS_MAX) { |
| 100 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 101 | + goto cleanup; |
| 102 | +@@ -3156,6 +3193,10 @@ remoteDispatchDomainGetNumaParameters(virNetServer *server G_GNUC_UNUSED, |
| 103 | + |
| 104 | + flags = args->flags; |
| 105 | + |
| 106 | ++ if (args->nparams < 0) { |
| 107 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 108 | ++ goto cleanup; |
| 109 | ++ } |
| 110 | + if (args->nparams > REMOTE_DOMAIN_NUMA_PARAMETERS_MAX) { |
| 111 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 112 | + goto cleanup; |
| 113 | +@@ -3216,6 +3257,10 @@ remoteDispatchDomainGetBlkioParameters(virNetServer *server G_GNUC_UNUSED, |
| 114 | + |
| 115 | + flags = args->flags; |
| 116 | + |
| 117 | ++ if (args->nparams < 0) { |
| 118 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 119 | ++ goto cleanup; |
| 120 | ++ } |
| 121 | + if (args->nparams > REMOTE_DOMAIN_BLKIO_PARAMETERS_MAX) { |
| 122 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 123 | + goto cleanup; |
| 124 | +@@ -3277,6 +3322,10 @@ remoteDispatchNodeGetCPUStats(virNetServer *server G_GNUC_UNUSED, |
| 125 | + |
| 126 | + flags = args->flags; |
| 127 | + |
| 128 | ++ if (args->nparams < 0) { |
| 129 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 130 | ++ goto cleanup; |
| 131 | ++ } |
| 132 | + if (args->nparams > REMOTE_NODE_CPU_STATS_MAX) { |
| 133 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 134 | + goto cleanup; |
| 135 | +@@ -3339,6 +3388,10 @@ remoteDispatchNodeGetMemoryStats(virNetServer *server G_GNUC_UNUSED, |
| 136 | + |
| 137 | + flags = args->flags; |
| 138 | + |
| 139 | ++ if (args->nparams < 0) { |
| 140 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 141 | ++ goto cleanup; |
| 142 | ++ } |
| 143 | + if (args->nparams > REMOTE_NODE_MEMORY_STATS_MAX) { |
| 144 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 145 | + goto cleanup; |
| 146 | +@@ -3514,6 +3567,10 @@ remoteDispatchDomainGetBlockIoTune(virNetServer *server G_GNUC_UNUSED, |
| 147 | + if (!conn) |
| 148 | + goto cleanup; |
| 149 | + |
| 150 | ++ if (args->nparams < 0) { |
| 151 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 152 | ++ goto cleanup; |
| 153 | ++ } |
| 154 | + if (args->nparams > REMOTE_DOMAIN_BLOCK_IO_TUNE_PARAMETERS_MAX) { |
| 155 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 156 | + goto cleanup; |
| 157 | +@@ -5079,6 +5136,10 @@ remoteDispatchDomainGetInterfaceParameters(virNetServer *server G_GNUC_UNUSED, |
| 158 | + |
| 159 | + flags = args->flags; |
| 160 | + |
| 161 | ++ if (args->nparams < 0) { |
| 162 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 163 | ++ goto cleanup; |
| 164 | ++ } |
| 165 | + if (args->nparams > REMOTE_DOMAIN_INTERFACE_PARAMETERS_MAX) { |
| 166 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 167 | + goto cleanup; |
| 168 | +@@ -5299,6 +5360,10 @@ remoteDispatchNodeGetMemoryParameters(virNetServer *server G_GNUC_UNUSED, |
| 169 | + |
| 170 | + flags = args->flags; |
| 171 | + |
| 172 | ++ if (args->nparams < 0) { |
| 173 | ++ virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams must be non-negative")); |
| 174 | ++ goto cleanup; |
| 175 | ++ } |
| 176 | + if (args->nparams > REMOTE_NODE_MEMORY_PARAMETERS_MAX) { |
| 177 | + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("nparams too large")); |
| 178 | + goto cleanup; |
| 179 | +diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl |
| 180 | +index 5ce988c..c5842dc 100755 |
| 181 | +--- a/src/rpc/gendispatch.pl |
| 182 | ++++ b/src/rpc/gendispatch.pl |
| 183 | +@@ -1070,6 +1070,11 @@ elsif ($mode eq "server") { |
| 184 | + print "\n"; |
| 185 | + |
| 186 | + if ($single_ret_as_list) { |
| 187 | ++ print " if (args->$single_ret_list_max_var < 0) {\n"; |
| 188 | ++ print " virReportError(VIR_ERR_RPC,\n"; |
| 189 | ++ print " \"%s\", _(\"max$single_ret_list_name must be non-negative\"));\n"; |
| 190 | ++ print " goto cleanup;\n"; |
| 191 | ++ print " }\n"; |
| 192 | + print " if (args->$single_ret_list_max_var > $single_ret_list_max_define) {\n"; |
| 193 | + print " virReportError(VIR_ERR_RPC,\n"; |
| 194 | + print " \"%s\", _(\"max$single_ret_list_name > $single_ret_list_max_define\"));\n"; |
| 195 | +-- |
| 196 | +2.34.1 |
| 197 | + |
0 commit comments