From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mx.groups.io with SMTP id smtpd.web12.564.1572487043590780262 for ; Wed, 30 Oct 2019 18:57:23 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.115, mailfrom: hao.a.wu@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2019 18:57:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,249,1569308400"; d="scan'208";a="205959894" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by FMSMGA003.fm.intel.com with ESMTP; 30 Oct 2019 18:57:23 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 30 Oct 2019 18:57:23 -0700 Received: from shsmsx105.ccr.corp.intel.com (10.239.4.158) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 30 Oct 2019 18:57:22 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX105.ccr.corp.intel.com ([169.254.11.225]) with mapi id 14.03.0439.000; Thu, 31 Oct 2019 09:57:21 +0800 From: "Wu, Hao A" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Ni, Ray" Subject: Re: [PATCH v2] MdeModulePkg/SdBlockIoPei: Add check for DeviceIndex Thread-Topic: [PATCH v2] MdeModulePkg/SdBlockIoPei: Add check for DeviceIndex Thread-Index: AQHVjx48iXzHEAt73USqMOml5Jkf9adz/rag Date: Thu, 31 Oct 2019 01:57:20 +0000 Message-ID: References: <20191030123319.19988-1-shenglei.zhang@intel.com> In-Reply-To: <20191030123319.19988-1-shenglei.zhang@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: hao.a.wu@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable > -----Original Message----- > From: Zhang, Shenglei > Sent: Wednesday, October 30, 2019 8:33 PM > To: devel@edk2.groups.io > Cc: Wu, Hao A; Ni, Ray > Subject: [PATCH v2] MdeModulePkg/SdBlockIoPei: Add check for DeviceIndex >=20 > DeviceIndex is used as index in Slot[]. The max size of Slot[] > is SD_PEIM_MAX_SLOTS. So DeviceIndex should be checked before used. >=20 > Cc: Hao A Wu > Cc: Ray Ni > Signed-off-by: Shenglei Zhang > --- > v2. Update the check boundary from "SD_PEIM_MAX_SLOTS-1" > to "SD_PEIM_MAX_SLOTS". Beacuse DeviceIndex is used as "DeviceIndex-1= " > in arrays. >=20 > MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c > b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c > index 8fa58d65b22c..ebd8270ce8e0 100644 > --- a/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c > +++ b/MdeModulePkg/Bus/Sd/SdBlockIoPei/SdBlockIoPei.c > @@ -174,7 +174,7 @@ SdBlockIoPeimGetMediaInfo ( >=20 > Private =3D GET_SD_PEIM_HC_PRIVATE_DATA_FROM_THIS (This); >=20 > - if ((DeviceIndex =3D=3D 0) || (DeviceIndex > Private->TotalBlkIoDevice= s)) { > + if ((DeviceIndex =3D=3D 0) || (DeviceIndex > Private->TotalBlkIoDevice= s) || > (DeviceIndex > SD_PEIM_MAX_SLOTS)) { > return EFI_INVALID_PARAMETER; > } >=20 > @@ -252,7 +252,7 @@ SdBlockIoPeimReadBlocks ( > return EFI_SUCCESS; > } >=20 > - if ((DeviceIndex =3D=3D 0) || (DeviceIndex > Private->TotalBlkIoDevice= s)) { > + if ((DeviceIndex =3D=3D 0) || (DeviceIndex > Private->TotalBlkIoDevice= s) || > (DeviceIndex > SD_PEIM_MAX_SLOTS)) { Reviewed-by: Hao A Wu Best Regards, Hao Wu > return EFI_INVALID_PARAMETER; > } >=20 > -- > 2.18.0.windows.1