lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.DEB.1.10.1004032332520.22263@loser>
Date:	Sat, 3 Apr 2010 23:41:18 +0300 (EEST)
From:	Aaro Koskinen <aaro.koskinen@....fi>
To:	Andrew Morton <akpm@...ux-foundation.org>
cc:	Aaro Koskinen <aaro.koskinen@....fi>, linux-kernel@...r.kernel.org,
	hsweeten@...ionengravers.com, hpa@...or.com,
	eric.piel@...mplin-utc.net, stable <stable@...nel.org>
Subject: Re: [PATCH] initramfs: prevent buffer overflow when unpacking to
 rootfs

On Fri, 2 Apr 2010, Andrew Morton wrote:
> On Thu,  1 Apr 2010 12:45:46 +0300
> Aaro Koskinen <aaro.koskinen@....fi> wrote:
>
>> Garbage in the initrd memory area may result in the unpack routine
>> accessing memory outside the buffer. The patch adds a check that the
>> specified area size is not exceeded.
>>
>> Signed-off-by: Aaro Koskinen <aaro.koskinen@....fi>
>> Cc: stable <stable@...nel.org>
>> ---
>>
>> The patch prevents the following kernel panic on Amstrad E3:
>>
>> 	Unpacking initramfs...
>> 	Unable to handle kernel paging request at virtual address c20121a7
>>
>> ...
>>
>> --- a/init/initramfs.c
>> +++ b/init/initramfs.c
>> @@ -460,6 +460,8 @@ static char * __init unpack_to_rootfs(char *buf, unsigned len)
>>  		}
>>  		if (state != Reset)
>>  			error("junk in compressed archive");
>> +		if (my_inptr >= len)
>> +			break;
>>  		this_header = saved_offset + my_inptr;
>>  		buf += my_inptr;
>>  		len -= my_inptr;
>
> OK, so if I'm understanding this right, the call to
>
> 	decompress(buf, len, NULL, flush_buffer, NULL, &my_inptr, error);
>
> has gone and generated more output data than it was asked to generate?
>
> If so, isn't that a bug in the decompressor?  Which one is your system using?

The decompressor is gzip, and it returned correct buffer position.

The problem was that the loop in unpack_to_rootfs() continued
to process the remaining buffer. my_inptr was never again updated
(decompress_method() did not recognize the remaining garbage data, so
there was no further calls to decompressor). The loop kept subtracting
my_inptr from len eventually exceeding it. Perhaps there should be some
better logic to give up earlier.

A.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ