From patchwork Mon Mar 20 13:11:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chenhui Sun X-Patchwork-Id: 95529 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp936047qgd; Mon, 20 Mar 2017 06:15:22 -0700 (PDT) X-Received: by 10.107.12.80 with SMTP id w77mr27218686ioi.124.1490015722329; Mon, 20 Mar 2017 06:15:22 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b17si17737842ioa.40.2017.03.20.06.15.22; Mon, 20 Mar 2017 06:15:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linaro-uefi-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=linaro-uefi-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id D423B63E92; Mon, 20 Mar 2017 13:15:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id A793F63E80; Mon, 20 Mar 2017 13:15:03 +0000 (UTC) X-Original-To: linaro-uefi@lists.linaro.org Delivered-To: linaro-uefi@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id E8C4A63E7E; Mon, 20 Mar 2017 13:14:56 +0000 (UTC) Received: from mail-pg0-f53.google.com (mail-pg0-f53.google.com [74.125.83.53]) by lists.linaro.org (Postfix) with ESMTPS id CD98C63E77 for ; Mon, 20 Mar 2017 13:14:52 +0000 (UTC) Received: by mail-pg0-f53.google.com with SMTP id t143so11444126pgb.2 for ; Mon, 20 Mar 2017 06:14:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kCclAYqx5Ggai0x5NpgA2FsrVyudX4CxRRu/ikW8818=; b=Y55j1f0s45zRvhQwoDO/fFARlNYv1sIKPHfwAcCB/MJPN9Y6xrXhuPIxXqSKDZ50IN srBaMK8hsNAR4wIFUu9Mec++C/I0Mh+8RZO/wl8IcOv7W+z/VsD7vXl6XULJ2X+H5fOP ipvJfwDS1N/MdtSrWSXZ1lCKzVsg8iglYbfudBR7lkqBd5RNWW0faYRqlwXsEvtu5goZ G9/S5fcXZrHw0Nmg+YR1I42aK3X+FTWBBWjlLjrpGCjJq8GRB5aAystMh8QRc6kBbalg MfHeuqlnDjA9QlpUXYRPYmJuNHJoeCkOon8RRSB0af23k8iyQDveh/VVjE15lRhhDI9Z 1OkQ== X-Gm-Message-State: AFeK/H00sJ5YuyntVXqLJNgG8JcvC/gGTXOZ09VgAyrxcPBlwQ0XISg1Y25Vz3y8gE53XC93Htk= X-Received: by 10.99.117.85 with SMTP id f21mr21800714pgn.143.1490015692066; Mon, 20 Mar 2017 06:14:52 -0700 (PDT) Received: from localhost.localdomain ([119.145.15.121]) by smtp.gmail.com with ESMTPSA id a62sm33573787pgc.60.2017.03.20.06.14.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 20 Mar 2017 06:14:51 -0700 (PDT) From: Chenhui Sun To: leif.lindholm@linaro.org, linaro-uefi@lists.linaro.org Date: Mon, 20 Mar 2017 21:11:05 +0800 Message-Id: <1490015485-53685-2-git-send-email-chenhui.sun@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490015485-53685-1-git-send-email-chenhui.sun@linaro.org> References: <1490015485-53685-1-git-send-email-chenhui.sun@linaro.org> Cc: Yi Li , Chenhui Sun , shaochangliang , sunchenhui@huawei.com, wanghuiqiang@huawei.com Subject: [Linaro-uefi] [Linaro-uefi v1 01/21] Hisilicon/UpdateFdtDxe: fix memory overflow issue X-BeenThere: linaro-uefi@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linaro-uefi-bounces@lists.linaro.org Sender: "Linaro-uefi" The size of the updated DTB file may be increased, so we need to allocate more memory than the original DTB size,or memory overflow may happen. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: shaochangliang Signed-off-by: Heyi Guo Signed-off-by: Yi Li Reviewed-by: Leif Lindholm --- Chips/Hisilicon/Drivers/UpdateFdtDxe/UpdateFdtDxe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chips/Hisilicon/Drivers/UpdateFdtDxe/UpdateFdtDxe.c b/Chips/Hisilicon/Drivers/UpdateFdtDxe/UpdateFdtDxe.c index 8586e33..699a820 100644 --- a/Chips/Hisilicon/Drivers/UpdateFdtDxe/UpdateFdtDxe.c +++ b/Chips/Hisilicon/Drivers/UpdateFdtDxe/UpdateFdtDxe.c @@ -112,7 +112,7 @@ EFIAPI UpdateFdt ( Size = (UINTN)fdt_totalsize ((VOID*)(PcdGet64(FdtFileAddress))); NewFdtBlobSize = Size + ADD_FILE_LENGTH; - Status = gBS->AllocatePages (AllocateAnyPages, EfiRuntimeServicesData, EFI_SIZE_TO_PAGES(Size), &NewFdtBlobBase); + Status = gBS->AllocatePages (AllocateAnyPages, EfiRuntimeServicesData, EFI_SIZE_TO_PAGES(NewFdtBlobSize), &NewFdtBlobBase); if (EFI_ERROR (Status)) { return EFI_OUT_OF_RESOURCES;