diff options
author | Silvio Cesare <silvio.cesare@gmail.com> | 2018-05-04 06:44:02 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-03 12:24:59 +0300 |
commit | b7261fc5f5748b3f6f1a839dbc5a744b8871dfcd (patch) | |
tree | 1e1ec8d6f4bc32c243ad123af8c018054dcce57f /fs/ubifs | |
parent | a23cf10d9abb04652ec2daf93d494dc0e2cd835f (diff) | |
download | linux-b7261fc5f5748b3f6f1a839dbc5a744b8871dfcd.tar.xz |
UBIFS: Fix potential integer overflow in allocation
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@gmail.com>
Fixes: 1e51764a3c2ac ("UBIFS: add new flash file system")
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ubifs')
-rw-r--r-- | fs/ubifs/journal.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index 04c4ec6483e5..8ae1cd8611cc 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c @@ -1283,10 +1283,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; |