slackware-current/source/l/polkit/CVE-2021-4115.patch
Patrick J Volkerding 026e3d5682 Sat Mar 12 20:57:35 UTC 2022
a/kernel-generic-5.16.14-x86_64-1.txz:  Upgraded.
a/kernel-huge-5.16.14-x86_64-1.txz:  Upgraded.
a/kernel-modules-5.16.14-x86_64-1.txz:  Upgraded.
ap/qpdf-10.6.3-x86_64-1.txz:  Upgraded.
ap/sqlite-3.38.1-x86_64-1.txz:  Upgraded.
d/kernel-headers-5.16.14-x86-1.txz:  Upgraded.
k/kernel-source-5.16.14-noarch-1.txz:  Upgraded.
l/harfbuzz-4.0.1-x86_64-1.txz:  Upgraded.
l/librsvg-2.52.7-x86_64-1.txz:  Upgraded.
l/polkit-0.120-x86_64-3.txz:  Rebuilt.
  Patched to fix a security issue where an unprivileged user could cause a
  denial of service due to process file descriptor exhaustion.
  Thanks to marav.
  For more information, see:
    https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-4115
  (* Security fix *)
xap/NetworkManager-openvpn-1.8.18-x86_64-1.txz:  Upgraded.
xap/xlockmore-5.69-x86_64-1.txz:  Upgraded.
xfce/xfce4-screenshooter-1.9.10-x86_64-1.txz:  Upgraded.
isolinux/initrd.img:  Rebuilt.
kernels/*:  Upgraded.
usb-and-pxe-installers/usbboot.img:  Rebuilt.
2022-03-13 06:59:45 +01:00

71 lines
2 KiB
Diff

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;