From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 0DCFE2095C3B6 for ; Tue, 11 Apr 2017 04:53:33 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Apr 2017 04:53:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.37,185,1488873600"; d="scan'208";a="1154320102" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga002.fm.intel.com with ESMTP; 11 Apr 2017 04:53:32 -0700 Received: from fmsmsx151.amr.corp.intel.com (10.18.125.4) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 11 Apr 2017 04:53:32 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX151.amr.corp.intel.com (10.18.125.4) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 11 Apr 2017 04:53:32 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.117]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.224]) with mapi id 14.03.0319.002; Tue, 11 Apr 2017 19:53:29 +0800 From: "Wu, Jiaxin" To: Santhapur Naveen , "edk2-devel@lists.01.org" Thread-Topic: Array out of bounds write Thread-Index: AdKymXbNH7HWOz3xTVWbtmQe+Q4TQwAH8nkg Date: Tue, 11 Apr 2017 11:53:28 +0000 Message-ID: <895558F6EA4E3B41AC93A00D163B7274162BF6B4@SHSMSX103.ccr.corp.intel.com> References: <625A2455CC232F40B0F38F05ACED6D97C867892F@Venus2.in.megatrends.com> In-Reply-To: <625A2455CC232F40B0F38F05ACED6D97C867892F@Venus2.in.megatrends.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGIzZGNlZDUtNDIyZS00ZTkzLWI2MDMtZmU5MmZjZjVhMjY0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE1LjkuNi42IiwiVHJ1c3RlZExhYmVsSGFzaCI6IkM0VFNTR2VBRHdyM0J1cWxcL0JLeURxRFgxM21nYU9IZHQxTUNoeVlGeFZFPSJ9 x-ctpclassification: CTP_IC dlp-product: dlpe-windows dlp-version: 10.0.102.7 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: Array out of bounds write X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Apr 2017 11:53:33 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Naveen, Please feel free for the below coding, the array should never over bound si= nce the buffer has been allocated before using it. FragCount =3D (HeaderSize !=3D NULL) ? 2 : 1; TxLength =3D sizeof (EFI_UDP6_TRANSMIT_DATA) + (FragCount - 1) * sizeof= (EFI_UDP6_FRAGMENT_DATA); TxData =3D (EFI_UDP6_TRANSMIT_DATA *) AllocateZeroPool (TxLength); Actually, you can treat it as pointer, and the allocated memory would be lo= st since we have defined the FragmentCount. Thanks, Jiaxin > -----Original Message----- > From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of > Santhapur Naveen > Sent: Tuesday, April 11, 2017 4:06 PM > To: edk2-devel@lists.01.org > Subject: [edk2] Array out of bounds write > Importance: High >=20 > Hello all, >=20 > In the file PxeBcSupport.c of NetworkPkg there is >=20 > EFI_STATUS > PxeBcUdp4Write ( > { > ... > // > // Arrange one fragment buffer for data, and another fragment= buffer > for header if has. > // > FragCount =3D (HeaderSize !=3D NULL) ? 2 : 1; > ... > TxData->FragmentTable[FragCount - 1].FragmentLength =3D (UINT= 32) > *BufferSize; > ... > } >=20 > And similarly in >=20 > EFI_STATUS > PxeBcUdp6Write ( > { > ... > // > // Arrange one fragment buffer for data, and another fragment= buffer > for header if has. > // > FragCount =3D (HeaderSize !=3D NULL) ? 2 : 1; > ... > TxData->FragmentTable[FragCount - 1].FragmentLength =3D (UINT= 32) > *BufferSize; > ... > } >=20 > If HeaderSize is not NULL, then there is a chance of writing array over b= ounds > since FragmentTable is of single element. >=20 > /// > /// Array of fragment descriptors. > /// > EFI_UDP6_FRAGMENT_DATA FragmentTable[1]; >=20 > Shouldn't we be taking care of this? >=20 >=20 > Regards, > Naveen > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel