]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.18.114/ubifs-fix-potential-integer-overflow-in-allocation.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.18.114 / ubifs-fix-potential-integer-overflow-in-allocation.patch
CommitLineData
0ea29e54
GKH
1From 353748a359f1821ee934afc579cf04572406b420 Mon Sep 17 00:00:00 2001
2From: Silvio Cesare <silvio.cesare@gmail.com>
3Date: Fri, 4 May 2018 13:44:02 +1000
4Subject: UBIFS: Fix potential integer overflow in allocation
5
6From: Silvio Cesare <silvio.cesare@gmail.com>
7
8commit 353748a359f1821ee934afc579cf04572406b420 upstream.
9
10There is potential for the size and len fields in ubifs_data_node to be
11too large causing either a negative value for the length fields or an
12integer overflow leading to an incorrect memory allocation. Likewise,
13when the len field is small, an integer underflow may occur.
14
15Signed-off-by: Silvio Cesare <silvio.cesare@gmail.com>
16Fixes: 1e51764a3c2ac ("UBIFS: add new flash file system")
17Cc: stable@vger.kernel.org
18Signed-off-by: Kees Cook <keescook@chromium.org>
19Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21---
22 fs/ubifs/journal.c | 2 +-
23 1 file changed, 1 insertion(+), 1 deletion(-)
24
25--- a/fs/ubifs/journal.c
26+++ b/fs/ubifs/journal.c
27@@ -1101,7 +1101,7 @@ static int recomp_data_node(struct ubifs
28 int err, len, compr_type, out_len;
29
30 out_len = le32_to_cpu(dn->size);
31- buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);
32+ buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS);
33 if (!buf)
34 return -ENOMEM;
35