From: Phillip Lougher Date: Fri, 23 Apr 2010 17:18:11 +0000 (-0400) Subject: initramfs: handle unrecognised decompressor when unpacking X-Git-Tag: firefly_0821_release~10186^2~1659 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=46cdf2a8b9d5b105f609469e0caf9dc2336d7e22;p=firefly-linux-kernel-4.4.55.git initramfs: handle unrecognised decompressor when unpacking commit df37bd156dcb4f5441beaf5bde444adac974e9a0 upstream. The unpack routine fails to handle the decompress_method() returning unrecognised decompressor (compress_name == NULL). This results in the routine looping eventually oopsing on an out of bounds memory access. Note this bug is usually hidden, only triggering on trailing junk after one or more correct compressed blocks. The case of the compressed archive being complete junk is (by accident?) caught by the if (state != Reset) check because state is initialised to Start, but not updated due to the decompressor not having been called. Obviously if the junk is trailing a correctly decompressed buffer, state == Reset from the previous call to the decompressor. Signed-off-by: Phillip Lougher Reported-by: Aaro Koskinen Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/init/initramfs.c b/init/initramfs.c index 4c00edc59689..1fd59b81dd9a 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -455,7 +455,8 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len) compress_name); message = msg_buf; } - } + } else + error("junk in compressed archive"); if (state != Reset) error("junk in compressed archive"); this_header = saved_offset + my_inptr;