Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2994336imm; Sun, 1 Jul 2018 09:56:16 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcpMvjNVqSoiiuXwG1SIB7NWNDEUTahPq9qcAffoLlTayGye3+wJJDef12rjoJa5ztERI8J X-Received: by 2002:a62:675b:: with SMTP id b88-v6mr18109753pfc.24.1530464176138; Sun, 01 Jul 2018 09:56:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530464176; cv=none; d=google.com; s=arc-20160816; b=gtMc3VBxD4RHz6aPCXL9ijTYSBlLix1E6FMCiRTL5rVt48kLsakaYbNacIpMTbIc0j /KXQSdoHtSXSCmvPqkg07/SUDDQ0XeBXj8U7H2JcooYAucFU9UP8skyLu/c48M7iLhSz /hspqEle2QzERm6aBiU3QkSxUYkS9FxGfMJiv1ZGxiMHFR4uMT7IGH5pGB5PQ2zzN2Bw 2HQGREehrJS1Xv0PQCh8EFWrEn0gE0GK5c/aAAkZQXDjcjaPtXs/gIiVtiO8cmpkaDd5 dGNCVufsF1T7t1DuR5gQ3p26h3ggnYR0Mv0jT/ijZd1+/7/0ea1eq0VGMaVfGtmqaEia AaeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=zKp1th/OX+tJNaXklNo6A4f4qXeHG0ztSewCwrnE9GE=; b=mWu/XYJKL/Kij110MhUOU1T0sfPLfvCb3bP2Dp8ioYA2AuUvDnKEAtkt7n+g2CXJyR Dw4eaOLeiagKg8pCBWIIe/uKMliEK3w1ZLVWE9KlHJXxnGnRlzed+v4UTedHWBe5rjcI 4ZAn//OVPy8FJn7MUsPKngY2zqaUWN4BauZ7Nk+DQk5l65tYbx/+ObZh+b38TmJc8pQW dZkA6eVWb/aJ0RyzLXVou9r66K4vMTWHNYNGp2Qxx6bFhf5HypgkD4b+RP6FbKxVlsuX g9YzZPsVFE1zebQwGfZoob7X9H8VUYFvQzxn0jUH5FzxTGjgX5imgp/hQjgI7knsORr9 zn0w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a23-v6si13665803plm.305.2018.07.01.09.56.01; Sun, 01 Jul 2018 09:56:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934097AbeGAQpV (ORCPT + 99 others); Sun, 1 Jul 2018 12:45:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38184 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933644AbeGAQpO (ORCPT ); Sun, 1 Jul 2018 12:45:14 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1D19DACC; Sun, 1 Jul 2018 16:45:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Silvio Cesare , Kees Cook Subject: [PATCH 4.17 154/220] UBIFS: Fix potential integer overflow in allocation Date: Sun, 1 Jul 2018 18:22:58 +0200 Message-Id: <20180701160914.723817814@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180701160908.272447118@linuxfoundation.org> References: <20180701160908.272447118@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Silvio Cesare 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 Fixes: 1e51764a3c2ac ("UBIFS: add new flash file system") Cc: stable@vger.kernel.org Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- fs/ubifs/journal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c @@ -1283,10 +1283,11 @@ static int truncate_data_node(const stru 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;