9
0
Fork 0
barebox/lib
Stefan Müller-Klieser 115bfd0009 lzo: check for length overrun in variable length encoding.
This corresponds to kernel commit 72cf90124e87d975d0b

This fix ensures that we never meet an integer overflow while adding
255 while parsing a variable length encoding. It works differently from
commit 206a81c ("lzo: properly check for overruns") because instead of
ensuring that we don't overrun the input, which is tricky to guarantee
due to many assumptions in the code, it simply checks that the cumulated
number of 255 read cannot overflow by bounding this number.

The MAX_255_COUNT is the maximum number of times we can add 255 to a base
count without overflowing an integer. The multiply will overflow when
multiplying 255 by more than MAXINT/255. The sum will overflow earlier
depending on the base count. Since the base count is taken from a u8
and a few bits, it is safe to assume that it will always be lower than
or equal to 2*255, thus we can always prevent any overflow by accepting
two less 255 steps.

This patch also reduces the CPU overhead and actually increases performance
by 1.1% compared to the initial code, while the previous fix costs 3.1%
(measured on x86_64).

The fix needs to be backported to all currently supported stable kernels.

Reported-by: Willem Pinckaers <willem@lekkertech.net>
Cc: "Don A. Bailey" <donb@securitymouse.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Stefan Müller-Klieser <s.mueller-klieser@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-03-25 09:47:51 +01:00
..
bootstrap sizes.h: move include/sizes.h to include/linux/sizes.h 2015-01-08 14:00:26 +01:00
gui graphic_utils: set_pixel only write 16bit in 16bit mode 2015-01-05 11:36:40 +01:00
lz4 lz4: fix another possible overrun 2014-07-02 08:19:45 +02:00
lzo lzo: check for length overrun in variable length encoding. 2015-03-25 09:47:51 +01:00
xz Add xz decompression support 2014-11-04 12:18:55 +01:00
zlib_inflate Unused files removed 2012-06-30 22:09:49 +02:00
Kconfig xymodem: select CRC16 from lib 2014-11-12 09:22:22 +01:00
Makefile lib: Add hex2bin and bin2hex implementations 2015-03-13 08:22:27 +01:00
bcd.c lib: import 'bcd' from linux-3.15 2014-07-31 07:30:51 +02:00
bch.c lib: add BCH encoding/decoding 2012-01-02 12:34:58 +01:00
bitmap.c lib: Add bitmap functions from kernel 2014-07-17 23:01:15 +02:00
bitrev.c lib: add bitrev utility 2012-01-02 12:34:58 +01:00
bzlib_private.h svn_rev_639 2007-07-05 18:02:12 +02:00
cmdlinepart.c cmndlinepart: skip devname if partstr already contains it 2015-02-12 09:33:44 +01:00
ctype.c Treewide: remove address of the Free Software Foundation 2012-09-17 10:57:41 +02:00
decompress_bunzip2.c lib: decompress: remove redundant INT_MAX define 2015-01-21 14:58:07 +01:00
decompress_inflate.c Add deflate_decompress function 2013-08-07 08:44:48 +02:00
decompress_unlz4.c pbl: add lz4 support 2013-07-22 09:15:32 +02:00
decompress_unlzo.c lzo: Remove unused variable 2014-04-23 14:00:25 +02:00
decompress_unxz.c lib: decompress_xz: fix function header to match prototype 2014-11-24 14:04:11 +01:00
display_options.c treewide: fix signedness mixups in printf format specifiers 2014-04-23 09:05:51 +02:00
div64.c svn_rev_639 2007-07-05 18:02:12 +02:00
find_next_bit.c U-Boot-V2:Bitops: asm-generic bitops 2008-08-15 08:47:49 +02:00
fnmatch.c fnmatch:sparse fixes 2010-10-21 22:21:22 +02:00
gcd.c lib: Add gcd() function 2015-03-05 09:11:33 +01:00
getopt.c getopt: change optstring to const char* 2013-02-11 20:57:34 +01:00
glob.c glob: fix GLOB_SORT 2012-08-03 08:29:38 +02:00
hexdump.c lib: Add hex2bin and bin2hex implementations 2015-03-13 08:22:27 +01:00
kfifo.c lib: fix whitespace, drop blank lines at EOF 2014-01-06 09:24:22 +01:00
libbb.c move file helper functions to separate file 2014-08-07 06:13:51 +02:00
libfile.c libfile: Add copy_recursive 2014-11-06 10:58:55 +01:00
libgen.c Treewide: remove address of the Free Software Foundation 2012-09-17 10:57:41 +02:00
libmtd.c mtd: Update internal API to support 64-bit device size 2014-03-12 21:26:37 +01:00
libscan.c libubi: Use global mtd_all_ff function 2013-03-04 10:54:46 +01:00
libubigen.c lib: libubigen math compile error fix 2014-01-06 10:58:00 +01:00
make_directory.c Make errno a positive value 2012-05-14 08:35:54 +02:00
math.c lib: math: Return NULL pointer 2014-02-24 08:59:04 +01:00
misc.c lib: Add hex2bin and bin2hex implementations 2015-03-13 08:22:27 +01:00
notifier.c lib: fix whitespace, drop blank lines at EOF 2014-01-06 09:24:22 +01:00
parameter.c param: add error check to __dev_add_param() 2015-02-02 11:46:31 +01:00
process_escape_sequence.c lib: fix whitespace, drop blank lines at EOF 2014-01-06 09:24:22 +01:00
qsort.c qsort: Fix wrong check 2012-08-03 08:28:18 +02:00
random.c UBI: reimport UBI from Linux v3.10 2013-07-25 10:24:16 +02:00
rbtree.c Treewide: remove address of the Free Software Foundation 2012-09-17 10:57:41 +02:00
readkey.c readkey: keys are unsigned char 2014-07-11 08:14:52 +02:00
readline.c readline: Fix history prev when history is empty 2014-09-01 14:24:50 +02:00
readline_simple.c remove undefined WATCHDOG_RESET 2011-12-19 14:38:21 +01:00
recursive_action.c rm: implement -r 2012-11-29 20:21:29 +01:00
show_progress.c lib: fix whitespace, drop blank lines at EOF 2014-01-06 09:24:22 +01:00
stmp-device.c ARM: MXS: introduce stmp device support 2013-07-23 16:25:13 +02:00
string.c string.c: Fix include 2014-03-29 06:49:47 +01:00
stringlist.c stringlist: the string argument should be const 2014-12-04 08:24:05 +01:00
strtox.c printf: move simple_strto*() functions to separate file 2015-01-05 11:30:58 +01:00
uncompress.c Add xz decompression support 2014-11-04 12:18:55 +01:00
unlink-recursive.c unlink_recursive: return negative error value 2014-04-09 09:36:34 +02:00
vsprintf.c Add PBL console support 2015-01-05 11:30:59 +01:00
wchar.c lib: add wchar strdup 2014-12-09 09:59:10 +01:00
xfuncs.c string: Add (x)memdup 2013-11-27 10:42:54 +01:00
xymodem.c xymodem.c: fix compiler warning 2012-11-26 08:56:25 +01:00