Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17930959ybl; Thu, 2 Jan 2020 15:03:12 -0800 (PST) X-Google-Smtp-Source: APXvYqy3xYDJme45tocG0uHXLOjY8TW9imRnG75Wwc09NbqG1mEmpI079J217NBnCgWT7dobLkYd X-Received: by 2002:a9d:6f8f:: with SMTP id h15mr90436994otq.1.1578006192364; Thu, 02 Jan 2020 15:03:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578006192; cv=none; d=google.com; s=arc-20160816; b=nmacZdi8zXHyegH/PCsFV+8ch4RHgxA9Atqm5Rz+udbnzuxvjISFGI/6Oa/1HrgK2z fwvcqkqs7pwg/tmCoX5UpRpyqqoSBsCJkubeCVakkSmJTZl1Lut8yKKltWwdZysb+T1k oInwiZ+si9v4qHZEdq2nkE61bJxOlhbHy0PHIykNCOSb+Wwo+svYxX4eW8xMe6rG8Zh6 MQJJnJi9SdAMXfto0QCQMreFmcFcLSHRoEgf6OHeSZVj7YgnH7Wu3jZGbJca0ZxJ9gg2 vHf1aUxTd3MutdQymf/ZW7mSsl2BJ1PGF57P96I9XGYE6NhDIjljYhw0GohXe3A+/Xvs 4R+Q== 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=Wd928oA7L9iwA2ft31+5ceR3vCyTaA5yssR6oJXUQl0=; b=Vk4e+d0HDs//CkwkX3jvk6yNM9a7vLdriBZ4yE9qejEEPCEVEtd9zrMuWFh7MFb+dC OjA9VsnOlcen4Lv8vFzFkMp2IuVlPXtUbJKbPsaLX0Z5+ImY31mFjzRh2HuzjJPn86JQ 67LdJScm1BGCYWoydQrCZEOuRWs2uWYBtw2wuf6fabsRDtMs9SgVybdAyRncAzqTTSU8 LOVMw4jcYkscPvE9xebYtwUTGN9XgqFhnIr3L/3M/hgWaSaL/p8Ic8WFNa5rjCjomt4S 346VqJ69mmyMrqy5po5CBVDh0b44pVLpaR7BgeY68LtEtyxjkRKBd0ar5i7rb9ajxciw /xpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=iqhcpgQm; 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 e3si30976645otp.286.2020.01.02.15.02.59; Thu, 02 Jan 2020 15:03:12 -0800 (PST) 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=iqhcpgQm; 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 S1727444AbgABWMR (ORCPT + 99 others); Thu, 2 Jan 2020 17:12:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:51214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727400AbgABWMO (ORCPT ); Thu, 2 Jan 2020 17:12:14 -0500 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 7D93921D7D; Thu, 2 Jan 2020 22:12:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003134; bh=znMmWzgjYL4Doa5GAgSjyVDzZg8ISUI1lwxXLueNmtU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iqhcpgQmvcG+tXn+VCtrjmhrzV7XnIqtNCC5EaY3XNUfY8TrW3BC47AiSjKHNsgCZ CZUbNPae5GoLf8GEEjfpf4YzfDdMPrYEVyVGugPpTxKdshs3RaB78iRMVXHIxhTyiV s+ImOipTSHC9HiPlkxWeLtemvNtGP61SlNQ34Gv8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sreekanth Reddy , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 5.4 007/191] scsi: mpt3sas: Reject NVMe Encap cmnds to unsupported HBA Date: Thu, 2 Jan 2020 23:04:49 +0100 Message-Id: <20200102215830.585891452@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102215829.911231638@linuxfoundation.org> References: <20200102215829.911231638@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 From: Sreekanth Reddy [ Upstream commit 77fd4f2c88bf83205a21f9ca49fdcc0c7868dba9 ] If any faulty application issues an NVMe Encapsulated commands to HBA which doesn't support NVMe protocol then driver should return the command as invalid with the following message. "HBA doesn't support NVMe. Rejecting NVMe Encapsulated request." Otherwise below page fault kernel panic will be observed while building the PRPs as there is no PRP pools allocated for the HBA which doesn't support NVMe drives. RIP: 0010:_base_build_nvme_prp+0x3b/0xf0 [mpt3sas] Call Trace: _ctl_do_mpt_command+0x931/0x1120 [mpt3sas] _ctl_ioctl_main.isra.11+0xa28/0x11e0 [mpt3sas] ? prepare_to_wait+0xb0/0xb0 ? tty_ldisc_deref+0x16/0x20 _ctl_ioctl+0x1a/0x20 [mpt3sas] do_vfs_ioctl+0xaa/0x620 ? vfs_read+0x117/0x140 ksys_ioctl+0x67/0x90 __x64_sys_ioctl+0x1a/0x20 do_syscall_64+0x60/0x190 entry_SYSCALL_64_after_hwframe+0x44/0xa9 [mkp: tweaked error string] Link: https://lore.kernel.org/r/1568379890-18347-12-git-send-email-sreekanth.reddy@broadcom.com Signed-off-by: Sreekanth Reddy Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/mpt3sas/mpt3sas_ctl.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 3c463e8f6074..b95f7d062ea4 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -778,6 +778,18 @@ _ctl_do_mpt_command(struct MPT3SAS_ADAPTER *ioc, struct mpt3_ioctl_command karg, case MPI2_FUNCTION_NVME_ENCAPSULATED: { nvme_encap_request = (Mpi26NVMeEncapsulatedRequest_t *)request; + if (!ioc->pcie_sg_lookup) { + dtmprintk(ioc, ioc_info(ioc, + "HBA doesn't support NVMe. Rejecting NVMe Encapsulated request.\n" + )); + + if (ioc->logging_level & MPT_DEBUG_TM) + _debug_dump_mf(nvme_encap_request, + ioc->request_sz/4); + mpt3sas_base_free_smid(ioc, smid); + ret = -EINVAL; + goto out; + } /* * Get the Physical Address of the sense buffer. * Use Error Response buffer address field to hold the sense -- 2.20.1