Compare commits
140 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 15daaf9dad | |||
| 0e49b25b5b | |||
| b5937f6a85 | |||
| d307c3aa2e | |||
| f4d251ad6e | |||
| b0d2e09842 | |||
| b0dd011728 | |||
| 2513c9ff81 | |||
| 9ef5501a94 | |||
| 659f2f0b36 | |||
| f3cac3532b | |||
| 6eb56c2e71 | |||
| 93a549eb1a | |||
| f2a998ce76 | |||
| 8556d44e84 | |||
| f8539fae13 | |||
| 80a3188a20 | |||
| 56d89b1d61 | |||
| 2a7828bae8 | |||
| c879325741 | |||
| edf6aa6cd7 | |||
| 163b87484b | |||
| 5828ec5da6 | |||
| adaeee1c2c | |||
| 200f2942a9 | |||
| cbf07f0551 | |||
| eb9ceebe38 | |||
| 507eb37491 | |||
| 3e211fa0f6 | |||
| d4bb64489a | |||
| 6d908194bf | |||
| 2333a80c1a | |||
| f4fd6d7df6 | |||
| c1a3411c3b | |||
| 619904f37a | |||
| 044c5b0665 | |||
| 50aba9b5a0 | |||
| c98b586e70 | |||
| 987430ba8b | |||
| 58043b20fb | |||
| f1888958a6 | |||
| 6c3d79e65d | |||
| dc9be9b9a7 | |||
| 5e0d67787a | |||
| 662f0e2ba4 | |||
| 66060fa395 | |||
| 83def04a25 | |||
| 535bbcdd91 | |||
| 417e4c9cf7 | |||
| 24d349fa37 | |||
| 9f3b22fec4 | |||
| 7285a57f5c | |||
| 9944fa190c | |||
| 1a44dca7d4 | |||
| 0c2262d602 | |||
| da598118cf | |||
| da34e517db | |||
| 7b17ccd035 | |||
| 908a2f2a46 | |||
| acf19787de | |||
| c269619b9a | |||
| 3f6336f446 | |||
| a552a10ec8 | |||
| bfb8157052 | |||
| edb5200d83 | |||
| fe3f90dedd | |||
| 437df85540 | |||
| 2d6cbe6672 | |||
| 97a323d7c2 | |||
| cb839d3dfc | |||
| dc6b512f3c | |||
| ac122f4525 | |||
| 7744acbb6b | |||
| 3807f07c15 | |||
| e484fdc92b | |||
| 6752fe8c9e | |||
| 15f52369ae | |||
| 65a0e26138 | |||
| 497e096592 | |||
| 03a98aaf59 | |||
| 5845f1efec | |||
| a8d01eb9d7 | |||
| 6d76ba5956 | |||
| a11202d9e2 | |||
| bbfa59c8da | |||
| b97ad8956c | |||
| f9639a0012 | |||
| c71e60c76c | |||
| 9764121247 | |||
| a18ed3c492 | |||
| 9e2eeb32e3 | |||
| 8bf91f5d22 | |||
| 91d8eff569 | |||
| a761ea338f | |||
| 7eef88add4 | |||
| 0c88a64234 | |||
| c2f3be1f4d | |||
| 18b1c9d77e | |||
| 4528832026 | |||
| 037cd36ba2 | |||
| b94fb6a393 | |||
| b0c05ac2ae | |||
| 15c305caf3 | |||
| bc1b3e59a7 | |||
| 3c4492c415 | |||
| fecc0295a2 | |||
| 325dc837c6 | |||
| 5a45cb7f0d | |||
| 21269530e8 | |||
| fc18e983e7 | |||
| 4a7cc743a9 | |||
| 4398397311 | |||
| 401f9087bc | |||
| dd3698988e | |||
| 3df49002c2 | |||
| 1bf0aedb9f | |||
| 79accd5a6e | |||
| 422d548fce | |||
| 20ec6e955c | |||
| 406a235cbc | |||
| 4d15e56a38 | |||
| 8693111790 | |||
| 8461a521f2 | |||
| 511e2c5124 | |||
| 749dc3d3cb | |||
| 73c9e38f2c | |||
| afe8184d3f | |||
| 7d77bf76aa | |||
| 7f0f1b831e | |||
| d964be0097 | |||
| a2479f539e | |||
| c2c89ec6a3 | |||
| d61e2404ba | |||
| a2be167dfe | |||
| 15ca09e1da | |||
| 2cc07e6366 | |||
| 4dd4fe78a4 | |||
| 0bc22fb6f7 | |||
| 76097a6961 | |||
| 98cbf39fd3 |
@@ -0,0 +1,31 @@
|
||||
[suppress_function]
|
||||
symbol_version_regexp = LIBVIRT_PRIVATE.*
|
||||
soname_regexp = libvirt\\.so.*
|
||||
|
||||
[suppress_function]
|
||||
symbol_version_regexp = LIBVIRT_ADMIN_PRIVATE.*
|
||||
soname_regexp = libvirt-admin\\.so.*
|
||||
|
||||
[suppress_variable]
|
||||
symbol_version_regexp = LIBVIRT_PRIVATE.*
|
||||
soname_regexp = libvirt\\.so.*
|
||||
|
||||
[suppress_variable]
|
||||
symbol_version_regexp = LIBVIRT_ADMIN_PRIVATE.*
|
||||
soname_regexp = libvirt-admin\\.so.*
|
||||
|
||||
[suppress_function]
|
||||
symbol_version_regexp = .*
|
||||
soname_regexp = libvirt_storage_.*\\.so.*
|
||||
|
||||
[suppress_variable]
|
||||
symbol_version_regexp = .*
|
||||
soname_regexp = libvirt_storage_.*\\.so.*
|
||||
|
||||
[suppress_function]
|
||||
symbol_version_regexp = .*
|
||||
soname_regexp = libvirt_driver_.*\\.so.*
|
||||
|
||||
[suppress_variable]
|
||||
symbol_version_regexp = .*
|
||||
soname_regexp = libvirt_driver_.*\\.so.*
|
||||
@@ -0,0 +1,41 @@
|
||||
From 3499354e12a1c1832bf4030693a64e03ceb79d05 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
||||
Date: Wed, 5 Jun 2024 11:16:21 +0100
|
||||
Subject: [PATCH] interface: fix udev reference leak with invalid flags
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The udevInterfaceGetXMLDesc method takes a reference on the udev
|
||||
driver as its first action. If the virCheckFlags() condition
|
||||
fails, however, this reference is never released.
|
||||
|
||||
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
|
||||
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
---
|
||||
src/interface/interface_backend_udev.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c
|
||||
index fdf11a8318..e1a50389c9 100644
|
||||
--- a/src/interface/interface_backend_udev.c
|
||||
+++ b/src/interface/interface_backend_udev.c
|
||||
@@ -1027,12 +1027,14 @@ static char *
|
||||
udevInterfaceGetXMLDesc(virInterfacePtr ifinfo,
|
||||
unsigned int flags)
|
||||
{
|
||||
- struct udev *udev = udev_ref(driver->udev);
|
||||
+ struct udev *udev = NULL;
|
||||
g_autoptr(virInterfaceDef) ifacedef = NULL;
|
||||
char *xmlstr = NULL;
|
||||
|
||||
virCheckFlags(VIR_INTERFACE_XML_INACTIVE, NULL);
|
||||
|
||||
+ udev = udev_ref(driver->udev);
|
||||
+
|
||||
/* Recursively build up the interface XML based on the requested
|
||||
* interface name
|
||||
*/
|
||||
--
|
||||
2.45.1
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
From 98f1cf88fa7e0f992d93f376418fbfb3996a9690 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
||||
Date: Fri, 17 May 2024 14:55:24 +0100
|
||||
Subject: [PATCH] rpc: avoid leak of GSource in use for interrupting main loop
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
We never release the reference on the GSource created for
|
||||
interrupting the main loop, nor do we remove it from the
|
||||
main context if our thread is woken up prior to the wakeup
|
||||
callback firing.
|
||||
|
||||
This can result in a leak of GSource objects, along with an
|
||||
ever growing list of GSources attached to the main context,
|
||||
which will gradually slow down execution of the loop, as
|
||||
several operations are O(N) for the number of attached GSource
|
||||
objects.
|
||||
|
||||
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
---
|
||||
src/rpc/virnetclient.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
|
||||
index 147b0d661a..6d424eb599 100644
|
||||
--- a/src/rpc/virnetclient.c
|
||||
+++ b/src/rpc/virnetclient.c
|
||||
@@ -1946,7 +1946,7 @@ static int virNetClientIO(virNetClient *client,
|
||||
/* Check to see if another thread is dispatching */
|
||||
if (client->haveTheBuck) {
|
||||
/* Force other thread to wakeup from poll */
|
||||
- GSource *wakeup = g_idle_source_new();
|
||||
+ g_autoptr(GSource) wakeup = g_idle_source_new();
|
||||
g_source_set_callback(wakeup, virNetClientIOWakeup, client->eventLoop, NULL);
|
||||
g_source_attach(wakeup, client->eventCtx);
|
||||
|
||||
@@ -1968,6 +1968,7 @@ static int virNetClientIO(virNetClient *client,
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ g_source_destroy(wakeup);
|
||||
VIR_DEBUG("Woken up from sleep head=%p call=%p",
|
||||
client->waitDispatch, thiscall);
|
||||
/* Three reasons we can be woken up
|
||||
--
|
||||
2.45.1
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
From 8074d64dc2eca846d6a61efe1a9b7428a0ce1dd1 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
||||
Date: Tue, 30 Apr 2024 11:51:15 +0100
|
||||
Subject: [PATCH] rpc: ensure temporary GSource is removed from client event
|
||||
loop
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Users are seeing periodic segfaults from libvirt client apps,
|
||||
especially thread heavy ones like virt-manager. A typical
|
||||
stack trace would end up in the virNetClientIOEventFD method,
|
||||
with illegal access to stale stack data. eg
|
||||
|
||||
==238721==ERROR: AddressSanitizer: stack-use-after-return on address 0x75cd18709788 at pc 0x75cd3111f907 bp 0x75cd181ff550 sp 0x75cd181ff548
|
||||
WRITE of size 4 at 0x75cd18709788 thread T11
|
||||
#0 0x75cd3111f906 in virNetClientIOEventFD /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:1634:15
|
||||
#1 0x75cd3210d198 (/usr/lib/libglib-2.0.so.0+0x5a198) (BuildId: 0a2311dfbbc6c215dc36f4b6bdd2b4b6fbae55a2)
|
||||
#2 0x75cd3216c3be (/usr/lib/libglib-2.0.so.0+0xb93be) (BuildId: 0a2311dfbbc6c215dc36f4b6bdd2b4b6fbae55a2)
|
||||
#3 0x75cd3210ddc6 in g_main_loop_run (/usr/lib/libglib-2.0.so.0+0x5adc6) (BuildId: 0a2311dfbbc6c215dc36f4b6bdd2b4b6fbae55a2)
|
||||
#4 0x75cd3111a47c in virNetClientIOEventLoop /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:1722:9
|
||||
#5 0x75cd3111a47c in virNetClientIO /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:2002:10
|
||||
#6 0x75cd3111a47c in virNetClientSendInternal /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:2170:11
|
||||
#7 0x75cd311198a8 in virNetClientSendWithReply /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclient.c:2198:11
|
||||
#8 0x75cd31111653 in virNetClientProgramCall /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/rpc/virnetclientprogram.c:318:9
|
||||
#9 0x75cd31241c8f in callFull /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/remote/remote_driver.c:6054:10
|
||||
#10 0x75cd31241c8f in call /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/remote/remote_driver.c:6076:12
|
||||
#11 0x75cd31241c8f in remoteNetworkGetXMLDesc /usr/src/debug/libvirt/libvirt-10.2.0/build/src/remote/remote_client_bodies.h:5959:9
|
||||
#12 0x75cd31410ff7 in virNetworkGetXMLDesc /usr/src/debug/libvirt/libvirt-10.2.0/build/../src/libvirt-network.c:952:15
|
||||
|
||||
The root cause is a bad assumption in the virNetClientIOEventLoop
|
||||
method. This method is run by whichever thread currently owns the
|
||||
buck, and is responsible for handling I/O. Inside a for(;;) loop,
|
||||
this method creates a temporary GSource, adds it to the event loop
|
||||
and runs g_main_loop_run(). When I/O is ready, the GSource callback
|
||||
(virNetClientIOEventFD) will fire and call g_main_loop_quit(), and
|
||||
return G_SOURCE_REMOVE which results in the temporary GSource being
|
||||
destroyed. A g_autoptr() will then remove the last reference.
|
||||
|
||||
What was overlooked, is that a second thread can come along and
|
||||
while it can't enter virNetClientIOEventLoop, it will register an
|
||||
idle source that uses virNetClientIOWakeup to interrupt the
|
||||
original thread's 'g_main_loop_run' call. When this happens the
|
||||
virNetClientIOEventFD callback never runs, and so the temporary
|
||||
GSource is not destroyed. The g_autoptr() will remove a reference,
|
||||
but by virtue of still being attached to the event context, there
|
||||
is an extra reference held causing GSource to be leaked. The
|
||||
next time 'g_main_loop_run' is called, the original GSource will
|
||||
trigger its callback, and access data that was allocated on the
|
||||
stack by the previous thread, and likely SEGV.
|
||||
|
||||
To solve this, the thread calling 'g_main_loop_run' must call
|
||||
g_source_destroy, immediately upon return, to guarantee that
|
||||
the temporary GSource is removed.
|
||||
|
||||
CVE-2024-4418
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
Reported-by: Martin Shirokov <shirokovmartin@gmail.com>
|
||||
Tested-by: Martin Shirokov <shirokovmartin@gmail.com>
|
||||
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
---
|
||||
src/rpc/virnetclient.c | 14 +++++++++++++-
|
||||
1 file changed, 13 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
|
||||
index 68098b1c8d..147b0d661a 100644
|
||||
--- a/src/rpc/virnetclient.c
|
||||
+++ b/src/rpc/virnetclient.c
|
||||
@@ -1657,7 +1657,7 @@ static int virNetClientIOEventLoop(virNetClient *client,
|
||||
#endif /* !WIN32 */
|
||||
int timeout = -1;
|
||||
virNetMessage *msg = NULL;
|
||||
- g_autoptr(GSource) G_GNUC_UNUSED source = NULL;
|
||||
+ g_autoptr(GSource) source = NULL;
|
||||
GIOCondition ev = 0;
|
||||
struct virNetClientIOEventData data = {
|
||||
.client = client,
|
||||
@@ -1721,6 +1721,18 @@ static int virNetClientIOEventLoop(virNetClient *client,
|
||||
|
||||
g_main_loop_run(client->eventLoop);
|
||||
|
||||
+ /*
|
||||
+ * If virNetClientIOEventFD ran, this GSource will already be
|
||||
+ * destroyed due to G_SOURCE_REMOVE. It is harmless to re-destroy
|
||||
+ * it, since we still own a reference.
|
||||
+ *
|
||||
+ * If virNetClientIOWakeup ran, it will have interrupted the
|
||||
+ * g_main_loop_run call, before virNetClientIOEventFD could
|
||||
+ * run, and thus the GSource is still registered, and we need
|
||||
+ * to destroy it since it is referencing stack memory for 'data'
|
||||
+ */
|
||||
+ g_source_destroy(source);
|
||||
+
|
||||
#ifndef WIN32
|
||||
ignore_value(pthread_sigmask(SIG_SETMASK, &oldmask, NULL));
|
||||
#endif /* !WIN32 */
|
||||
--
|
||||
2.45.1
|
||||
|
||||
@@ -1,149 +0,0 @@
|
||||
From 092320f10b47bd6aca1f29278fcdc6b0efaf636a Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
||||
Date: Mon, 18 Mar 2019 10:58:48 +0000
|
||||
Subject: [PATCH 1/5] storage: split off code for calling rbd_list
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The rbd_list method has a quite unpleasant signature returning an
|
||||
array of strings in a single buffer instead of an array. It is
|
||||
being deprecated in favour of rbd_list2. To maintain clarity of
|
||||
code when supporting both APIs in parallel, split the rbd_list
|
||||
code out into a separate method.
|
||||
|
||||
In splitting this we now honour the rbd_list failures.
|
||||
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
(cherry picked from commit 28c8403ed07896d6d7e06d7726ed904027206719)
|
||||
---
|
||||
src/storage/storage_backend_rbd.c | 83 +++++++++++++++++++++----------
|
||||
1 file changed, 58 insertions(+), 25 deletions(-)
|
||||
|
||||
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
|
||||
index 2b7af1db23..0865163756 100644
|
||||
--- a/src/storage/storage_backend_rbd.c
|
||||
+++ b/src/storage/storage_backend_rbd.c
|
||||
@@ -565,19 +565,68 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
|
||||
return ret;
|
||||
}
|
||||
|
||||
+
|
||||
+static char **
|
||||
+virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr)
|
||||
+{
|
||||
+ char **names = NULL;
|
||||
+ size_t nnames = 0;
|
||||
+ int rc;
|
||||
+ size_t max_size = 1024;
|
||||
+ VIR_AUTOFREE(char *) namebuf = NULL;
|
||||
+ const char *name;
|
||||
+
|
||||
+ while (true) {
|
||||
+ if (VIR_ALLOC_N(namebuf, max_size) < 0)
|
||||
+ goto error;
|
||||
+
|
||||
+ rc = rbd_list(ptr->ioctx, namebuf, &max_size);
|
||||
+ if (rc >= 0)
|
||||
+ break;
|
||||
+ if (rc != -ERANGE) {
|
||||
+ virReportSystemError(-rc, "%s", _("Unable to list RBD images"));
|
||||
+ goto error;
|
||||
+ }
|
||||
+ VIR_FREE(namebuf);
|
||||
+ }
|
||||
+
|
||||
+ for (name = namebuf; name < namebuf + max_size;) {
|
||||
+ VIR_AUTOFREE(char *) namedup = NULL;
|
||||
+
|
||||
+ if (STREQ(name, ""))
|
||||
+ break;
|
||||
+
|
||||
+ if (VIR_STRDUP(namedup, name) < 0)
|
||||
+ goto error;
|
||||
+
|
||||
+ if (VIR_APPEND_ELEMENT(names, nnames, namedup) < 0)
|
||||
+ goto error;
|
||||
+
|
||||
+ name += strlen(name) + 1;
|
||||
+ }
|
||||
+
|
||||
+ if (VIR_EXPAND_N(names, nnames, 1) < 0)
|
||||
+ goto error;
|
||||
+
|
||||
+ return names;
|
||||
+
|
||||
+ error:
|
||||
+ virStringListFreeCount(names, nnames);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+
|
||||
static int
|
||||
virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
|
||||
{
|
||||
- size_t max_size = 1024;
|
||||
int ret = -1;
|
||||
- int len = -1;
|
||||
int r = 0;
|
||||
- char *name;
|
||||
virStoragePoolDefPtr def = virStoragePoolObjGetDef(pool);
|
||||
virStorageBackendRBDStatePtr ptr = NULL;
|
||||
struct rados_cluster_stat_t clusterstat;
|
||||
struct rados_pool_stat_t poolstat;
|
||||
- VIR_AUTOFREE(char *) names = NULL;
|
||||
+ char **names = NULL;
|
||||
+ size_t i;
|
||||
|
||||
if (!(ptr = virStorageBackendRBDNewState(pool)))
|
||||
goto cleanup;
|
||||
@@ -602,33 +651,16 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
|
||||
def->source.name, clusterstat.kb, clusterstat.kb_avail,
|
||||
poolstat.num_bytes);
|
||||
|
||||
- while (true) {
|
||||
- if (VIR_ALLOC_N(names, max_size) < 0)
|
||||
- goto cleanup;
|
||||
-
|
||||
- len = rbd_list(ptr->ioctx, names, &max_size);
|
||||
- if (len >= 0)
|
||||
- break;
|
||||
- if (len != -ERANGE) {
|
||||
- VIR_WARN("%s", "A problem occurred while listing RBD images");
|
||||
- goto cleanup;
|
||||
- }
|
||||
- VIR_FREE(names);
|
||||
- }
|
||||
+ if (!(names = virStorageBackendRBDGetVolNames(ptr)))
|
||||
+ goto cleanup;
|
||||
|
||||
- for (name = names; name < names + max_size;) {
|
||||
+ for (i = 0; names[i] != NULL; i++) {
|
||||
VIR_AUTOPTR(virStorageVolDef) vol = NULL;
|
||||
|
||||
- if (STREQ(name, ""))
|
||||
- break;
|
||||
-
|
||||
if (VIR_ALLOC(vol) < 0)
|
||||
goto cleanup;
|
||||
|
||||
- if (VIR_STRDUP(vol->name, name) < 0)
|
||||
- goto cleanup;
|
||||
-
|
||||
- name += strlen(name) + 1;
|
||||
+ VIR_STEAL_PTR(vol->name, names[i]);
|
||||
|
||||
r = volStorageBackendRBDRefreshVolInfo(vol, pool, ptr);
|
||||
|
||||
@@ -661,6 +693,7 @@ virStorageBackendRBDRefreshPool(virStoragePoolObjPtr pool)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
+ virStringListFree(names);
|
||||
virStorageBackendRBDFreeState(&ptr);
|
||||
return ret;
|
||||
}
|
||||
--
|
||||
2.20.1
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
From adfdb79f1e01401349e1321d0f5059d7b6489f00 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <adfdb79f1e01401349e1321d0f5059d7b6489f00.1724763718.git.crobinso@redhat.com>
|
||||
From: Martin Kletzander <mkletzan@redhat.com>
|
||||
Date: Fri, 16 Aug 2024 13:56:51 +0200
|
||||
Subject: [PATCH 1/3] virarptable: Properly calculate rtattr length
|
||||
Content-type: text/plain
|
||||
|
||||
Use convenience macro which does almost the same thing we were doing,
|
||||
but also pads out the payload length to a multiple of NLMSG_ALIGNTO (4)
|
||||
bytes.
|
||||
|
||||
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
||||
Reviewed-by: Laine Stump <laine@redhat.com>
|
||||
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
||||
---
|
||||
src/util/virarptable.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/util/virarptable.c b/src/util/virarptable.c
|
||||
index 299dddd664..d8e41c5a86 100644
|
||||
--- a/src/util/virarptable.c
|
||||
+++ b/src/util/virarptable.c
|
||||
@@ -102,8 +102,7 @@ virArpTableGet(void)
|
||||
return table;
|
||||
|
||||
VIR_WARNINGS_NO_CAST_ALIGN
|
||||
- parse_rtattr(tb, NDA_MAX, NDA_RTA(r),
|
||||
- nh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
|
||||
+ parse_rtattr(tb, NDA_MAX, NDA_RTA(r), NLMSG_PAYLOAD(nh, sizeof(*r)));
|
||||
VIR_WARNINGS_RESET
|
||||
|
||||
if (tb[NDA_DST] == NULL || tb[NDA_LLADDR] == NULL)
|
||||
--
|
||||
2.46.0
|
||||
|
||||
@@ -1,96 +0,0 @@
|
||||
From e8ec2592202387cca8e45cf15bd55ed5a952f3e3 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
||||
Date: Mon, 18 Mar 2019 11:11:38 +0000
|
||||
Subject: [PATCH 2/5] storage: add support for new rbd_list2 method
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The rbd_list method has been deprecated in Ceph >= 14.0.0
|
||||
in favour of the new rbd_list2 method which populates an
|
||||
array of structs.
|
||||
|
||||
Reviewed-by: Ján Tomko <jtomko@redhat.com>
|
||||
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
(cherry picked from commit 3aa190f2a43a632b542a6ba751a6c3ab4d51f1dd)
|
||||
---
|
||||
m4/virt-storage-rbd.m4 | 1 +
|
||||
src/storage/storage_backend_rbd.c | 43 +++++++++++++++++++++++++++++++
|
||||
2 files changed, 44 insertions(+)
|
||||
|
||||
diff --git a/m4/virt-storage-rbd.m4 b/m4/virt-storage-rbd.m4
|
||||
index 17e2115309..f3d9d04908 100644
|
||||
--- a/m4/virt-storage-rbd.m4
|
||||
+++ b/m4/virt-storage-rbd.m4
|
||||
@@ -33,6 +33,7 @@ AC_DEFUN([LIBVIRT_STORAGE_CHECK_RBD], [
|
||||
old_LIBS="$LIBS"
|
||||
LIBS="$LIBS $LIBRBD_LIBS"
|
||||
AC_CHECK_FUNCS([rbd_get_features],[],[LIBRBD_FOUND=no])
|
||||
+ AC_CHECK_FUNCS([rbd_list2])
|
||||
LIBS="$old_LIBS"
|
||||
fi
|
||||
|
||||
diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c
|
||||
index 0865163756..bfc3419f9c 100644
|
||||
--- a/src/storage/storage_backend_rbd.c
|
||||
+++ b/src/storage/storage_backend_rbd.c
|
||||
@@ -566,6 +566,48 @@ volStorageBackendRBDRefreshVolInfo(virStorageVolDefPtr vol,
|
||||
}
|
||||
|
||||
|
||||
+#ifdef HAVE_RBD_LIST2
|
||||
+static char **
|
||||
+virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr)
|
||||
+{
|
||||
+ char **names = NULL;
|
||||
+ size_t nnames = 0;
|
||||
+ int rc;
|
||||
+ rbd_image_spec_t *images = NULL;
|
||||
+ size_t nimages = 16;
|
||||
+ size_t i;
|
||||
+
|
||||
+ while (true) {
|
||||
+ if (VIR_ALLOC_N(images, nimages) < 0)
|
||||
+ goto error;
|
||||
+
|
||||
+ rc = rbd_list2(ptr->ioctx, images, &nimages);
|
||||
+ if (rc >= 0)
|
||||
+ break;
|
||||
+ if (rc != -ERANGE) {
|
||||
+ virReportSystemError(-rc, "%s", _("Unable to list RBD images"));
|
||||
+ goto error;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (VIR_ALLOC_N(names, nimages + 1) < 0)
|
||||
+ goto error;
|
||||
+ nnames = nimages;
|
||||
+
|
||||
+ for (i = 0; i < nimages; i++)
|
||||
+ VIR_STEAL_PTR(names[i], images->name);
|
||||
+
|
||||
+ return names;
|
||||
+
|
||||
+ error:
|
||||
+ virStringListFreeCount(names, nnames);
|
||||
+ rbd_image_spec_list_cleanup(images, nimages);
|
||||
+ VIR_FREE(images);
|
||||
+ return NULL;
|
||||
+}
|
||||
+
|
||||
+#else /* ! HAVE_RBD_LIST2 */
|
||||
+
|
||||
static char **
|
||||
virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr)
|
||||
{
|
||||
@@ -614,6 +656,7 @@ virStorageBackendRBDGetVolNames(virStorageBackendRBDStatePtr ptr)
|
||||
virStringListFreeCount(names, nnames);
|
||||
return NULL;
|
||||
}
|
||||
+#endif /* ! HAVE_RBD_LIST2 */
|
||||
|
||||
|
||||
static int
|
||||
--
|
||||
2.20.1
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
From 137779b894858bd958ea575cec260a0559b31e48 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <137779b894858bd958ea575cec260a0559b31e48.1724763718.git.crobinso@redhat.com>
|
||||
In-Reply-To: <adfdb79f1e01401349e1321d0f5059d7b6489f00.1724763718.git.crobinso@redhat.com>
|
||||
References: <adfdb79f1e01401349e1321d0f5059d7b6489f00.1724763718.git.crobinso@redhat.com>
|
||||
From: Martin Kletzander <mkletzan@redhat.com>
|
||||
Date: Fri, 16 Aug 2024 13:59:15 +0200
|
||||
Subject: [PATCH 2/3] virarptable: Fix check for message length
|
||||
Content-type: text/plain
|
||||
|
||||
The previous check was all wrong since it calculated the how long would
|
||||
the netlink message be if the netlink header was the payload and then
|
||||
subtracted that from the whole message length, a variable that was not
|
||||
used later in the code. This check can fail if there are no additional
|
||||
payloads, struct rtattr in particular, which we are parsing later,
|
||||
however the RTA_OK macro would've caught that anyway.
|
||||
|
||||
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
||||
Reviewed-by: Laine Stump <laine@redhat.com>
|
||||
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
||||
---
|
||||
src/util/virarptable.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/src/util/virarptable.c b/src/util/virarptable.c
|
||||
index d8e41c5a86..45ee76766f 100644
|
||||
--- a/src/util/virarptable.c
|
||||
+++ b/src/util/virarptable.c
|
||||
@@ -81,10 +81,9 @@ virArpTableGet(void)
|
||||
for (; NLMSG_OK(nh, msglen); nh = NLMSG_NEXT(nh, msglen)) {
|
||||
VIR_WARNINGS_RESET
|
||||
struct ndmsg *r = NLMSG_DATA(nh);
|
||||
- int len = nh->nlmsg_len;
|
||||
void *addr;
|
||||
|
||||
- if ((len -= NLMSG_LENGTH(sizeof(*nh))) < 0) {
|
||||
+ if (nh->nlmsg_len < NLMSG_SPACE(sizeof(*r))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("wrong nlmsg len"));
|
||||
goto cleanup;
|
||||
--
|
||||
2.46.0
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
From b990740b12117eaaf2797141a53a30b41f07c791 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
||||
Date: Mon, 18 Mar 2019 17:31:21 +0000
|
||||
Subject: [PATCH 3/5] network: improve error report when firewall chain
|
||||
creation fails
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
During startup we create some top level chains in which all
|
||||
virtual network firewall rules will be placed. The upfront
|
||||
creation is done to avoid slowing down creation of individual
|
||||
virtual networks by checking for chain existance every time.
|
||||
|
||||
There are some factors which can cause this upfront creation
|
||||
to fail and while a message will get into the libvirtd log
|
||||
this won't be seen by users who later try to start a virtual
|
||||
network. Instead they'll just get a message saying that the
|
||||
libvirt top level chain does not exist. This message is
|
||||
accurate, but unhelpful for solving the root cause.
|
||||
|
||||
This patch thus saves any error during daemon startup and
|
||||
reports it when trying to create a virtual network later.
|
||||
|
||||
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
|
||||
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
(cherry picked from commit 9f4e35dc73ec9e940aa61bc7c140c2b800218ef3)
|
||||
---
|
||||
src/network/bridge_driver.c | 3 +--
|
||||
src/network/bridge_driver_linux.c | 31 +++++++++++++++++++++-------
|
||||
src/network/bridge_driver_nop.c | 3 +--
|
||||
src/network/bridge_driver_platform.h | 2 +-
|
||||
4 files changed, 27 insertions(+), 12 deletions(-)
|
||||
|
||||
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
|
||||
index b3ca5b8a15..1da60f0a21 100644
|
||||
--- a/src/network/bridge_driver.c
|
||||
+++ b/src/network/bridge_driver.c
|
||||
@@ -2108,8 +2108,7 @@ static void
|
||||
networkReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup)
|
||||
{
|
||||
VIR_INFO("Reloading iptables rules");
|
||||
- if (networkPreReloadFirewallRules(startup) < 0)
|
||||
- return;
|
||||
+ networkPreReloadFirewallRules(startup);
|
||||
virNetworkObjListForEach(driver->networks,
|
||||
networkReloadFirewallRulesHelper,
|
||||
NULL);
|
||||
diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c
|
||||
index b10d0a6c4d..c899f4b6d0 100644
|
||||
--- a/src/network/bridge_driver_linux.c
|
||||
+++ b/src/network/bridge_driver_linux.c
|
||||
@@ -35,11 +35,25 @@ VIR_LOG_INIT("network.bridge_driver_linux");
|
||||
|
||||
#define PROC_NET_ROUTE "/proc/net/route"
|
||||
|
||||
-int networkPreReloadFirewallRules(bool startup)
|
||||
+static virErrorPtr errInit;
|
||||
+
|
||||
+void networkPreReloadFirewallRules(bool startup)
|
||||
{
|
||||
- int ret = iptablesSetupPrivateChains();
|
||||
- if (ret < 0)
|
||||
- return -1;
|
||||
+ int rc;
|
||||
+
|
||||
+ /* We create global rules upfront as we don't want
|
||||
+ * the perf hit of conditionally figuring out whether
|
||||
+ * to create them each time a network is started.
|
||||
+ *
|
||||
+ * Any errors here are saved to be reported at time
|
||||
+ * of starting the network though as that makes them
|
||||
+ * more likely to be seen by a human
|
||||
+ */
|
||||
+ rc = iptablesSetupPrivateChains();
|
||||
+ if (rc < 0) {
|
||||
+ errInit = virSaveLastError();
|
||||
+ virResetLastError();
|
||||
+ }
|
||||
|
||||
/*
|
||||
* If this is initial startup, and we just created the
|
||||
@@ -54,10 +68,8 @@ int networkPreReloadFirewallRules(bool startup)
|
||||
* rules will be present. Thus we can safely just tell it
|
||||
* to always delete from the builin chain
|
||||
*/
|
||||
- if (startup && ret == 1)
|
||||
+ if (startup && rc == 1)
|
||||
iptablesSetDeletePrivate(false);
|
||||
-
|
||||
- return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -671,6 +683,11 @@ int networkAddFirewallRules(virNetworkDefPtr def)
|
||||
virFirewallPtr fw = NULL;
|
||||
int ret = -1;
|
||||
|
||||
+ if (errInit) {
|
||||
+ virSetError(errInit);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
if (def->bridgeZone) {
|
||||
|
||||
/* if a firewalld zone has been specified, fail/log an error
|
||||
diff --git a/src/network/bridge_driver_nop.c b/src/network/bridge_driver_nop.c
|
||||
index a0e57012f9..ea9db338cb 100644
|
||||
--- a/src/network/bridge_driver_nop.c
|
||||
+++ b/src/network/bridge_driver_nop.c
|
||||
@@ -19,9 +19,8 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
-int networkPreReloadFirewallRules(bool startup ATTRIBUTE_UNUSED)
|
||||
+void networkPreReloadFirewallRules(bool startup ATTRIBUTE_UNUSED)
|
||||
{
|
||||
- return 0;
|
||||
}
|
||||
|
||||
|
||||
diff --git a/src/network/bridge_driver_platform.h b/src/network/bridge_driver_platform.h
|
||||
index baeb22bc3e..95fd64bdc7 100644
|
||||
--- a/src/network/bridge_driver_platform.h
|
||||
+++ b/src/network/bridge_driver_platform.h
|
||||
@@ -58,7 +58,7 @@ struct _virNetworkDriverState {
|
||||
typedef struct _virNetworkDriverState virNetworkDriverState;
|
||||
typedef virNetworkDriverState *virNetworkDriverStatePtr;
|
||||
|
||||
-int networkPreReloadFirewallRules(bool startup);
|
||||
+void networkPreReloadFirewallRules(bool startup);
|
||||
void networkPostReloadFirewallRules(bool startup);
|
||||
|
||||
int networkCheckRouteCollision(virNetworkDefPtr def);
|
||||
--
|
||||
2.20.1
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
From df2cefb31dab2fa56e0864fbd2b8ad468dee22c0 Mon Sep 17 00:00:00 2001
|
||||
Message-ID: <df2cefb31dab2fa56e0864fbd2b8ad468dee22c0.1724763718.git.crobinso@redhat.com>
|
||||
In-Reply-To: <adfdb79f1e01401349e1321d0f5059d7b6489f00.1724763718.git.crobinso@redhat.com>
|
||||
References: <adfdb79f1e01401349e1321d0f5059d7b6489f00.1724763718.git.crobinso@redhat.com>
|
||||
From: Martin Kletzander <mkletzan@redhat.com>
|
||||
Date: Fri, 16 Aug 2024 14:02:48 +0200
|
||||
Subject: [PATCH 3/3] virarptable: End parsing earlier in case of NLMSG_DONE
|
||||
Content-type: text/plain
|
||||
|
||||
Check for the last multipart message right as the first thing. The
|
||||
presumption probably was that the last message might still contain a
|
||||
payload we want to parse. However that cannot be true since that would
|
||||
have to be a type RTM_NEWNEIGH. This was not caught because older
|
||||
kernels were note sending NLMSG_DONE and probably relied on the fact
|
||||
that the parsing just stops after all the messages are walked through,
|
||||
which the NLMSG_OK macro successfully did.
|
||||
|
||||
Resolves: https://issues.redhat.com/browse/RHEL-52449
|
||||
Resolves: https://bugzilla.redhat.com/2302245
|
||||
Fixes: a176d67cdfaf5b8237a7e3a80d8be0e6bdf2d8fd
|
||||
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
|
||||
Reviewed-by: Laine Stump <laine@redhat.com>
|
||||
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
||||
---
|
||||
src/util/virarptable.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/src/util/virarptable.c b/src/util/virarptable.c
|
||||
index 45ee76766f..20d11f97b0 100644
|
||||
--- a/src/util/virarptable.c
|
||||
+++ b/src/util/virarptable.c
|
||||
@@ -83,6 +83,9 @@ virArpTableGet(void)
|
||||
struct ndmsg *r = NLMSG_DATA(nh);
|
||||
void *addr;
|
||||
|
||||
+ if (nh->nlmsg_type == NLMSG_DONE)
|
||||
+ break;
|
||||
+
|
||||
if (nh->nlmsg_len < NLMSG_SPACE(sizeof(*r))) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("wrong nlmsg len"));
|
||||
@@ -97,9 +100,6 @@ virArpTableGet(void)
|
||||
(!(r->ndm_state == NUD_STALE || r->ndm_state == NUD_REACHABLE)))
|
||||
continue;
|
||||
|
||||
- if (nh->nlmsg_type == NLMSG_DONE)
|
||||
- return table;
|
||||
-
|
||||
VIR_WARNINGS_NO_CAST_ALIGN
|
||||
parse_rtattr(tb, NDA_MAX, NDA_RTA(r), NLMSG_PAYLOAD(nh, sizeof(*r)));
|
||||
VIR_WARNINGS_RESET
|
||||
--
|
||||
2.46.0
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
From 095c45036615a84c7150ea801d6932bdde1d5b49 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
||||
Date: Mon, 18 Mar 2019 16:49:32 +0000
|
||||
Subject: [PATCH 4/5] network: split setup of ipv4 and ipv6 top level chains
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
During startup libvirtd creates top level chains for both ipv4
|
||||
and ipv6 protocols. If this fails for any reason then startup
|
||||
of virtual networks is blocked.
|
||||
|
||||
The default virtual network, however, only requires use of ipv4
|
||||
and some servers have ipv6 disabled so it is expected that ipv6
|
||||
chain creation will fail. There could equally be servers with
|
||||
no ipv4, only ipv6.
|
||||
|
||||
This patch thus makes error reporting a little more fine grained
|
||||
so that it works more sensibly when either ipv4 or ipv6 is
|
||||
disabled on the server. Only the protocols that are actually
|
||||
used by the virtual network have errors reported.
|
||||
|
||||
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
|
||||
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
(cherry picked from commit 686803a1a2e1e0641916b1c9e2c7e3910fe598d4)
|
||||
---
|
||||
src/network/bridge_driver_linux.c | 34 +++++++++++++++++++++++++------
|
||||
src/util/viriptables.c | 14 ++++---------
|
||||
src/util/viriptables.h | 2 +-
|
||||
3 files changed, 33 insertions(+), 17 deletions(-)
|
||||
|
||||
diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c
|
||||
index c899f4b6d0..50fc197134 100644
|
||||
--- a/src/network/bridge_driver_linux.c
|
||||
+++ b/src/network/bridge_driver_linux.c
|
||||
@@ -35,10 +35,12 @@ VIR_LOG_INIT("network.bridge_driver_linux");
|
||||
|
||||
#define PROC_NET_ROUTE "/proc/net/route"
|
||||
|
||||
-static virErrorPtr errInit;
|
||||
+static virErrorPtr errInitV4;
|
||||
+static virErrorPtr errInitV6;
|
||||
|
||||
void networkPreReloadFirewallRules(bool startup)
|
||||
{
|
||||
+ bool created = false;
|
||||
int rc;
|
||||
|
||||
/* We create global rules upfront as we don't want
|
||||
@@ -49,11 +51,21 @@ void networkPreReloadFirewallRules(bool startup)
|
||||
* of starting the network though as that makes them
|
||||
* more likely to be seen by a human
|
||||
*/
|
||||
- rc = iptablesSetupPrivateChains();
|
||||
+ rc = iptablesSetupPrivateChains(VIR_FIREWALL_LAYER_IPV4);
|
||||
if (rc < 0) {
|
||||
- errInit = virSaveLastError();
|
||||
+ errInitV4 = virSaveLastError();
|
||||
virResetLastError();
|
||||
}
|
||||
+ if (rc)
|
||||
+ created = true;
|
||||
+
|
||||
+ rc = iptablesSetupPrivateChains(VIR_FIREWALL_LAYER_IPV6);
|
||||
+ if (rc < 0) {
|
||||
+ errInitV6 = virSaveLastError();
|
||||
+ virResetLastError();
|
||||
+ }
|
||||
+ if (rc)
|
||||
+ created = true;
|
||||
|
||||
/*
|
||||
* If this is initial startup, and we just created the
|
||||
@@ -68,7 +80,7 @@ void networkPreReloadFirewallRules(bool startup)
|
||||
* rules will be present. Thus we can safely just tell it
|
||||
* to always delete from the builin chain
|
||||
*/
|
||||
- if (startup && rc == 1)
|
||||
+ if (startup && created)
|
||||
iptablesSetDeletePrivate(false);
|
||||
}
|
||||
|
||||
@@ -683,8 +695,18 @@ int networkAddFirewallRules(virNetworkDefPtr def)
|
||||
virFirewallPtr fw = NULL;
|
||||
int ret = -1;
|
||||
|
||||
- if (errInit) {
|
||||
- virSetError(errInit);
|
||||
+ if (errInitV4 &&
|
||||
+ (virNetworkDefGetIPByIndex(def, AF_INET, 0) ||
|
||||
+ virNetworkDefGetRouteByIndex(def, AF_INET, 0))) {
|
||||
+ virSetError(errInitV4);
|
||||
+ return -1;
|
||||
+ }
|
||||
+
|
||||
+ if (errInitV6 &&
|
||||
+ (virNetworkDefGetIPByIndex(def, AF_INET6, 0) ||
|
||||
+ virNetworkDefGetRouteByIndex(def, AF_INET6, 0) ||
|
||||
+ def->ipv6nogw)) {
|
||||
+ virSetError(errInitV6);
|
||||
return -1;
|
||||
}
|
||||
|
||||
diff --git a/src/util/viriptables.c b/src/util/viriptables.c
|
||||
index d67b640a3b..0e3c0ad73a 100644
|
||||
--- a/src/util/viriptables.c
|
||||
+++ b/src/util/viriptables.c
|
||||
@@ -127,7 +127,7 @@ iptablesPrivateChainCreate(virFirewallPtr fw,
|
||||
|
||||
|
||||
int
|
||||
-iptablesSetupPrivateChains(void)
|
||||
+iptablesSetupPrivateChains(virFirewallLayer layer)
|
||||
{
|
||||
virFirewallPtr fw = NULL;
|
||||
int ret = -1;
|
||||
@@ -143,17 +143,11 @@ iptablesSetupPrivateChains(void)
|
||||
};
|
||||
bool changed = false;
|
||||
iptablesGlobalChainData data[] = {
|
||||
- { VIR_FIREWALL_LAYER_IPV4, "filter",
|
||||
+ { layer, "filter",
|
||||
filter_chains, ARRAY_CARDINALITY(filter_chains), &changed },
|
||||
- { VIR_FIREWALL_LAYER_IPV4, "nat",
|
||||
+ { layer, "nat",
|
||||
natmangle_chains, ARRAY_CARDINALITY(natmangle_chains), &changed },
|
||||
- { VIR_FIREWALL_LAYER_IPV4, "mangle",
|
||||
- natmangle_chains, ARRAY_CARDINALITY(natmangle_chains), &changed },
|
||||
- { VIR_FIREWALL_LAYER_IPV6, "filter",
|
||||
- filter_chains, ARRAY_CARDINALITY(filter_chains), &changed },
|
||||
- { VIR_FIREWALL_LAYER_IPV6, "nat",
|
||||
- natmangle_chains, ARRAY_CARDINALITY(natmangle_chains), &changed },
|
||||
- { VIR_FIREWALL_LAYER_IPV6, "mangle",
|
||||
+ { layer, "mangle",
|
||||
natmangle_chains, ARRAY_CARDINALITY(natmangle_chains), &changed },
|
||||
};
|
||||
size_t i;
|
||||
diff --git a/src/util/viriptables.h b/src/util/viriptables.h
|
||||
index 903f390f89..e680407ec8 100644
|
||||
--- a/src/util/viriptables.h
|
||||
+++ b/src/util/viriptables.h
|
||||
@@ -24,7 +24,7 @@
|
||||
# include "virsocketaddr.h"
|
||||
# include "virfirewall.h"
|
||||
|
||||
-int iptablesSetupPrivateChains (void);
|
||||
+int iptablesSetupPrivateChains (virFirewallLayer layer);
|
||||
|
||||
void iptablesSetDeletePrivate (bool pvt);
|
||||
|
||||
--
|
||||
2.20.1
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
From 3e02ee9b5da7fc7197aaa6d57563349a7670b8a1 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
|
||||
Date: Wed, 13 Mar 2019 16:21:15 +0000
|
||||
Subject: [PATCH 5/5] network: avoid trying to create global firewall rules if
|
||||
unprivileged
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
The unprivileged libvirtd does not have permission to create firewall
|
||||
rules, or bridge devices, or do anything to the host network in
|
||||
general. Historically we still activate the network driver though and
|
||||
let the network start API call fail.
|
||||
|
||||
The startup code path which reloads firewall rules on active networks
|
||||
would thus effectively be a no-op when unprivileged as it is impossible
|
||||
for there to be any active networks
|
||||
|
||||
With the change to use a global set of firewall chains, however, we now
|
||||
have code that is run unconditionally.
|
||||
|
||||
Ideally we would not register the network driver at all when
|
||||
unprivileged, but the entanglement with the virt drivers currently makes
|
||||
that impractical. As a temporary hack, we just make the firewall reload
|
||||
into a no-op.
|
||||
|
||||
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
|
||||
(cherry picked from commit 5d010c3df6152cf5fb00f1f67d22151241f4a8a2)
|
||||
---
|
||||
src/network/bridge_driver.c | 4 ++++
|
||||
1 file changed, 4 insertions(+)
|
||||
|
||||
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
|
||||
index 1da60f0a21..0e1d5efd8e 100644
|
||||
--- a/src/network/bridge_driver.c
|
||||
+++ b/src/network/bridge_driver.c
|
||||
@@ -2108,6 +2108,10 @@ static void
|
||||
networkReloadFirewallRules(virNetworkDriverStatePtr driver, bool startup)
|
||||
{
|
||||
VIR_INFO("Reloading iptables rules");
|
||||
+ /* Ideally we'd not even register the driver when unprivilegd
|
||||
+ * but until we untangle the virt driver that's not viable */
|
||||
+ if (!driver->privileged)
|
||||
+ return;
|
||||
networkPreReloadFirewallRules(startup);
|
||||
virNetworkObjListForEach(driver->networks,
|
||||
networkReloadFirewallRulesHelper,
|
||||
--
|
||||
2.20.1
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# Makefile for source rpm: libvirt
|
||||
# $Id$
|
||||
NAME := libvirt
|
||||
SPECFILE = $(firstword $(wildcard *.spec))
|
||||
|
||||
define find-makefile-common
|
||||
for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$d/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(find-makefile-common))
|
||||
|
||||
ifeq ($(MAKEFILE_COMMON),)
|
||||
# attempt a checkout
|
||||
define checkout-makefile-common
|
||||
test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2
|
||||
endef
|
||||
|
||||
MAKEFILE_COMMON := $(shell $(checkout-makefile-common))
|
||||
endif
|
||||
|
||||
include $(MAKEFILE_COMMON)
|
||||
@@ -0,0 +1,31 @@
|
||||
From 4c5b2e1e0d0d0cbbf8c6ed28ce77d055d5974f7f Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?J=C3=A1n=20Tomko?= <jtomko@redhat.com>
|
||||
Date: Wed, 6 Mar 2024 17:26:40 +0100
|
||||
Subject: [PATCH] qemu: virtiofs: set correct label when creating the socket
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
Use svirt_t instead of virtd_t, since virtd_t is not available in the
|
||||
session mode and qemu with svirt_t won't be able to talk to unconfined_t
|
||||
socket.
|
||||
|
||||
Signed-off-by: Ján Tomko <jtomko@redhat.com>
|
||||
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
|
||||
---
|
||||
src/qemu/qemu_virtiofs.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/qemu/qemu_virtiofs.c b/src/qemu/qemu_virtiofs.c
|
||||
index 15dea3bb57f..d80cddd3ba9 100644
|
||||
--- a/src/qemu/qemu_virtiofs.c
|
||||
+++ b/src/qemu/qemu_virtiofs.c
|
||||
@@ -102,7 +102,7 @@ qemuVirtioFSOpenChardev(virQEMUDriver *driver,
|
||||
chrdev->data.nix.listen = true;
|
||||
chrdev->data.nix.path = g_strdup(socket_path);
|
||||
|
||||
- if (qemuSecuritySetDaemonSocketLabel(driver->securityManager, vm->def) < 0)
|
||||
+ if (qemuSecuritySetSocketLabel(driver->securityManager, vm->def) < 0)
|
||||
goto cleanup;
|
||||
fd = qemuOpenChrChardevUNIXSocket(chrdev);
|
||||
if (fd < 0) {
|
||||
+1773
-939
File diff suppressed because it is too large
Load Diff
@@ -1 +1 @@
|
||||
SHA512 (libvirt-5.1.0.tar.xz) = ca64d7be683614bdeb20a8865655fe80f911cf13c00aed2334db3a2e4131e1dd6fe5e9663a24e6f82161ad5aa53f1a2637cd21730eed46e4764b7eebced94f3f
|
||||
SHA512 (libvirt-10.1.0.tar.xz) = 08e73ae15de5681430b62db85ec9901242dca5e9a4ca9685614f4a67092c6e28f27f9187144b3ceb18ad6b40e6eb1a90b1a4b056b0888724d04a62002ee2bc48
|
||||
|
||||
Reference in New Issue
Block a user