Package: klibc-utils Version: 2.0.6-1 Severity: normal Dear Maintainer,
The check_for_modules() function in the fstype utility does not correctly match compressed kernel modules, which can result in a failure to mount an ext4 root file system from the initramfs. Booting a debian 10 ext4 root with a vanilla 4.19.60 kernel built with CONFIG_MODULE_COMPRESS=y, CONFIG_MODULE_COMPRESS_XZ=y, and CONFIG_EXT4_FS=m, the initramfs will fail to mount the ext4 root file system: Begin: Running /scripts/init-premount ... done. Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done. Begin: Running /scripts/local-premount ... done. Begin: Will now check root file system ... fsck from util-linux 2.33.1 [/sbin/fsck.ext4 (1) -- /dev/vda1] fsck.ext4 -a -C0 /dev/vda1 /dev/vda1: clean, 112319/524288 files, 736358/2096640 blocks done. mount: mounting /dev/vda1 on /root failed: No such device Failed to mount /dev/vda1 as root file system. This is due to the klibc's fstype utility failing to match the compressed ext4 module: (initramfs) /usr/bin/fstype /dev/vda1 FSTYPE=ext4dev <---------------------- here (should be 'ext4') FSSIZE=8587837440 This results in the ext4 module not being loaded, and the mount failure. You can manually load the driver, mount the file system, and continue the boot. (initramfs) modinfo ext4 filename: /lib/modules/4.19.60/kernel/fs/ext4/ext4.ko.xz author: Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others description: Fourth Extended Filesystem license: GPL alias: fs-ext4 alias: ext3 alias: fs-ext3 alias: ext2 alias: fs-ext2 depends: mbcache,jbd2 intree: Y vermagic: 4.19.60 SMP mod_unload (initramfs) lsmod | grep ext4 (initramfs) modprobe ext4 (initramfs) lsmod | grep ext4 ext4 634880 0 mbcache 16384 1 ext4 jbd2 102400 1 ext4 (initramfs) mount /dev/vda1 /root [ 115.810557] EXT4-fs (vda1): mounted filesystem with ordered data mode. Opts: (null) (initramfs) exit Attached patch resolves it for me. -- System Information: Debian Release: 10.0 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 4.19.60 (SMP w/4 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) Versions of packages klibc-utils depends on: ii libklibc 2.0.6-1 klibc-utils recommends no packages. klibc-utils suggests no packages. -- no debconf information
From 3512325b51eccef3a16a4a610b3bc825ef5c77c3 Mon Sep 17 00:00:00 2001 From: Greg Edwards <gedwa...@ddn.com> Date: Tue, 23 Jul 2019 13:57:56 -0600 Subject: [PATCH] [klibc] fstype: match compressed kernel modules check_for_modules() does not correctly match compressed modules, e.g. ext4.ko.xz. Instead of comparing the end of the string to ".ko", search for the ".ko" substring, and truncate it there if we find a match. Signed-off-by: Greg Edwards <gedwa...@ddn.com> --- usr/kinit/fstype/fstype.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/usr/kinit/fstype/fstype.c b/usr/kinit/fstype/fstype.c index c5a143286919..885b44fc2f9f 100644 --- a/usr/kinit/fstype/fstype.c +++ b/usr/kinit/fstype/fstype.c @@ -160,7 +160,6 @@ static int check_for_modules(const char *fs_name) struct utsname uts; FILE *f; char buf[1024], *cp, *t; - int i; if (uname(&uts)) return 0; @@ -178,12 +177,9 @@ static int check_for_modules(const char *fs_name) if (cp == NULL) continue; cp++; - i = strlen(cp); - if (i > 3) { - t = cp + i - 3; - if (!strcmp(t, ".ko")) - *t = 0; - } + t = strstr(cp, ".ko"); + if (t) + *t = 0; if (!strcmp(cp, fs_name)) { fclose(f); return 1; -- 2.21.0