summaryrefslogtreecommitdiffstats
path: root/src/lib/stdlib.C
diff options
context:
space:
mode:
authorNick Bofferding <bofferdn@us.ibm.com>2018-10-25 16:59:50 -0500
committerDaniel M. Crowell <dcrowell@us.ibm.com>2018-11-15 10:37:14 -0600
commit9b7da2e3c3a7127d39e6ba94be9dadc9ac3f273e (patch)
treef5be48ba5726506e93866b7a27038d98b87a4eb4 /src/lib/stdlib.C
parent41e818515bd88e911a521b8b28d763bb61c24582 (diff)
downloadtalos-hostboot-9b7da2e3c3a7127d39e6ba94be9dadc9ac3f273e.tar.gz
talos-hostboot-9b7da2e3c3a7127d39e6ba94be9dadc9ac3f273e.zip
Support for putting fences around mallocs
This commit implements a compile time feature (set MALLOC_FENCING to y in the src/lib/HBconfig file) which puts check bytes around each malloc. Whenever an allocation is freed, if the check bytes have changed, the memory manager immediate crashes Hostboot. It also fixes a heap corruption in the SBE get capabilities command. Change-Id: I3df96d5fce43c34d3574c47f3c674076842d90e1 CQ: SW442980 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/68214 Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com> Reviewed-by: Roland Veloz <rveloz@us.ibm.com> Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
Diffstat (limited to 'src/lib/stdlib.C')
-rw-r--r--src/lib/stdlib.C15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/stdlib.C b/src/lib/stdlib.C
index 610a045a3..a7c694f9d 100644
--- a/src/lib/stdlib.C
+++ b/src/lib/stdlib.C
@@ -5,7 +5,7 @@
/* */
/* OpenPOWER HostBoot Project */
/* */
-/* Contributors Listed Below - COPYRIGHT 2010,2014 */
+/* Contributors Listed Below - COPYRIGHT 2010,2018 */
/* [+] International Business Machines Corp. */
/* */
/* */
@@ -28,6 +28,7 @@
#include <kernel/heapmgr.H>
#include <kernel/pagemgr.H>
#include <kernel/console.H>
+#include <config.h>
#ifdef HOSTBOOT_MEMORY_LEAKS
#include <arch/ppc.H>
@@ -114,10 +115,12 @@ void* malloc(size_t s)
return result;
}
-
void free(void* p)
{
- if (NULL == p) return;
+ if (nullptr == p)
+ {
+ return;
+ }
#ifdef HOSTBOOT_MEMORY_LEAKS
memoryleak_magic_instruction(MEMORYLEAK_FREE, 0, p, NULL);
@@ -126,10 +129,12 @@ void free(void* p)
HeapManager::free(p);
}
-
void* realloc(void* p, size_t s)
{
- if (NULL == p) return malloc(s);
+ if (nullptr == p)
+ {
+ return malloc(s);
+ }
void* result = HeapManager::realloc(p,s);
OpenPOWER on IntegriCloud