Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1074802ybl; Wed, 14 Aug 2019 10:17:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlNtxk8BBkb6spui0ee3Ir5MSLoMPr07lRm9XKDDB455J7ieQRINhNJIC/APjbue0Pio3/ X-Received: by 2002:a17:902:8a87:: with SMTP id p7mr471658plo.124.1565803028626; Wed, 14 Aug 2019 10:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565803028; cv=none; d=google.com; s=arc-20160816; b=sQ5PLtTcy92G8Wfvhw8qziynU7uuIyTVai9ckjfoHTP9UtGsngeh/YDqxw1AROmE5H jyXRjNbzO0xPN/vNiF0HigLLrnWpdVWnjmr0SOjf1LVnGHn3j8O3t7sfy8QL8S8JjyOQ kLEGR7CP0DkWodfwBs6UbRbz9UJoLKVM8wuP+AkwcHCqH4FfJmY70DFAcCOxqEX9x+Vl HcpL+OCQN7FEMY3NOUf6axJ7xUHS69ZQeU1bu6l/uIbrwlNQ5xoAL4EwOWCbsKuqQLmE G4VepXUg+fmNNrtkbN1/cPw+0No4A4beR+Ev/1EB81B9K/HvLRixRlJ2DmpFZTDAiuTi lIPA== 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=NyYPb8C8ZOle5jdA9V8EMPwM/BnbeSm+shjNGvPRn5o=; b=RHvXHEzieAa4269f3uX5S3zkJe9FhqqaYwEJu80YRG4rXk45fME3Y7zAd4QsX2bPRD dpz4uJiT2f/27o0xpCteFtMOSWabimAPr4uL5A6EeaJBRZe04EPv38D1v7HqybWqSaOF in5WX9h/MaTuNZR/6OUBIYtF0cnPS8VjPpuJrIpv3OTOx9RBS+SD03enHT9i4WLgzVEK KmvoyCUtLsGhMX1lh4woG1cqWAzzRWTbAPqVPRutOsTQxCsDbublutE9JszPhrzoeOOr 1ItkckPZGJuTheAoUpTMxDK/67QNb8imjaN8dRIuwHgql67yF0TAyHC2Nkp4RyT8wowi HaKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2oLln+2l; 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 g5si230422pjp.10.2019.08.14.10.16.52; Wed, 14 Aug 2019 10:17:08 -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=2oLln+2l; 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 S1730944AbfHNRPI (ORCPT + 99 others); Wed, 14 Aug 2019 13:15:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:39650 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730829AbfHNRPG (ORCPT ); Wed, 14 Aug 2019 13:15:06 -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 0C43B2084D; Wed, 14 Aug 2019 17:15:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802905; bh=hooKEbjL6lz/cDvdyt0WkVmwmV+joOzrgmmqPwvwX7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2oLln+2lXZinD7oAEHvMTZosAZkpQX4BgegjZWaBWbtRle8Qq70mJDE93LCxh3lLT fxpCsOLIYJk3VTVdVDzyfbWRN9NL8m6VE8MSB/iiFai++xkKqNSWWBlj91epugouN3 fjjgNvl3hjReXlDpHK1+BWRJR2f7hzs+1K6WlxC0= 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.14 45/69] scsi: megaraid_sas: fix panic on loading firmware crashdump Date: Wed, 14 Aug 2019 19:01:43 +0200 Message-Id: <20190814165748.520722978@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165744.822314328@linuxfoundation.org> References: <20190814165744.822314328@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 73acd3e9ded75..8595d83229b77 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -2976,6 +2976,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; @@ -3001,6 +3002,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