Skip to contentSkip to conversation

+ init-do_mounts_rdc-fix-null-pointer-dereference-while-loading-initramfs.patch added to -mm tree

PATCH [email protected] 1 participant 1 message Oct 9, 2013 VFS

lore
Share & tools
lore
#0 lore raw

Subject: + init-do_mounts_rdc-fix-null-pointer-dereference-while-loading-initramfs.patch added to -mm tree
To: [email protected]
From: [email protected]
Date: Wed, 09 Oct 2013 14:48:57 -0700

The patch titled
Subject: init/do_mounts_rd.c: fix NULL pointer dereference while loading initramfs
has been added to the -mm tree. Its filename is
init-do_mounts_rdc-fix-null-pointer-dereference-while-loading-initramfs.patch

This patch should soon appear at
http://ozlabs.org/~akpm/mmots/broken-out/init-do_mounts_rdc-fix-null-pointer-dereference-while-loading-initramfs.patch
and later at
http://ozlabs.org/~akpm/mmotm/broken-out/init-do_mounts_rdc-fix-null-pointer-dereference-while-loading-initramfs.patch

Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/SubmitChecklist when testing your code ***

The -mm tree is included into linux-next and is updated there every 3-4 working days

------------------------------------------------------
From: P J P <[email protected]>
Subject: init/do_mounts_rd.c: fix NULL pointer dereference while loading initramfs

Make menuconfig allows one to choose compression format of an initial ramdisk image. But this choice does not result in duly compressed initial ramdisk image. Because - $ make install - does not pass on the selected compression choice to the dracut(8) tool, which creates the initramfs file. dracut(8) generates the image with the default compression, ie. gzip(1).

If a user chose any other compression instead of gzip(1), it leads to a crash due to NULL pointer dereference in crd_load(), caused by a NULL function pointer returned by the 'decompress_method()' routine. Because the initramfs image is gzip(1) compressed, whereas the kernel knows only to decompress the chosen format and not gzip(1).

This patch replaces the crash by an explicit panic() call with an appropriate error message. This shall prevent the kernel from eventually panicking in: init/do_mounts.c: mount_block_root() with
-> panic("VFS: Unable to mount root fs on %s", b);

---

 init/do_mounts_rd.c |    7 +++++++
 1 file changed, 7 insertions(+)
init/do_mounts_rd.c renamed from init/do_mounts_rd.c~init-do_mounts_rdc-fix-null-pointer-dereference-while-loading-initramfs +7 -0
diff -puN init/do_mounts_rd.c~init-do_mounts_rdc-fix-null-pointer-dereference-while-loading-initramfs init/do_mounts_rd.c
@@ -342,6 +342,13 @@ static int __init crd_load(int in_fd, in
 	int result;
 	crd_infd = in_fd;
 	crd_outfd = out_fd;
+
+	if (!deco) {
+		pr_emerg("Invalid decompression routine: %p; "
+				 "Select appropriate config option.\n", deco);
+		panic("Could not decompress initial ramdisk image.");
+	}
+
 	result = deco(NULL, 0, compr_fill, compr_flush, NULL, NULL, error);
 	if (decompress_error)
 		result = 1;

_

Patches currently in -mm which might be from [email protected] are

init-do_mounts_rdc-fix-null-pointer-dereference-while-loading-initramfs.patch init-do_mounts_rdc-fix-null-pointer-dereference-while-loading-initramfs-fix.patch