1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-03 01:17:45 +03:00

pid1: fix segv triggered by status query (#26279)

If any query makes it to the end of install_info_follow() then I think symlink_target is set to NULL.
If that is followed by -EXDEV from unit_file_load_or_readlink(), then that causes basename(NULL)
which segfaults pid 1.

This is triggered by eg. "systemctl status crond" in RHEL9 if

/etc/systemd/system/crond.service
  -> /ram/etc/systemd/system/crond.service
  -> /usr/lib/systemd/system/.crond.service.blah.blah
  -> /usr/lib/systemd/system/crond.service

(cherry picked from commit 19cfda9fc3)
(cherry picked from commit 015b0ca928)
(cherry picked from commit 9a906fae89)
This commit is contained in:
Robin Humble 2023-02-01 23:36:48 +11:00 committed by Luca Boccassi
parent 8523187071
commit a2dc9e3be9

View File

@ -1607,7 +1607,7 @@ static int install_info_traverse(
} }
r = install_info_follow(c, i, paths->root_dir, flags, false); r = install_info_follow(c, i, paths->root_dir, flags, false);
if (r == -EXDEV) { if (r == -EXDEV && i->symlink_target) {
_cleanup_free_ char *buffer = NULL; _cleanup_free_ char *buffer = NULL;
const char *bn; const char *bn;