]> git.ipfire.org Git - thirdparty/systemd.git/commit
core: Serialize both pid and pidfd
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 5 Apr 2024 13:21:49 +0000 (15:21 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 10 Apr 2024 07:32:04 +0000 (09:32 +0200)
commit7072777163bef1877d65dce07e0914cf57c6ea38
tree5873f6d7295b7d0b3bee417d645b0d891cca33da
parent11a150bc43d08e4d1e1622aca696770c59bda03c
core: Serialize both pid and pidfd

If we try to deserialize only a pidfd that points to a process that
has been reaped, creating the pidref object will fail, which means that
we'll try to create a pidref object from the serialized pid that comes
next. If the pid has already been reused, this will succeed and we'll
now have a pidref that points to a different process.

Let's avoid this issue by serializing both the pidfd and the pid and
creating the pidref object directly from both. This means we'll reuse
the deserialized pidfd instead of opening a new one. We'll then immediately
notice the pidfd is dead and do the appropriate follow up depending on
the unit type.
src/core/scope.c
src/core/service.c
src/shared/serialize.c