From patchwork Mon Jan 4 23:41:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 356415 Delivered-To: patch@linaro.org Received: by 2002:a02:85a7:0:0:0:0:0 with SMTP id d36csp15351334jai; Mon, 4 Jan 2021 15:43:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwJfeu40b9BqySmw/nMYbE6ZvhqaxzhZGUFBPm97PTp9aG9bEyJA9p+Rqm9atCFs5X4XngZ X-Received: by 2002:aa7:c403:: with SMTP id j3mr72019978edq.217.1609803821179; Mon, 04 Jan 2021 15:43:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609803821; cv=none; d=google.com; s=arc-20160816; b=0Vg3eu3RlDebEixWDec52YNnM+0TVs1V1dGcxwsEQmzwG0xOK4n6g9sackw4Db1fJn azCQ5ovdfExi+6rDiWfwEYcTOGW4snkFj0gtr1roaOtCuid1rtThIRDrdQXhXYIInS4X zdS1TkQoPirORV8bT4kdLa4Ayr8YUthSKsPvob3oxksSQtXVfqKTaIKRVyBLpUxCmwXy /E6dRL2IXy83btAdn9qckVxzkPpuHpjCRNGetyhLHDUaGByGU3T4We2UmZB3UlYtT95s zvOEtQGgLRlduNbVznrW6eXtGuw4zUwz54qE4pxavhi0I658zBprP2gsfQ9eG5Hvar+o LPZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HI9KV5ht1EkwiLVrY+LQxewNcDbiKFt07C1y4kD4e0g=; b=NPy68boxbjcCKu+dKV4/fqdOhtddb05HAiFImgQF/SJEGrS0SEZqsSindGua9OGFBM Bv7JRc6G6t85QAzMDbdXCXXlcUtuw63rMoSGvRU9rMeaZoCpxB7J//cQ83VrTXA7809a 1YWfM/ZKVgaI1N9qRKc2kNLTtybDFzkvb4bO+ZKRQFhaBa1RJ8d7om0GBv+dhhC4/f5J TrM6NGHA4sVIHmqD8QP3So7cCkITO2IGvxUX6dqixNnxO5QzN2ll0VcHNyu5Fw9NBDbr taZd1KoqKz0Cq7rYLeRwfKBm9V77QYW+Mz1INwfO+AxUk9kImPE0hgDxQuZPCa5damqA qJKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oGa41UtB; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-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 df16si31862580edb.69.2021.01.04.15.43.40 for ; Mon, 04 Jan 2021 15:43:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-scsi-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=k20201202 header.b=oGa41UtB; spf=pass (google.com: domain of linux-scsi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-scsi-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 S1726475AbhADXmX (ORCPT ); Mon, 4 Jan 2021 18:42:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:57958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726026AbhADXmX (ORCPT ); Mon, 4 Jan 2021 18:42:23 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id CFA442253A; Mon, 4 Jan 2021 23:41:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1609803702; bh=HcjfSk9jtUTttCAPsHGyHCv++22UOGHXgsPS0pGqMi8=; h=From:To:Cc:Subject:Date:From; b=oGa41UtBkdLJEHhmfTD7zAyxVAeH4iZic7396UY70u8ZgQKlOwxDTa+ryHPcNItW5 tfQ4I9wwN1ygbMPMZsI8LJpA34tBt70mA8W+ZofJ+mJ6Du9IZWdB13l3ahwmfznFWR dsVKcB/+qL+Cv24gCwLZQ5XujZwyZwEjEcFglyrhpLapIib6SJL1YMm/0HQTcnsCW3 2/PUlah9K+SU74ypbxHsGeXDbzSaXlyyUpp8fScArEG+dDUhcRtxvKahi3atvUSB+A xGEWBHVgh7QTXURYgP+N+k7Rmtbgs51065dJ9g9tpDxDCw7R4Kx19XHt/EUmAX8Ua4 mVsFwKtjCdJ5g== From: Arnd Bergmann To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: Arnd Bergmann , Phil Oester , Kashyap Desai , Sumit Saxena , Shivasharan S , Anand Lodnoor , Vaibhav Gupta , Jason Yan , Damien Le Moal , megaraidlinux.pdl@broadcom.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] scsi: megaraid_sas: Fix MEGASAS_IOC_FIRMWARE regression Date: Tue, 5 Jan 2021 00:41:04 +0100 Message-Id: <20210104234137.438275-1-arnd@kernel.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Arnd Bergmann Phil Oester reported that a fix for a possible buffer overrun that I sent caused a regression that manifests in this output: Event Message: A PCI parity error was detected on a component at bus 0 device 5 function 0. Severity: Critical Message ID: PCI1308 The original code tried to handle the sense data pointer differently when using 32-bit 64-bit DMA addressing, which would lead to a 32-bit dma_addr_t value of 0x11223344 to get stored 32-bit kernel: 44 33 22 11 ?? ?? ?? ?? 64-bit LE kernel: 44 33 22 11 00 00 00 00 64-bit BE kernel: 00 00 00 00 44 33 22 11 or a 64-bit dma_addr_t value of 0x1122334455667788 to get stored as 32-bit kernel: 88 77 66 55 ?? ?? ?? ?? 64-bit kernel: 88 77 66 55 44 33 22 11 In my patch, I tried to ensure that the same value is used on both 32-bit and 64-bit kernels, and picked what seemed to be the most sensible combination, storing 32-bit addresses in the first four bytes (as 32-bit kernels already did), and 64-bit addresses in eight consecutive bytes (as 64-bit kernels already did), but evidently this was incorrect. Always storing the dma_addr_t pointer as 64-bit little-endian, i.e. initializing the second four bytes to zero in case of 32-bit addressing, apparently solved the problem for Phil, and is consistent with what all 64-bit little-endian machines did before. I also checked in the history that in previous versions of the code, the pointer was always in the first four bytes without padding, and that previous attempts to fix 64-bit user space, big-endian architectures and 64-bit DMA were clearly flawed and seem to have introduced made this worse. Reported-by: Phil Oester Fixes: 381d34e376e3 ("scsi: megaraid_sas: Check user-provided offsets") Fixes: 107a60dd71b5 ("scsi: megaraid_sas: Add support for 64bit consistent DMA") Fixes: 94cd65ddf4d7 ("[SCSI] megaraid_sas: addded support for big endian architecture") Fixes: 7b2519afa1ab ("[SCSI] megaraid_sas: fix 64 bit sense pointer truncation") Signed-off-by: Arnd Bergmann --- drivers/scsi/megaraid/megaraid_sas_base.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.29.2 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 6e4bf05c6d77..3b574c453414 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -8205,11 +8205,9 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance, goto out; } + /* always store 64 bits regardless of addressing */ sense_ptr = (void *)cmd->frame + ioc->sense_off; - if (instance->consistent_mask_64bit) - put_unaligned_le64(sense_handle, sense_ptr); - else - put_unaligned_le32(sense_handle, sense_ptr); + put_unaligned_le64(sense_handle, sense_ptr); } /*