From patchwork Mon Jan 25 18:38:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 370649 Delivered-To: patch@linaro.org Received: by 2002:a02:a60d:0:0:0:0:0 with SMTP id c13csp5325726jam; Tue, 26 Jan 2021 12:53:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJyg2Y/1o21dm3HfGzZL04zfkBosnZbVlskogqlDh3A/9W7FMdEGCgZqmBRWIv0jYma/0zTw X-Received: by 2002:a17:906:178d:: with SMTP id t13mr4526031eje.455.1611694437564; Tue, 26 Jan 2021 12:53:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611694437; cv=none; d=google.com; s=arc-20160816; b=YfT4Ldtq73684w6hy9zz5pKuuu7jOhJONgqud6hJAhFS9LoBihwPEQYsH/+caoruEV VcIIQaWM5gW8oc6M1dyPkyQGAHz5l0/gEpESW7YS0SUsp/ilyLeG5Zp0jS6lWwVSGVZ9 oxE6IM4qYUJt8vjmn3BTxjCOofDUPCZDoyJBX0SS/MBBpmABH0vqQnUCfxOho1bvU5p2 82HlZ4lLsMyB7nY1MfUwuhJ+v2U9BdNSnfaH1VBqkWVZjozCbv2chg11YJbn2VKJJ9bb 3HPeSdBdIU0gO78G9oijMQq7Qa0OghngP1k9qo6azwxQ3OHVgdzj3cV5J55IAlvcl6fg Gzog== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bPneUXmmqWRdLDyYfs3JdXv/2u3yA+qvS+v4yhWv/ZY=; b=FDQEKYKyl59IQtwQeplY/cXKvjQx1PkNb1s7oC6ennP16HjSbe7xcBRYgAPcnpztT+ ix1yNjC7sFIFpjXi+6KuDU2bWA13HMo7So6q44OlkEN4waE7ovrn2ubXqd97L3Yl64z2 IbKRz3EcDpRjoWi2yR08RZTT27Wha4tKw87EPmN6ANFfY2DRSB3MKXBuJSBgsodcPFAu ECJV/5Hqs6u9ojpOcPg7q7TH/v+x7vqw2I0jeSBynJkWSIWKqzJMsoDiOQAb5HtKtSJu K8BoD4yFI0BVpQYcYzoc7RgHfP2FND2uoF7aVvQ2ySsMawoSfnhXJEabXfcI+3C2vGWb uF/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=otRsr3oU; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si9124740edc.346.2021.01.26.12.53.57; Tue, 26 Jan 2021 12:53:57 -0800 (PST) Received-SPF: pass (google.com: domain of stable-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=@linuxfoundation.org header.s=korg header.b=otRsr3oU; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730521AbhAZFAQ (ORCPT + 13 others); Tue, 26 Jan 2021 00:00:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:38156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730871AbhAYSuz (ORCPT ); Mon, 25 Jan 2021 13:50:55 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id F403A2063A; Mon, 25 Jan 2021 18:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1611600614; bh=N8+4XAaY5SVHvDSceX+S21bvw7FkyehDhyC0eYvfnXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=otRsr3oUKqngR2nWkZ+QrMK15klu8kKwwy0C4chQGJhCirlOfGPT0HLF1YmZBQb8z j2HRQyQKF6KvxN+liMKg/UGlUD4T7RqD1mffarkXVDTNM3HOxOAmi5IY5dHA8iyZjD KEmxQEN9JHqnJTuhTsHF6h+lajACIp+VdNP1+kgo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Phil Oester , Arnd Bergmann , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.10 083/199] scsi: megaraid_sas: Fix MEGASAS_IOC_FIRMWARE regression Date: Mon, 25 Jan 2021 19:38:25 +0100 Message-Id: <20210125183219.770744554@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210125183216.245315437@linuxfoundation.org> References: <20210125183216.245315437@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann [ Upstream commit b112036535eda34460677ea883eaecc3a45a435d ] 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. Link: https://lore.kernel.org/r/20210104234137.438275-1-arnd@kernel.org 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") Reported-by: Phil Oester Tested-by: Phil Oester Signed-off-by: Arnd Bergmann Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/megaraid/megaraid_sas_base.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) -- 2.27.0 diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 9ebeb031329d9..cc45cdac13844 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -8232,11 +8232,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); } /*