Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1069262ybl; Wed, 14 Aug 2019 10:12:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqzcl3OqZiR4X/tqCm3dhI0zrej5HbGqrKxCq2Uu/qrwNLhUpWPO+zxrEDV7RmBsNxcjV9YP X-Received: by 2002:a63:62c6:: with SMTP id w189mr205553pgb.312.1565802726593; Wed, 14 Aug 2019 10:12:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802726; cv=none; d=google.com; s=arc-20160816; b=lF9IYXuv0eHBuK4P9hdm2WHnDl5WfFsRyH+M5sjPk+dgK4xBts+lQmvroNeZJbKqq4 p1IhZcrQpyd11bAtuysYWHyGjBJWUigTJbCMwxDcZX8MvAFj5tZT0FXbnXnQy2FkhBzD XqvzdMVPWONiNBN7SyDZaUbxYOFiL/0k+ojPd+Fi2hOGF2zbcWR4MXEEcmv0W6C38jYs xpxGp/6PAa+uo85gUu/WKJTtAoJhAwC6tynwYiAscl19vJtPZFmGL9UuzgfB3bXb8c/A uhDtIK0g0Nq5PPC528g+LMyp4jLMoMho9OXkhVcQBOPnlN3WZLiEZSn33/Yi1LJeLTQ5 GSoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ry1CkK5kSccOMgO5EuVv3zQ8kSC2nPLE+tYekTdt1Go=; b=qxBFOzNkkcZjBYTKcF15ZX6RBb41smZD2PcRyZahn8CPJEKNv23KUHVLp61irB+ExN fv9Nr/IMgU3mPPGul9cVSpzvmp76WdpWlWGAQRYWzyfg9LWBw6fg6vwb1iHBpkxqDLb6 jqg3G2IiBjKORgqklKiwLBnSahzPz2csWfe4/1uHsnDpWbpVFJtF8MUfPVLToD4sAQUt WP3BasWFrU7IugxbBmz+2anUk/5saq+Gw15sZiav2eDqBCtAyRezlCyOSaMn1ab0T8Pb aXULzbdpY217ndnoG6xZRtXPzqJFz87Z6dgugBPQJyfEMy0jytjFkjbRRzr5cOEulzl9 IFvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FDFun5UT; 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 d3si189322pjo.73.2019.08.14.10.11.50; Wed, 14 Aug 2019 10:12:06 -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; dkim=pass header.i=@kernel.org header.s=default header.b=FDFun5UT; 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 S1730056AbfHNRLN (ORCPT + 99 others); Wed, 14 Aug 2019 13:11:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:34278 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730550AbfHNRLI (ORCPT ); Wed, 14 Aug 2019 13:11:08 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9462E2084D; Wed, 14 Aug 2019 17:11:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802667; bh=63UifcLWro0TGxLFOZryiaCWAiPOi1B1KuP23Xh1lIc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FDFun5UThM6canYtHIgq3YkPuxu2B5ehhlfOInPLdQNtxXioKwgrxYhdEmAGtQXgl Y78X0ngWOaf+N/rWoJx/kDzlGA3ZZRE6o5SaJDQ6Ob3al1okhxKmUNlxaeQBb2ZVX7 qyZK+1daaa7fEN21vhV7U8R/e7ch5a0a9fCRS51A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Junxiao Bi , Sumit Saxena , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.19 63/91] scsi: megaraid_sas: fix panic on loading firmware crashdump Date: Wed, 14 Aug 2019 19:01:26 +0200 Message-Id: <20190814165752.299152649@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165748.991235624@linuxfoundation.org> References: <20190814165748.991235624@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 3b5f307ef3cb5022bfe3c8ca5b8f2114d5bf6c29 ] While loading fw crashdump in function fw_crash_buffer_show(), left bytes in one dma chunk was not checked, if copying size over it, overflow access will cause kernel panic. Signed-off-by: Junxiao Bi Acked-by: Sumit Saxena Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/megaraid/megaraid_sas_base.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index e0c87228438d3..806ceabcabc3f 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3025,6 +3025,7 @@ megasas_fw_crash_buffer_show(struct device *cdev, u32 size; unsigned long buff_addr; unsigned long dmachunk = CRASH_DMA_BUF_SIZE; + unsigned long chunk_left_bytes; unsigned long src_addr; unsigned long flags; u32 buff_offset; @@ -3050,6 +3051,8 @@ megasas_fw_crash_buffer_show(struct device *cdev, } size = (instance->fw_crash_buffer_size * dmachunk) - buff_offset; + chunk_left_bytes = dmachunk - (buff_offset % dmachunk); + size = (size > chunk_left_bytes) ? chunk_left_bytes : size; size = (size >= PAGE_SIZE) ? (PAGE_SIZE - 1) : size; src_addr = (unsigned long)instance->crash_buf[buff_offset / dmachunk] + -- 2.20.1