From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Mon, 16 Sep 2019 07:45:58 -0700 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A674C18C427E; Mon, 16 Sep 2019 14:45:57 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-124-96.rdu2.redhat.com [10.10.124.96]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28AC65DA5B; Mon, 16 Sep 2019 14:45:55 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 04/11] OvmfPkg/XenBusDxe: Avoid Allocate in XenStoreVSPrint To: devel@edk2.groups.io, anthony.perard@citrix.com Cc: Ard Biesheuvel , Julien Grall , Jordan Justen , xen-devel@lists.xenproject.org References: <20190913145100.303433-1-anthony.perard@citrix.com> <20190913145100.303433-5-anthony.perard@citrix.com> From: "Laszlo Ersek" Message-ID: Date: Mon, 16 Sep 2019 16:45:55 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190913145100.303433-5-anthony.perard@citrix.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.62]); Mon, 16 Sep 2019 14:45:57 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 09/13/19 16:50, Anthony PERARD wrote: > In order to be able to use XenStoreVSPrint during the > ExitBootServices, we remove the allocation done by the function and > use the stack instead. > > Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2190 > Signed-off-by: Anthony PERARD > --- > OvmfPkg/XenBusDxe/XenStore.c | 21 +++++++++------------ > 1 file changed, 9 insertions(+), 12 deletions(-) > > diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c > index 5cc900190a..7b71dc156d 100644 > --- a/OvmfPkg/XenBusDxe/XenStore.c > +++ b/OvmfPkg/XenBusDxe/XenStore.c > @@ -1259,20 +1259,17 @@ XenStoreVSPrint ( > IN VA_LIST Marker > ) > { > - CHAR8 *Buf; > - XENSTORE_STATUS Status; > - UINTN BufSize; > - VA_LIST Marker2; > + CHAR8 Buf[XENSTORE_PAYLOAD_MAX]; > + UINTN Count; > > - VA_COPY (Marker2, Marker); > - BufSize = SPrintLengthAsciiFormat (FormatString, Marker2) + 1; > - VA_END (Marker2); > - Buf = AllocateZeroPool (BufSize); > - AsciiVSPrint (Buf, BufSize, FormatString, Marker); > - Status = XenStoreWrite (Transaction, DirectoryPath, Node, Buf); > - FreePool (Buf); > + Count = AsciiVSPrint (Buf, sizeof (Buf), FormatString, Marker); > + ASSERT (Count > 0); > + ASSERT (Count < sizeof (Buf)); > + if ((Count == 0) || (Count >= sizeof (Buf))) { > + return XENSTORE_STATUS_EINVAL; > + } > > - return Status; > + return XenStoreWrite (Transaction, DirectoryPath, Node, Buf); > } > > XENSTORE_STATUS > Reviewed-by: Laszlo Ersek