Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1082952ybt; Wed, 1 Jul 2020 18:25:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOZp7CDEx2flsBul5csc17+tfx9R6mtdCz7EfH3ph6s/BTba2/ENrnzSe4aS+k/iRIASDe X-Received: by 2002:a17:906:5283:: with SMTP id c3mr23878249ejm.22.1593653154690; Wed, 01 Jul 2020 18:25:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593653154; cv=none; d=google.com; s=arc-20160816; b=KEq/Irstfd64NgNlYIpPHdiRMn1hjQfy5annY1uzb7NYtKoKOmgIAHAP+Nt9kxYv/w RnQEMUqCekj9AygzZopQbljj9cu3HknsKOYAp21giRdf0Q1Ro3Xr70VQPF5WEz7KZOhZ inc3zG7/rbDZb1gmaJlDnZTtlRJ5J7Ri4UYh/hiTs/SxIMrDx7pa9S2v2wCzsg+8DQE8 llsJmtXR+KYM7JV7BS/ZPJwpX0tWsK4nP4Wp6FXi2+T9P+emIbSLqQLqVylIpSJIVUrA 5rXZ8nOmsHKl049bEqJysIyw6mbXnCc2Q9fWw9AV4KThhJNrEsBfFmbjmMK6ECyCW3qC rlCA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tGbuLqs7DorpnxYFjv2hAfW95nGyf10GjJind6ba8rs=; b=DaCNg7r0C71lD7fubYXIVftGNksl50c1t0YWqoNeM3EDsSrr3CInQnntqdeAH+K3Bj +8LM+E0pa9FIe0+Fqtm9AjVMy7dO3qf5wUhNj2afLg56lpuVPdCmfTEMY0INIDNdNgcq BIUd7Mx61RqWNYYTT0NfZtencFTn9d0nGjl5z+aB+W7V8/D0tiuYCl70gFQ+rTGAKkxl ltOO1slsqSN//f8H1tqZ3A1dicuXCQl4og5Tswd/WeEKW2Vl0r7Nbos0DCLMtefS9VPy 35U/SDUKvhU9Me8sliFtEIw0JtYsmIwbPnDYqw//Ie+qfXROIKAiCfVZUDkviP3QU17M IU7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r5ivT7ON; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d2si4655094ejb.118.2020.07.01.18.25.31; Wed, 01 Jul 2020 18:25:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r5ivT7ON; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728567AbgGBBYA (ORCPT + 99 others); Wed, 1 Jul 2020 21:24:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:54598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728491AbgGBBXt (ORCPT ); Wed, 1 Jul 2020 21:23:49 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4A5AD20BED; Thu, 2 Jul 2020 01:23:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593653029; bh=d57Z06bRJknnqjS3Wp/YqNK1f++WDqjwuAwuq9k2yN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r5ivT7ON/iZkr9xvFuYlTcZ/11sxWKjVprJ69vtXcrdRXcXPpdCXl4sw/gzdFvxr0 6xhiIQaK/CnC3LO2A3YA8vCoZxB7rZcDzUV3yCpxDBodefv18m2K4z3lnDkTHqLLAt 8Q5XIob2FYl19W6T1YAAbttFgeSZtdUnRqgVqQn8= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tomas Henzl , Stanislav Saner , "Martin K . Petersen" , Sasha Levin , MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org Subject: [PATCH AUTOSEL 5.7 43/53] scsi: mptscsih: Fix read sense data size Date: Wed, 1 Jul 2020 21:21:52 -0400 Message-Id: <20200702012202.2700645-43-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702012202.2700645-1-sashal@kernel.org> References: <20200702012202.2700645-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tomas Henzl [ Upstream commit afe89f115e84edbc76d316759e206580a06c6973 ] The sense data buffer in sense_buf_pool is allocated with size of MPT_SENSE_BUFFER_ALLOC(64) (multiplied by req_depth) while SNS_LEN(sc)(96) is used when reading the data. That may lead to a read from unallocated area, sometimes from another (unallocated) page. To fix this, limit the read size to MPT_SENSE_BUFFER_ALLOC. Link: https://lore.kernel.org/r/20200616150446.4840-1-thenzl@redhat.com Co-developed-by: Stanislav Saner Signed-off-by: Stanislav Saner Signed-off-by: Tomas Henzl Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/message/fusion/mptscsih.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c index f0737c57ed5fc..1491561d2e5c9 100644 --- a/drivers/message/fusion/mptscsih.c +++ b/drivers/message/fusion/mptscsih.c @@ -118,8 +118,6 @@ int mptscsih_suspend(struct pci_dev *pdev, pm_message_t state); int mptscsih_resume(struct pci_dev *pdev); #endif -#define SNS_LEN(scp) SCSI_SENSE_BUFFERSIZE - /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/ /* @@ -2422,7 +2420,7 @@ mptscsih_copy_sense_data(struct scsi_cmnd *sc, MPT_SCSI_HOST *hd, MPT_FRAME_HDR /* Copy the sense received into the scsi command block. */ req_index = le16_to_cpu(mf->u.frame.hwhdr.msgctxu.fld.req_idx); sense_data = ((u8 *)ioc->sense_buf_pool + (req_index * MPT_SENSE_BUFFER_ALLOC)); - memcpy(sc->sense_buffer, sense_data, SNS_LEN(sc)); + memcpy(sc->sense_buffer, sense_data, MPT_SENSE_BUFFER_ALLOC); /* Log SMART data (asc = 0x5D, non-IM case only) if required. */ -- 2.25.1