From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.43; helo=mga05.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 7963421E25685 for ; Thu, 25 Jan 2018 02:43:06 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jan 2018 02:48:34 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,411,1511856000"; d="scan'208";a="169032618" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga004.jf.intel.com with ESMTP; 25 Jan 2018 02:48:34 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 25 Jan 2018 02:48:34 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 25 Jan 2018 02:48:33 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Thu, 25 Jan 2018 18:48:32 +0800 From: "Wang, Jian J" To: "Ni, Ruiyu" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] MdeModulePkg/Partition: Fix media probe Thread-Index: AQHTlcEpiDHXhZ1rFEmbXZ87t987pqOEZqYA Date: Thu, 25 Jan 2018 10:48:32 +0000 Message-ID: References: <20180125094444.385092-1-ruiyu.ni@intel.com> In-Reply-To: <20180125094444.385092-1-ruiyu.ni@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNDNkNzllMjItMjRjNi00ZWMzLWFlYTEtYzM5NDE5M2M2NTI5IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJ1YVF3a05QcDZYYXdYRWF6WXZESmFPWXcrSTIxdkRaa3lKRUQ4Q0hBczM5WDliNCt4T2VNWTZ0dEs3ajU0Q1VZIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg/Partition: Fix media probe X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jan 2018 10:43:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Tested-by/Reviewed-by: Jian J Wang > -----Original Message----- > From: Ni, Ruiyu > Sent: Thursday, January 25, 2018 5:45 PM > To: edk2-devel@lists.01.org > Cc: Wang, Jian J > Subject: [PATCH] MdeModulePkg/Partition: Fix media probe >=20 > The call in ProbeMediaStatusEx() to the ReadDisk() function of the > EFI_DISK_IO_PROTOCOL interface implemented in DiskIoDxe/DiskIo.c > crashed in DiskIo2ReadWriteDisk() because of the NULL value of > the destination buffer pointer. >=20 > Pass the address of a buffer in the stack instead of a NULL > pointer. >=20 > The similar fix was applied to ProbeMediaStatus in commit > df473cc1fc9acd1a623ec7e05276f2f0635c19d2 > * MdeModulePkg/PartitionDxe: Fix media probe >=20 > Somehow ProbeMediaStatusEx() wasn't changed together. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ruiyu Ni > Cc: Jian J Wang > --- > MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) >=20 > diff --git a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c > b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c > index bb9d0b70ce..46c0877cee 100644 > --- a/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c > +++ b/MdeModulePkg/Universal/Disk/PartitionDxe/Partition.c > @@ -4,7 +4,7 @@ > of the raw block devices media. Currently "El Torito CD-ROM", UDF, Leg= acy > MBR, and GPT partition schemes are supported. >=20 > -Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
> +Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BS= D > License > which accompanies this distribution. The full text of the license may b= e found > at > @@ -777,11 +777,15 @@ ProbeMediaStatusEx ( > ) > { > EFI_STATUS Status; > + UINT8 Buffer[1]; >=20 > // > - // Read 1 byte from offset 0 but passing NULL as buffer pointer > + // Read 1 byte from offset 0 to check if the MediaId is still valid. > + // The reading operation is synchronious thus it is not worth it to > + // allocate a buffer from the pool. The destination buffer for the > + // data is in the stack. > // > - Status =3D DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0, NULL, 1, NULL); > + Status =3D DiskIo2->ReadDiskEx (DiskIo2, MediaId, 0, NULL, 1, (VOID*)B= uffer); > if ((Status =3D=3D EFI_NO_MEDIA) || (Status =3D=3D EFI_MEDIA_CHANGED))= { > return Status; > } > -- > 2.15.1.windows.2