]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: try to reload selinux label database less frequently
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 12 Mar 2022 19:45:08 +0000 (04:45 +0900)
committerLennart Poettering <lennart@poettering.net>
Thu, 24 Mar 2022 15:20:42 +0000 (16:20 +0100)
Previously, `event_run()` was called repeatedly in one `event_queue_start()`
invocation. Hence, the SELinux label database is reloaded many times needlessly.
Other settings, e.g. udev rules or hwdata, are tried to be reloaded in the
beginning of `event_queue_start()`. Let's also do so for the SELinux database.

src/udev/udevd.c

index 8c690357b8d373a262c80351d4b3c533151501de..1e90b94f5c7da0f317f2effae16bc782fded4b41 100644 (file)
@@ -760,10 +760,6 @@ static int event_run(Event *event) {
         /* Re-enable the debug message for the next batch of events */
         log_children_max_reached = true;
 
-        /* fork with up-to-date SELinux label database, so the child inherits the up-to-date db
-         * and, until the next SELinux policy changes, we safe further reloads in future children */
-        mac_selinux_maybe_reload();
-
         /* start new worker and pass initial device */
         r = worker_spawn(manager, event);
         if (r < 0)
@@ -945,6 +941,10 @@ static int event_queue_start(Manager *manager) {
                         return log_warning_errno(r, "Failed to read udev rules: %m");
         }
 
+        /* fork with up-to-date SELinux label database, so the child inherits the up-to-date db
+         * and, until the next SELinux policy changes, we safe further reloads in future children */
+        mac_selinux_maybe_reload();
+
         LIST_FOREACH(event, event, manager->events) {
                 if (event->state != EVENT_QUEUED)
                         continue;