From: Hao Wu <hao.a.wu@intel.com>
To: edk2-devel@lists.01.org, feng.tian@intel.com
Cc: Hao Wu <hao.a.wu@intel.com>
Subject: [PATCH 7/7] MdeModulePkg NvmExpressDxe: Add check for command packet in PassThru
Date: Mon, 29 Aug 2016 10:42:27 +0800 [thread overview]
Message-ID: <1472438547-9368-8-git-send-email-hao.a.wu@intel.com> (raw)
In-Reply-To: <1472438547-9368-1-git-send-email-hao.a.wu@intel.com>
This commit adds check for the 'TransferBuffer' and 'TransferLength'
fields in EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET when the Opcode of an
NVME command indicates a data transfer between controller and host.
This commit also makes sure that the 'MetadataLength' field in
EFI_NVM_EXPRESS_PASS_THRU_COMMAND_PACKET is not 0 when the corresponding
'MetadataBuffer' field has a non-NULL value.
Cc: Feng Tian <feng.tian@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
---
MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
index c7ead21..693418c 100644
--- a/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
+++ b/MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressPassthru.c
@@ -477,6 +477,10 @@ NvmExpressPassThru (
// processor and a PCI Bus Master. It's caller's responsbility to ensure this.
//
if (((Sq->Opc & (BIT0 | BIT1)) != 0) && (Sq->Opc != NVME_ADMIN_CRIOCQ_CMD) && (Sq->Opc != NVME_ADMIN_CRIOSQ_CMD)) {
+ if ((Packet->TransferLength == 0) || (Packet->TransferBuffer == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
if ((Sq->Opc & BIT0) != 0) {
Flag = EfiPciIoOperationBusMasterRead;
} else {
@@ -499,8 +503,7 @@ NvmExpressPassThru (
Sq->Prp[0] = PhyAddr;
Sq->Prp[1] = 0;
- MapLength = Packet->MetadataLength;
- if(Packet->MetadataBuffer != NULL) {
+ if((Packet->MetadataLength != 0) && (Packet->MetadataBuffer != NULL)) {
MapLength = Packet->MetadataLength;
Status = PciIo->Map (
PciIo,
--
1.9.5.msysgit.0
prev parent reply other threads:[~2016-08-29 2:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-29 2:42 [PATCH 0/7] Fix some bugs in NvmExpressDxe driver Hao Wu
2016-08-29 2:42 ` [PATCH 1/7] MdeModulePkg NvmExpressDxe: Avoid crashing 'Mode' during OpenProtocol Hao Wu
2016-08-29 2:42 ` [PATCH 2/7] MdeModulePkg NvmExpressDxe: Refine BuildDevicePath API to follow spec Hao Wu
2016-08-29 2:42 ` [PATCH 3/7] MdeModulePkg NvmExpressDxe: Refine GetNameSpace " Hao Wu
2016-08-29 2:42 ` [PATCH 4/7] MdeModulePkg NvmExpressDxe: Refine GetNextNamespace " Hao Wu
2016-08-29 2:42 ` [PATCH 5/7] MdeModulePkg NvmExpressDxe: Add buffer alignment check in PassThru API Hao Wu
2016-08-29 2:42 ` [PATCH 6/7] MdeModulePkg NvmExpressDxe: Add check on the attributes of NVME controller Hao Wu
2016-08-29 2:42 ` Hao Wu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1472438547-9368-8-git-send-email-hao.a.wu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox