]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: verify pidfd after parsing data in usermode helper
authorLuca Boccassi <luca.boccassi@gmail.com>
Fri, 11 Apr 2025 13:44:30 +0000 (14:44 +0100)
committerLuca Boccassi <luca.boccassi@gmail.com>
Sun, 13 Apr 2025 09:18:58 +0000 (10:18 +0100)
Ensure the pidfd is still valid before continuing

Follow-up for 313537da6ffdea4049873571202679734d49f0a1

src/coredump/coredump.c

index a207086d816f734ac6f222062d68a5285a609d98..defc809c974125155b9ff190132fa44f84408d27 100644 (file)
@@ -1463,6 +1463,11 @@ static int gather_pid_metadata_from_procfs(struct iovec_wrapper *iovw, Context *
         if (get_process_environ(pid, &t) >= 0)
                 (void) iovw_put_string_field_free(iovw, "COREDUMP_ENVIRON=", t);
 
+        /* Now that we have parsed info from /proc/ ensure the pidfd is still valid before continuing */
+        r = pidref_verify(&context->pidref);
+        if (r < 0)
+                return log_error_errno(r, "PIDFD validation failed: %m");
+
         /* we successfully acquired all metadata */
         return context_parse_iovw(context, iovw);
 }