Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1064222ybl; Wed, 14 Aug 2019 10:08:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0B5X5nnxICU8VBbI3kRvcNwUllU8f+CS//5ZfDCCMOAkKgs+lCm369z9E7wQn5VgVoJgp X-Received: by 2002:a62:e515:: with SMTP id n21mr1003313pff.186.1565802482832; Wed, 14 Aug 2019 10:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802482; cv=none; d=google.com; s=arc-20160816; b=iMgm0jjKOBjhLe3cqmig/R4W4MY7T8wvphU2DeTaJ8a7fii/mGBKbwisajhriGSLKa cvqv0u+CJTprDEijlWTtUVVZ9gyryHw6c3ufssr6c9qWywuPKwyENIFDd4gYIAEf6JX8 S6xX4oUkoPPGAHqpYmFgZ1CLqh1BzFLsNNENpYUG6XcWyw0mI/UN/qBz6bmt051wCLkV AHkyfNBZGnq8L1/yt+BLaOi2RDS8/tKFRBfLfZgceReQZivlS+HEpAXEqq6suIOY2tnQ OmhRoMkUHfz+jixtaig+WF560OE7j3+5oTmmrXTbaB35IMR1Ob+RMAKjCUlpdjp8/QF/ atcw== 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=cNNTT/upyI9MrRTTIUaOT7uQ46dQWbWM3FskMGIUatw=; b=zgR5SatT7b9TEefHmpNGXHUZVSTOjZ/e6b9j3tiSdcbtXYhYKIbV4pWCIrfE2R7QdG mhyh/F00k+RnhqHX23JoeArajR8zRuCQlfmSKjDWa4ElTiuaIAZdfVUGezmpkdvHsDUz CCc6SJfZRGZL46s0WLAcygtmEBx7xJqc9cJTwxcKTycIyCsTi8yq2FjAyywm3IFFhWwJ jGFcD2wTOYXq+xotXItgTLmtMleX7HPiKRWz57MFlhGUFluv4winggVS5plHTXghgvBz 5a47xX/0IvuHReDvRVp3tIUjTNHNGmp9Gy899D55T/1A9+O/S7EF7l6R+GzpJYdvBGLa jYIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d6bDvq+a; 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 j17si74479pfa.198.2019.08.14.10.07.47; Wed, 14 Aug 2019 10:08:02 -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=d6bDvq+a; 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 S1729683AbfHNRGd (ORCPT + 99 others); Wed, 14 Aug 2019 13:06:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:55686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729670AbfHNRGb (ORCPT ); Wed, 14 Aug 2019 13:06:31 -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 988C0208C2; Wed, 14 Aug 2019 17:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802391; bh=t6eA6VKXVROaAH59iF6DMwE06CidU+UM0bKpkui1p7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d6bDvq+aCvQKT1O1FtxVrNdHEsw2ASdMvOwmU+6+bPADu41P14segcEN3X8A7lN+v S8/afAB4yTj7n7a4T+MCZwqzJ2U2zIW1QtBFLdsfmR+aaQKCXWxrhcO+zjcsArKQvE sei4HWLLV0MS9FKQBDdVQk9Ne2xjKQ0Rb6o11iCE= 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 5.2 107/144] scsi: megaraid_sas: fix panic on loading firmware crashdump Date: Wed, 14 Aug 2019 19:01:03 +0200 Message-Id: <20190814165804.380628302@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 7237114a1d534..5f30016e9b64f 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -3045,6 +3045,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; @@ -3070,6 +3071,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