Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
polkit
polkit
Commits
41cb093f
Commit
41cb093f
authored
Feb 21, 2022
by
Jan Rybar
Browse files
CVE-2021-4115 (GHSL-2021-077) fix
parent
a6bedfd0
Pipeline
#514523
passed with stage
in 6 minutes and 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/polkit/polkitsystembusname.c
View file @
41cb093f
...
...
@@ -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
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment