]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev,sysupdated: fix pidfd leak
authorMike Yuan <me@yhndnzj.com>
Thu, 1 Jan 2026 19:10:45 +0000 (20:10 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 1 Jan 2026 22:59:15 +0000 (07:59 +0900)
Follow-up for 179dcf924f7d0ac9398f54baeb39b47abd23aeaf

After the mentioned commit, event_add_child_pidref() duplicates
the pidfd internally, hence the original pidfd would be leaked
with TAKE_PIDREF.

src/sysupdate/sysupdated.c
src/udev/udev-watch.c

index a9740ee85423729b48750ac863dff44cef8c1677..4eeaf3a706213b33159c5181099d490ca740c83b 100644 (file)
@@ -543,7 +543,7 @@ static int job_start(Job *j) {
         r = sd_event_source_set_child_process_own(j->child, true);
         if (r < 0)
                 return log_error_errno(r, "Event loop failed to take ownership of child process: %m");
-        TAKE_PIDREF(pid);
+        pidref_done(&pid); /* disarm sigkill_wait */
 
         j->stdout_fd = TAKE_FD(stdout_fd);
 
index 76de67733f45888a20fb72a5f63445e32f2964ae..10cbc848460dbba5c531179e0c582c04b1d2d0e8 100644 (file)
@@ -208,11 +208,6 @@ static int synthesize_change(Manager *manager, sd_device *dev) {
                 return 0;
         }
 
-        r = sd_event_source_set_child_pidfd_own(s, true);
-        if (r < 0)
-                return r;
-        TAKE_PIDREF(pidref);
-
         r = set_ensure_put(&manager->synthesize_change_child_event_sources, &event_source_hash_ops, s);
         if (r < 0)
                 return r;