Received: by 10.223.185.116 with SMTP id b49csp801932wrg; Sat, 10 Feb 2018 20:35:23 -0800 (PST) X-Google-Smtp-Source: AH8x2241MzCUzKiry9oO5DjKJGuQ3k2ZMOl7q7BTvRW5VzoZm7xMDMSiwS3txJrsUu07zcw/WeEJ X-Received: by 10.99.103.198 with SMTP id b189mr6228539pgc.20.1518323723607; Sat, 10 Feb 2018 20:35:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518323723; cv=none; d=google.com; s=arc-20160816; b=xkEBwKha/zZu/HcVhXNB1dp2TZX2HYXVSoOADSDrdo0oKS7f5xUAe8Xfjq9lddAmnP LWpCeDWaJKw1prDfV7T2qYVl8liysalKeYUcADccD55/1ttThlbeDt4Lr0BLaoMuk8KK nyHOtluYBctWdmpDak64iQpBMy8NKqVBnI7mhKqRoUIu4nyIk4tUBUzI8spunDEo+X3Q ifP/APgbw1/FfDN0oPln+ZIg961t9qAOzg++TQQt95UZbMKo7yhoFUbTPWSBbVPKlA/C JpTL3WydFkw6+gLXEqAkTq1IJRfOSub6bF/1zgXIPdFboRH/U4YA1Xe7ST1UanwiiztD fkzg== 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 :arc-authentication-results; bh=oX4Vc7W/kYIjjJ3er91MHn4/+9Iw25zj+dc2raWRqFQ=; b=lv7jT6A1PchTbUwlduUBagxiuesrE/Z6/ZVGQ2txojy58yN6Dy6wMNlEU9BhYVVF2G NAX+seusY0vBEqaQRpRP0K9BcfR7loj+FGF4taejj5icNS4QSV3DC5ggFHRJ5DudmROo zAAeEafYbRSKW8f6XCeTuG5O2adZ+kpaN1UWdVOmtceEYiEO09RqDKWBa8Ap8rIdRlli bPaPVzEmyQRTviCW48us6fTA0i+Z2hd8HD7ftaf3XAIHyuHa7yhZfLzbOaRKYa9BAICd u7X/MGTSYBQqIfHKtTgG3lHqPN2FIgRnxvTK3ye4Dmawq14V59u6Rdve2rZVjYA/GJar g4UQ== 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 w27si1714952pge.33.2018.02.10.20.34.59; Sat, 10 Feb 2018 20:35:23 -0800 (PST) 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 S1752754AbeBKEdp (ORCPT + 99 others); Sat, 10 Feb 2018 23:33:45 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41324 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752465AbeBKEdk (ORCPT ); Sat, 10 Feb 2018 23:33:40 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (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 1ekjKc-0002hJ-ES; Sun, 11 Feb 2018 04:33:38 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKX-0004S9-6B; Sun, 11 Feb 2018 04:33:33 +0000 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, "Martin K. Petersen" , "Dan Carpenter" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 09/79] scsi: bfa: integer overflow in debugfs In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 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.2.99-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit 3e351275655d3c84dc28abf170def9786db5176d upstream. We could allocate less memory than intended because we do: bfad->regdata = kzalloc(len << 2, GFP_KERNEL); The shift can overflow leading to a crash. This is debugfs code so the impact is very small. I fixed the network version of this in March with commit 13e2d5187f6b ("bna: integer overflow bug in debugfs"). Fixes: ab2a9ba189e8 ("[SCSI] bfa: add debugfs support") Signed-off-by: Dan Carpenter Signed-off-by: Martin K. Petersen Signed-off-by: Ben Hutchings --- drivers/scsi/bfa/bfad_debugfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/scsi/bfa/bfad_debugfs.c +++ b/drivers/scsi/bfa/bfad_debugfs.c @@ -276,7 +276,8 @@ bfad_debugfs_write_regrd(struct file *fi struct bfad_s *bfad = port->bfad; struct bfa_s *bfa = &bfad->bfa; struct bfa_ioc_s *ioc = &bfa->ioc; - int addr, len, rc, i; + int addr, rc, i; + u32 len; u32 *regbuf; void __iomem *rb, *reg_addr; unsigned long flags; @@ -296,7 +297,7 @@ bfad_debugfs_write_regrd(struct file *fi } rc = sscanf(kern_buf, "%x:%x", &addr, &len); - if (rc < 2) { + if (rc < 2 || len > (UINT_MAX >> 2)) { printk(KERN_INFO "bfad[%d]: %s failed to read user buf\n", bfad->inst_no, __func__);