From 9ebf20c78ef750047ed66020f61a8b350fd5e6dd Mon Sep 17 00:00:00 2001 From: baiguo Date: Tue, 2 Apr 2024 14:13:17 +0800 Subject: [PATCH 1/3] fix potential segfault and leaking error in bd_lvm_init --- ...ult-and-leaking-error-in-bd_lvm_init.patch | 50 +++++++++++++++++++ libblockdev.spec | 9 +++- 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 0001-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch diff --git a/0001-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch b/0001-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch new file mode 100644 index 0000000..2d0900c --- /dev/null +++ b/0001-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch @@ -0,0 +1,50 @@ +From 72a65429ce31a2b66eaa1140e029ff8de89c0275 Mon Sep 17 00:00:00 2001 +From: vtrefny vtrefny@redhat.com +Date: Tue, 2 Apr 2024 13:56:27 +0800 +Subject: [PATCH] Fix potential segfault in bd_lvm_init + +--- + src/plugins/lvm-dbus.c | 12 +++++++++--- + 1 file changed, 9 insertions(+), 3 deletions(-) + +diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c +index e822bd6..8042945 100644 +--- a/src/plugins/lvm-dbus.c ++++ b/src/plugins/lvm-dbus.c +@@ -257,7 +257,7 @@ static gboolean setup_dbus_connection (GError **error) { + + addr = g_dbus_address_get_for_bus_sync (G_BUS_TYPE_SYSTEM, NULL, error); + if (!addr) { +- bd_utils_log_format (BD_UTILS_LOG_CRIT, "Failed to get system bus address: %s\n", (*error)->message); ++ g_prefix_error (error, "Failed to get system bus address: "); + return FALSE; + } + +@@ -267,9 +267,14 @@ static gboolean setup_dbus_connection (GError **error) { + NULL, NULL, error); + + g_free (addr); ++ if (!bus) { ++ g_prefix_error (error, "Failed to create a new connection for the system bus: "); ++ return FALSE; ++ } + +- if (!bus || g_dbus_connection_is_closed (bus)) { +- bd_utils_log_format (BD_UTILS_LOG_CRIT, "Failed to create a new connection for the system bus: %s\n", (*error)->message); ++ if (g_dbus_connection_is_closed (bus)) { ++ g_set_error (error, BD_LVM_ERROR, BD_LVM_ERROR_FAIL, ++ "Connection is closed"); + return FALSE; + } + +@@ -337,6 +342,7 @@ gboolean bd_lvm_init (void) { + completely rely on it */ + if (G_UNLIKELY (!bus) && !setup_dbus_connection (&error)) { + bd_utils_log_format (BD_UTILS_LOG_CRIT, "Failed to setup DBus connection: %s", error->message); ++ g_clear_error (&error); + return FALSE; + } + +-- +2.27.0 + diff --git a/libblockdev.spec b/libblockdev.spec index b22d55d..3dc7276 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -3,11 +3,12 @@ Name: libblockdev Version: 3.0.4 -Release: 3 +Release: 4 Summary: libblockdev is a C library supporting GObject introspection for manipulation of block devices License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-1/%{name}-%{version}.tar.gz +Patch1: 0001-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch BuildRequires: make glib2-devel libyaml-devel libbytesize-devel parted-devel libuuid-devel ndctl-devel device-mapper-devel BuildRequires: device-mapper-devel systemd-devel nss-devel volume_key-devel >= 0.3.9-7 libblkid-devel libmount-devel @@ -157,6 +158,12 @@ find %{buildroot} -type f -name "*.la" | xargs %{__rm} %changelog +* Tue Apr 2 2024 baiguo - 3.0.4-4 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: fix potential segfault and leaking error in bd_lvm_init + * Fri Mar 29 2024 sunhai - 3.0.4-3 - Type:bugfix - ID:NA -- Gitee From f094d82dca2b815132149c1c91127c5dcde298e2 Mon Sep 17 00:00:00 2001 From: baiguo Date: Sun, 7 Apr 2024 15:37:43 +0800 Subject: [PATCH 2/3] fix potential segfault and leaking error in bd_lvm_init --- ...ix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch | 0 libblockdev.spec | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename 0001-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch => 0002-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch (100%) diff --git a/0001-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch b/0002-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch similarity index 100% rename from 0001-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch rename to 0002-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch diff --git a/libblockdev.spec b/libblockdev.spec index bf48a4c..6bb21d8 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -8,7 +8,7 @@ Summary: libblockdev is a C library supporting GObject introspection for manipul License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-1/%{name}-%{version}.tar.gz -Patch1: 0001-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch +Patch2: 0002-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch Patch1: 0001-Add-BDPluginSpec-constructor-and-use-it-in-plugin_sp.patch -- Gitee From 059f4f36f37ba2fb04e32fd8776de4ae984922b5 Mon Sep 17 00:00:00 2001 From: baiguo Date: Sun, 7 Apr 2024 09:26:29 +0000 Subject: [PATCH 3/3] update libblockdev.spec. Signed-off-by: baiguo --- libblockdev.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libblockdev.spec b/libblockdev.spec index 6bb21d8..2eb1fc1 100644 --- a/libblockdev.spec +++ b/libblockdev.spec @@ -8,9 +8,9 @@ Summary: libblockdev is a C library supporting GObject introspection for manipul License: LGPLv2+ URL: https://github.com/storaged-project/libblockdev Source0: https://github.com/storaged-project/libblockdev/releases/download/%{version}-1/%{name}-%{version}.tar.gz -Patch2: 0002-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch Patch1: 0001-Add-BDPluginSpec-constructor-and-use-it-in-plugin_sp.patch +Patch2: 0002-fix-potential-segfault-and-leaking-error-in-bd_lvm_init.patch BuildRequires: make glib2-devel libyaml-devel libbytesize-devel parted-devel libuuid-devel ndctl-devel device-mapper-devel BuildRequires: device-mapper-devel systemd-devel nss-devel volume_key-devel >= 0.3.9-7 libblkid-devel libmount-devel -- Gitee