From 5bfc2cd3661368a60aee65c2add11f36a982d336e365aa54d9ea4c6914e1bfe1 Mon Sep 17 00:00:00 2001 From: Marcus Meissner Date: Tue, 22 Feb 2022 10:49:38 +0000 Subject: [PATCH] - Fixed denial of service via file descriptor leak (bsc#1195542 CVE-2021-4115) 0001-CVE-2021-4115-GHSL-2021-077-fix.patch OBS-URL: https://build.opensuse.org/package/show/Base:System/polkit?expand=0&rev=169 --- 0001-CVE-2021-4115-GHSL-2021-077-fix.patch | 83 ++++++++++++++++++++++ polkit.changes | 6 ++ polkit.spec | 2 + 3 files changed, 91 insertions(+) create mode 100644 0001-CVE-2021-4115-GHSL-2021-077-fix.patch diff --git a/0001-CVE-2021-4115-GHSL-2021-077-fix.patch b/0001-CVE-2021-4115-GHSL-2021-077-fix.patch new file mode 100644 index 0000000..0ddf67b --- /dev/null +++ b/0001-CVE-2021-4115-GHSL-2021-077-fix.patch @@ -0,0 +1,83 @@ +From 41cb093f554da8772362654a128a84dd8a5542a7 Mon Sep 17 00:00:00 2001 +From: Jan Rybar +Date: Mon, 21 Feb 2022 08:29:05 +0000 +Subject: [PATCH] CVE-2021-4115 (GHSL-2021-077) fix + +--- + src/polkit/polkitsystembusname.c | 38 ++++++++++++++++++++++++++++---- + 1 file changed, 34 insertions(+), 4 deletions(-) + +diff --git a/src/polkit/polkitsystembusname.c b/src/polkit/polkitsystembusname.c +index 8ed1363..2fbf5f1 100644 +--- a/src/polkit/polkitsystembusname.c ++++ b/src/polkit/polkitsystembusname.c +@@ -62,6 +62,10 @@ enum + PROP_NAME, + }; + ++ ++guint8 dbus_call_respond_fails; // has to be global because of callback ++ ++ + static void subject_iface_init (PolkitSubjectIface *subject_iface); + + G_DEFINE_TYPE_WITH_CODE (PolkitSystemBusName, polkit_system_bus_name, G_TYPE_OBJECT, +@@ -364,6 +368,7 @@ on_retrieved_unix_uid_pid (GObject *src, + if (!v) + { + data->caught_error = TRUE; ++ dbus_call_respond_fails += 1; + } + else + { +@@ -405,6 +410,8 @@ polkit_system_bus_name_get_creds_sync (PolkitSystemBusName *system_bus + tmp_context = g_main_context_new (); + g_main_context_push_thread_default (tmp_context); + ++ dbus_call_respond_fails = 0; ++ + /* Do two async calls as it's basically as fast as one sync call. + */ + g_dbus_connection_call (connection, +@@ -432,11 +439,34 @@ polkit_system_bus_name_get_creds_sync (PolkitSystemBusName *system_bus + on_retrieved_unix_uid_pid, + &data); + +- while (!((data.retrieved_uid && data.retrieved_pid) || data.caught_error)) +- g_main_context_iteration (tmp_context, TRUE); ++ while (TRUE) ++ { ++ /* If one dbus call returns error, we must wait until the other call ++ * calls _call_finish(), otherwise fd leak is possible. ++ * Resolves: GHSL-2021-077 ++ */ + +- if (data.caught_error) +- goto out; ++ if ( (dbus_call_respond_fails > 1) ) ++ { ++ // we got two faults, we can leave ++ goto out; ++ } ++ ++ if ((data.caught_error && (data.retrieved_pid || data.retrieved_uid))) ++ { ++ // we got one fault and the other call finally finished, we can leave ++ goto out; ++ } ++ ++ if ( !(data.retrieved_uid && data.retrieved_pid) ) ++ { ++ g_main_context_iteration (tmp_context, TRUE); ++ } ++ else ++ { ++ break; ++ } ++ } + + if (out_uid) + *out_uid = data.uid; +-- +2.26.2 + diff --git a/polkit.changes b/polkit.changes index c3a6558..4940094 100644 --- a/polkit.changes +++ b/polkit.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Tue Feb 22 10:48:15 UTC 2022 - Marcus Meissner + +- Fixed denial of service via file descriptor leak (bsc#1195542 CVE-2021-4115) + 0001-CVE-2021-4115-GHSL-2021-077-fix.patch + ------------------------------------------------------------------- Wed Jan 26 11:44:35 UTC 2022 - Fabian Vogt diff --git a/polkit.spec b/polkit.spec index 9271ffb..1f4a288 100644 --- a/polkit.spec +++ b/polkit.spec @@ -42,6 +42,8 @@ Patch4: polkit-adjust-libexec-path.patch Patch5: CVE-2021-4034-pkexec-fix.patch # PATCH-FIX-UPSTREAM https://gitlab.freedesktop.org/polkit/polkit/-/commit/c7fc4e1b61f0fd82fc697c19c604af7e9fb291a2.patch, without .gitlab-ci.yml (not in the tarball) Patch6: duktape-support.patch +# PATCH-FIX-UPSTREAM 0001-CVE-2021-4115-GHSL-2021-077-fix.patch meissner@ -- bsc#1195542 VUL-0: CVE-2021-4115: polkit: denial of service via file descriptor leak +Patch7: 0001-CVE-2021-4115-GHSL-2021-077-fix.patch BuildRequires: gcc-c++ BuildRequires: gtk-doc BuildRequires: intltool