]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core: Pass NULL error in dump_impl()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 28 Apr 2024 17:42:51 +0000 (19:42 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Mon, 29 Apr 2024 12:14:40 +0000 (14:14 +0200)
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.

src/core/dbus-manager.c
src/core/selinux-access.c
src/shared/bus-polkit.c
src/shared/bus-polkit.h

index 7a969ce6c1564421312f8766a3ccf54e77fab106..70aecc8edeff5a7a74462b5b6a55abe90046b129 100644 (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)
index 1214bd8f22f30c0e73a217b8016c3ee9b12869ca..8ce2d4e5a54f0fc71708bd49cd892d612b65f7fb 100644 (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)
index c0752b59bb0c596926d30a53663369a2c716c49e..0382d0b798b77a5f254fce8f954924b8f6dae58a 100644 (file)
@@ -529,14 +529,13 @@ int bus_verify_polkit_async_full(
                 uid_t good_user,
                 PolkitFlags flags,
                 Hashmap **registry,
-                sd_bus_error *ret_error) {
+                sd_bus_error *error) {
 
         int r;
 
         assert(call);
         assert(action);
         assert(registry);
-        assert(ret_error);
 
         log_debug("Trying to acquire polkit authentication for '%s'.", action);
 
@@ -551,7 +550,7 @@ int bus_verify_polkit_async_full(
         /* This is a repeated invocation of this function, hence let's check if we've already got
          * a response from polkit for this action */
         if (q) {
-                r = async_polkit_query_check_action(q, action, details, flags, ret_error);
+                r = async_polkit_query_check_action(q, action, details, flags, error);
                 if (r != 0) {
                         log_debug("Found matching previous polkit authentication for '%s'.", action);
                         return r;
index 15c621dfa3252e09aa23c65f27780caca6ae21c4..f3741b28229d58289f02251cf60e15ae7ea134b1 100644 (file)
@@ -16,8 +16,8 @@ typedef enum PolkitFLags {
 int bus_test_polkit(sd_bus_message *call, const char *action, const char **details, uid_t good_user, bool *_challenge, sd_bus_error *e);
 
 int bus_verify_polkit_async_full(sd_bus_message *call, const char *action, const char **details, uid_t good_user, PolkitFlags flags, Hashmap **registry, sd_bus_error *error);
-static inline int bus_verify_polkit_async(sd_bus_message *call, const char *action, const char **details, Hashmap **registry, sd_bus_error *ret_error) {
-        return bus_verify_polkit_async_full(call, action, details, UID_INVALID, 0, registry, ret_error);
+static inline int bus_verify_polkit_async(sd_bus_message *call, const char *action, const char **details, Hashmap **registry, sd_bus_error *error) {
+        return bus_verify_polkit_async_full(call, action, details, UID_INVALID, 0, registry, error);
 }
 
 int varlink_verify_polkit_async_full(Varlink *link, sd_bus *bus, const char *action, const char **details, uid_t good_user, PolkitFlags flags, Hashmap **registry);