From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (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 B315220352ABD for ; Sun, 10 Dec 2017 17:50:44 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2017 17:55:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,391,1508828400"; d="scan'208";a="10778589" Received: from jwang36-mobl2.ccr.corp.intel.com ([10.239.192.56]) by FMSMGA003.fm.intel.com with ESMTP; 10 Dec 2017 17:55:20 -0800 From: Jian J Wang To: edk2-devel@lists.01.org Date: Mon, 11 Dec 2017 09:55:16 +0800 Message-Id: <20171211015518.9404-1-jian.j.wang@intel.com> X-Mailer: git-send-email 2.15.1.windows.2 Subject: [PATCH 0/2] Fix issues in Heap Guard 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: Mon, 11 Dec 2017 01:50:44 -0000 One issue is that macros defined in HeapGuard.h GUARD_HEAP_TYPE_PAGE GUARD_HEAP_TYPE_POOL doesn't match the definition of PCD PcdHeapGuardPropertyMask in MdeModulePkg.dec. This patch fixed it by exchanging the BIT0 and BIT1 of them. Another is that method AdjustMemoryF() will return a bigger NumberOfPages than the value passed in. This is caused by counting twice of a shared Guard page which can be used for both head and tail Guard of the memory before it and after it. This happens only when partially freeing just one page in the middle of a bunch of allocated pages. The freed page should be turned into a new Guard page. Since the most part code of Heap Guard feature are almost the same, PiSmmCore and DxeCore have both above issues. This patch series fix them all. Jian J Wang (2): MdeModulePkg/DxeCore: Fix issues in Heap Guard MdeModulePkg/PiSmmCore: Fix issues in Heap Guard MdeModulePkg/Core/Dxe/Mem/HeapGuard.c | 93 ++++++++++++++++++++++++++------- MdeModulePkg/Core/Dxe/Mem/HeapGuard.h | 4 +- MdeModulePkg/Core/Dxe/Mem/Page.c | 15 +++--- MdeModulePkg/Core/Dxe/Mem/Pool.c | 4 +- MdeModulePkg/Core/PiSmmCore/HeapGuard.c | 91 ++++++++++++++++++++++++++------ MdeModulePkg/Core/PiSmmCore/HeapGuard.h | 4 +- 6 files changed, 164 insertions(+), 47 deletions(-) -- 2.15.1.windows.2