]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pid1: check for kernels older than baseline
authorLennart Poettering <lennart@poettering.net>
Wed, 30 Mar 2022 08:46:16 +0000 (10:46 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Thu, 31 Mar 2022 21:11:20 +0000 (22:11 +0100)
Let's make this detectable explicitly.

src/basic/def.h
src/core/main.c
src/core/manager.c

index ffd462c456f1412b6ff04e0dd468538bd793a371..54a82c7c49a2501df438f5cf49df2797aa863334 100644 (file)
@@ -73,3 +73,5 @@
 #define VARLINK_ADDR_PATH_MANAGED_OOM_SYSTEM "/run/systemd/io.system.ManagedOOM"
 /* Path where systemd-oomd listens for varlink connections from user managers to report changes in ManagedOOM settings. */
 #define VARLINK_ADDR_PATH_MANAGED_OOM_USER "/run/systemd/oom/io.system.ManagedOOM"
+
+#define KERNEL_BASELINE_VERSION "3.15"
index f39c7b0e3782a7a5129b35b308d23378856263d0..6567cdfb280111cf41c3ab432da2ee3114db920c 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/oom.h>
 #include <sys/mount.h>
 #include <sys/prctl.h>
+#include <sys/utsname.h>
 #include <unistd.h>
 #if HAVE_SECCOMP
 #include <seccomp.h>
@@ -2009,6 +2010,7 @@ static void log_execution_mode(bool *ret_first_boot) {
         assert(ret_first_boot);
 
         if (arg_system) {
+                struct utsname uts;
                 int v;
 
                 log_info("systemd " GIT_VERSION " running in %ssystem mode (%s)",
@@ -2046,6 +2048,14 @@ static void log_execution_mode(bool *ret_first_boot) {
                                 log_debug("Detected initialized system, this is not the first boot.");
                         }
                 }
+
+                assert(uname(&uts) >= 0);
+
+                if (strverscmp_improved(uts.release, KERNEL_BASELINE_VERSION) < 0)
+                        log_warning("Warning! Reported kernel version %s is older than systemd's required baseline kernel version %s. "
+                                    "Your mileage may vary.", uts.release, KERNEL_BASELINE_VERSION);
+                else
+                        log_debug("Kernel version %s, our baseline is %s", uts.release, KERNEL_BASELINE_VERSION);
         } else {
                 if (DEBUG_LOGGING) {
                         _cleanup_free_ char *t = NULL;
index 4493103298e125790cd02291a56cc3a2e45e9508..768977dc3a7a41ceaeb9117e4539035a605b6986 100644 (file)
@@ -8,6 +8,7 @@
 #include <sys/ioctl.h>
 #include <sys/reboot.h>
 #include <sys/timerfd.h>
+#include <sys/utsname.h>
 #include <sys/wait.h>
 #include <unistd.h>
 
@@ -4351,6 +4352,7 @@ int manager_dispatch_user_lookup_fd(sd_event_source *source, int fd, uint32_t re
 
 char *manager_taint_string(Manager *m) {
         _cleanup_free_ char *destination = NULL, *overflowuid = NULL, *overflowgid = NULL;
+        struct utsname uts;
         char *buf, *e;
         int r;
 
@@ -4367,7 +4369,8 @@ char *manager_taint_string(Manager *m) {
                                "local-hwclock:"
                                "var-run-bad:"
                                "overflowuid-not-65534:"
-                               "overflowgid-not-65534:"));
+                               "overflowgid-not-65534:"
+                               "old-kernel:"));
         if (!buf)
                 return NULL;
 
@@ -4398,6 +4401,10 @@ char *manager_taint_string(Manager *m) {
         if (r >= 0 && !streq(overflowgid, "65534"))
                 e = stpcpy(e, "overflowgid-not-65534:");
 
+        assert_se(uname(&uts) >= 0);
+        if (strverscmp_improved(uts.release, KERNEL_BASELINE_VERSION) < 0)
+                e = stpcpy(e, "old-kernel:");
+
         /* remove the last ':' */
         if (e != buf)
                 e[-1] = 0;