Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp30291imm; Fri, 21 Sep 2018 17:26:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV62S/PvNKwIb9WT195gphvkZSiwCpF8kKLLRCcYoeBBhap6MYPMRg1BzPFNC5CxLgBs/W1t2 X-Received: by 2002:a63:6054:: with SMTP id u81-v6mr141894pgb.74.1537575999524; Fri, 21 Sep 2018 17:26:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537575999; cv=none; d=google.com; s=arc-20160816; b=DqwK/e8fcR+8NyGktFgmH94NmzVSJRUjz9gAp9WZI5usV+RZ227FWXKpPcdbiLsGte 8P2U8BZEgDaS9DvkMfqiD9mbmd5lI7+YVwJgPocYhTfaXEnNDRKmEfHiYlHuk/9PTafM B+rjNndEjm3u4dQI9SbtKho4d9rT6odyhTlgxp8gX+8oP2Su0d9mf7hAwVD80Olkok3D dBbFIeKROYxrr/49CFCG76eitUypGuP9i+9+zKzexRgfDn52bX05Iblrzag5ecjZbj/5 FxRpGPn1uhwHF0Cn0IuPfLo4Ar4M9PtMNYo0ajZSLLSM4cSxK/fDESnA8mYvXaKK3FR6 Z2Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=GfkGu0fH8XJVLgDXUNmiTHAW9Laen4gfMbUxcAPARJI=; b=m9XZdRcshb+WLTJwCg2JF+kzPPOOnsX7c+aFfI367+XeKUrjClOM4XHeEYTcC6nah7 EDk1J3nPPlbjM79lc4hqDhodapuXRjVU+7fZni81u++nQoCmqX/gbiFAlsr0zoaMdUJ5 vzk5YwWg9jPqiSTmQ2WKOToHg/A94j1R47grooIbmGWaoV8BRVoFyZYMm2dtJ6uut5Rs rnOPRuelZMBm+2xTljKtV9/FtLuDxY1/99edgXUt+TA42NRgTD+ULXVa64QQ4mDudYn5 YiJNOiAAL1b9bfrv9TgS9rW9wn5k7DysEO4TYRQ9iKXz13goDns6/HsvyYv3zUX+n3No d25w== 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 m11-v6si5463741pgs.33.2018.09.21.17.26.24; Fri, 21 Sep 2018 17:26:39 -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 S2392379AbeIVGQH (ORCPT + 99 others); Sat, 22 Sep 2018 02:16:07 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:44138 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391926AbeIVGKp (ORCPT ); Sat, 22 Sep 2018 02:10:45 -0400 Received: from [2a02:8011:400e:2:cbab:f00:c93f:614] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1g3Vdv-0008Bc-Bo; Sat, 22 Sep 2018 01:19:27 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1g3Vdo-0000tY-Pr; Sat, 22 Sep 2018 01:19:20 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Kees Cook" , "Dr Silvio Cesare of InfoSect" Date: Sat, 22 Sep 2018 01:15:42 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 48/63] video: uvesafb: Fix integer overflow in allocation In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:cbab:f00:c93f:614 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.58-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Kees Cook commit 9f645bcc566a1e9f921bdae7528a01ced5bc3713 upstream. cmap->len can get close to INT_MAX/2, allowing for an integer overflow in allocation. This uses kmalloc_array() instead to catch the condition. Reported-by: Dr Silvio Cesare of InfoSect Fixes: 8bdb3a2d7df48 ("uvesafb: the driver core") Signed-off-by: Kees Cook Signed-off-by: Ben Hutchings --- drivers/video/fbdev/uvesafb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/video/fbdev/uvesafb.c +++ b/drivers/video/fbdev/uvesafb.c @@ -1059,7 +1059,8 @@ static int uvesafb_setcmap(struct fb_cma info->cmap.len || cmap->start < info->cmap.start) return -EINVAL; - entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL); + entries = kmalloc_array(cmap->len, sizeof(*entries), + GFP_KERNEL); if (!entries) return -ENOMEM;