Commit 353748a3 authored by Silvio Cesare's avatar Silvio Cesare Committed by Kees Cook
Browse files

UBIFS: Fix potential integer overflow in allocation

There is potential for the size and len fields in ubifs_data_node to be
too large causing either a negative value for the length fields or an
integer overflow leading to an incorrect memory allocation. Likewise,
when the len field is small, an integer underflow may occur.

Signed-off-by: default avatarSilvio Cesare <>
Fixes: 1e51764a

 ("UBIFS: add new flash file system")
Signed-off-by: default avatarKees Cook <>
parent f3278e3f
......@@ -1282,10 +1282,11 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
int *new_len)
void *buf;
int err, dlen, compr_type, out_len, old_dlen;
int err, compr_type;
u32 dlen, out_len, old_dlen;
out_len = le32_to_cpu(dn->size);
buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);
buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS);
if (!buf)
return -ENOMEM;
Supports Markdown
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