core: Pass NULL error in dump_impl()

If mac_selinux_access_check() or bus_verify_bypass_dump_ratelimit_async()
fail, we goto "ratelimited" where we set a custom D-BUS error. In
"ratelimited", we call sd_bus_error_setf() which eventually hits an
assert_return(!bus_error_is_dirty()). Avoid hitting this assertion by
passing NULL as the error to mac_selinux_access_check() and
bus_verify_bypass_dump_ratelimit_async() since we will override the error
immediately anyway if either fails.

We modify both functions as well to allow passing a NULL error and fix
the argument name as well while we're at it.
This commit is contained in:
Daan De Meyer
2024-04-29 14:14:40 +02:00
committed by Luca Boccassi
parent 7d7a3c3535
commit ba4c69a0c6
4 changed files with 6 additions and 8 deletions
+2 -2
View File
@@ -1405,11 +1405,11 @@ static int dump_impl(
* operations, and can cause PID1 to stall. So it seems similar enough in terms of security
* considerations and impact, and thus use the same access check for dumps which, given the
* large amount of data to fetch, can stall PID1 for quite some time. */
r = mac_selinux_access_check(message, "reload", error);
r = mac_selinux_access_check(message, "reload", /* error = */ NULL);
if (r < 0)
goto ratelimited;
r = bus_verify_bypass_dump_ratelimit_async(m, message, error);
r = bus_verify_bypass_dump_ratelimit_async(m, message, /* error = */ NULL);
if (r < 0)
goto ratelimited;
if (r == 0)
-1
View File
@@ -193,7 +193,6 @@ int mac_selinux_access_check_internal(
assert(message);
assert(permission);
assert(function);
assert(error);
r = access_init(error);
if (r <= 0)