aboutsummaryrefslogtreecommitdiffstats
path: root/init/do_mounts_rd.c
diff options
context:
space:
mode:
authorP J P <prasad@redhat.com>2013-11-12 18:10:20 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 22:09:26 -0500
commitdf3ef3af503e131f7848652af8be21747fd57419 (patch)
tree10c1b49f46fe082814593a00b08151d58177e4c0 /init/do_mounts_rd.c
parent65321547c8be5b00427ac8de23fd15801b68de1f (diff)
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); [akpm@linux-foundation.org: mention that the problem is with the ramdisk, don't print known-to-be-NULL value] Signed-off-by: P J P <prasad@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'init/do_mounts_rd.c')
-rw-r--r--init/do_mounts_rd.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/init/do_mounts_rd.c b/init/do_mounts_rd.c
index 6be2879cca66..143e98de6f29 100644
--- a/init/do_mounts_rd.c
+++ b/init/do_mounts_rd.c
@@ -342,6 +342,13 @@ static int __init crd_load(int in_fd, int out_fd, decompress_fn deco)
342 int result; 342 int result;
343 crd_infd = in_fd; 343 crd_infd = in_fd;
344 crd_outfd = out_fd; 344 crd_outfd = out_fd;
345
346 if (!deco) {
347 pr_emerg("Invalid ramdisk decompression routine. "
348 "Select appropriate config option.\n");
349 panic("Could not decompress initial ramdisk image.");
350 }
351
345 result = deco(NULL, 0, compr_fill, compr_flush, NULL, NULL, error); 352 result = deco(NULL, 0, compr_fill, compr_flush, NULL, NULL, error);
346 if (decompress_error) 353 if (decompress_error)
347 result = 1; 354 result = 1;