]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
UBIFS: Fix potential integer overflow in allocation
authorSilvio Cesare <silvio.cesare@gmail.com>
Fri, 4 May 2018 03:44:02 +0000 (13:44 +1000)
committerKees Cook <keescook@chromium.org>
Tue, 12 Jun 2018 23:19:22 +0000 (16:19 -0700)
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: Silvio Cesare <silvio.cesare@gmail.com>
Fixes: 1e51764a3c2ac ("UBIFS: add new flash file system")
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
fs/ubifs/journal.c

index da8afdfccaa64daa357dfc969c50d341783efab5..07b4956e042522e684e3dec9b36909fd46c83f83 100644 (file)
@@ -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;