Commit 46cdf2a8 authored by Phillip Lougher's avatar Phillip Lougher Committed by Greg Kroah-Hartman

initramfs: handle unrecognised decompressor when unpacking

commit df37bd15 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: default avatarPhillip Lougher <phillip@lougher.demon.co.uk>
Reported-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent dc1429f8
...@@ -455,7 +455,8 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len) ...@@ -455,7 +455,8 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len)
compress_name); compress_name);
message = msg_buf; message = msg_buf;
} }
} } else
error("junk in compressed archive");
if (state != Reset) if (state != Reset)
error("junk in compressed archive"); error("junk in compressed archive");
this_header = saved_offset + my_inptr; this_header = saved_offset + my_inptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment