[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 11 Nov 2018 19:49:05 +0000
From: Ben Hutchings <ben@...adent.org.uk>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
CC: akpm@...ux-foundation.org,
"Silvio Cesare" <silvio.cesare@...il.com>,
"Kees Cook" <keescook@...omium.org>
Subject: [PATCH 3.16 134/366] UBIFS: Fix potential integer overflow in
allocation
3.16.61-rc1 review patch. If anyone has any objections, please let me know.
------------------
From: Silvio Cesare <silvio.cesare@...il.com>
commit 353748a359f1821ee934afc579cf04572406b420 upstream.
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@...il.com>
Fixes: 1e51764a3c2ac ("UBIFS: add new flash file system")
Signed-off-by: Kees Cook <keescook@...omium.org>
[bwh: Backported to 3.16: We have a different set of length variables in
recomp_data_node()]
Signed-off-by: Ben Hutchings <ben@...adent.org.uk>
---
fs/ubifs/journal.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/fs/ubifs/journal.c
+++ b/fs/ubifs/journal.c
@@ -1099,10 +1099,11 @@ out_free:
static int recomp_data_node(struct ubifs_data_node *dn, int *new_len)
{
void *buf;
- int err, len, compr_type, out_len;
+ int err, compr_type;
+ u32 len, out_len;
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;
Powered by blists - more mailing lists