public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Hao A" <hao.a.wu@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"Zhang, Shenglei" <shenglei.zhang@intel.com>
Cc: "Ni, Ray" <ray.ni@intel.com>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/SdBlockIoPei: Add check for DeviceIndex
Date: Wed, 30 Oct 2019 07:14:41 +0000	[thread overview]
Message-ID: <B80AF82E9BFB8E4FBD8C89DA810C6A093C955767@SHSMSX104.ccr.corp.intel.com> (raw)
In-Reply-To: <20191017062111.10568-2-shenglei.zhang@intel.com>

> -----Original Message-----
> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of
> Zhang, Shenglei
> Sent: Thursday, October 17, 2019 2:21 PM
> To: devel@edk2.groups.io
> Cc: Wu, Hao A; Ni, Ray
> Subject: [edk2-devel] [PATCH] MdeModulePkg/SdBlockIoPei: Add check for
> DeviceIndex
> 
> DeviceIndex is used as index in Slot[]. The max size of Slot[]
> is SD_PEIM_MAX_SLOTS. So DeviceIndex should be checked before used.
> 
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Ray Ni <ray.ni@intel.com>
> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
> ---
>  MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c
> b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c
> index 8fa58d65b22c..25530dcb34ce 100644
> --- a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c
> +++ b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c
> @@ -174,7 +174,7 @@ SdBlockIoPeimGetMediaInfo (
> 
>    Private   = GET_SD_PEIM_HC_PRIVATE_DATA_FROM_THIS (This);
> 
> -  if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices)) {
> +  if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices) ||
> (DeviceIndex > (SD_PEIM_MAX_SLOTS - 1))) {


Hello,

I do not think the change is proper, since 'DeviceIndex' is used to access the
array Private->Slot[SD_PEIM_MAX_SLOTS] like:

  Private->Slot[DeviceIndex - 1]

I think the change should be:

  ... || (DeviceIndex > (SD_PEIM_MAX_SLOTS)

instead of:

  ... || (DeviceIndex > (SD_PEIM_MAX_SLOTS - 1)


Could you help to double confirm on this? Thanks in advance.

Best Regards,
Hao Wu


>      return EFI_INVALID_PARAMETER;
>    }
> 
> @@ -252,7 +252,7 @@ SdBlockIoPeimReadBlocks (
>      return EFI_SUCCESS;
>    }
> 
> -  if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices)) {
> +  if ((DeviceIndex == 0) || (DeviceIndex > Private->TotalBlkIoDevices) ||
> (DeviceIndex > (SD_PEIM_MAX_SLOTS - 1))) {
>      return EFI_INVALID_PARAMETER;
>    }
> 
> --
> 2.18.0.windows.1
> 
> 
> 


  reply	other threads:[~2019-10-30  7:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-17  6:21 [PATCH] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4' Zhang, Shenglei
2019-10-17  6:21 ` [PATCH] MdeModulePkg/SdBlockIoPei: Add check for DeviceIndex Zhang, Shenglei
2019-10-30  7:14   ` Wu, Hao A [this message]
2019-10-30  7:53     ` [edk2-devel] " Zhang, Shenglei
2019-10-18  2:53 ` [edk2-devel] [PATCH] MdeModulePkg/HiiDatabaseDxe: Add check for 'Private->Attribute >> 4' Dandan Bi

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=B80AF82E9BFB8E4FBD8C89DA810C6A093C955767@SHSMSX104.ccr.corp.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