mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
lib: validate in-memory LZ4 chunk length
We found and validated an issue in lib/decompress_unlz4.c. The bug is
reachable by a root user through kexec_file_load() with a crafted external
initrd.
unlz4() reads the compressed chunk length from an in-memory initrd and
passes it to LZ4_decompress_safe(). It only checks the chunk length
against the allocation size when the input is filled by a callback.
Reject an in-memory chunk that extends past the remaining input before
calling the LZ4 decoder. This prevents malformed initrds from making
the decoder read past the mapped archive.
Link: https://lore.kernel.org/59c6555c27aa7ba18ee227f9f02c78d15a37605f.1789219453.git.zhilinz@nebusec.ai
Fixes: e76e1fdfa8 ("lib: add support for LZ4-compressed kernel")
Signed-off-by: Zhiling Zou <zhilinz@nebusec.ai>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: VEGA <vega@nebusec.ai>
Assisted-by: LLM
Cc: Kyungsik Lee <kyungsik.lee@lge.com>
This commit is contained in:
parent
0f2cd84858
commit
138a84817d
|
|
@ -139,6 +139,10 @@ STATIC inline int INIT unlz4(u8 *input, long in_len,
|
|||
if (!fill) {
|
||||
inp += 4;
|
||||
size -= 4;
|
||||
if (chunksize > size) {
|
||||
error("data corrupted");
|
||||
goto exit_2;
|
||||
}
|
||||
} else {
|
||||
if (chunksize > LZ4_compressBound(uncomp_chunksize)) {
|
||||
error("chunk length is longer than allocated");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user