From 59def67979d980dd91d5cc5b1287ab3856e2044c Mon Sep 17 00:00:00 2001 From: Daniel Micay Date: Tue, 23 Oct 2018 07:40:14 -0400 Subject: [PATCH] add inlined check for -1 with pkey_set --- malloc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/malloc.c b/malloc.c index 0cce93d..4bc534c 100644 --- a/malloc.c +++ b/malloc.c @@ -94,15 +94,24 @@ int get_metadata_key(void) { #endif } +#ifdef USE_PKEY +static inline void thread_set_metadata_access(unsigned access) { + if (ro.metadata_pkey == -1) { + return; + } + pkey_set(ro.metadata_pkey, access); +} +#endif + static inline void thread_unseal_metadata(void) { #ifdef USE_PKEY - pkey_set(ro.metadata_pkey, 0); + thread_set_metadata_access(0); #endif } static inline void thread_seal_metadata(void) { #ifdef USE_PKEY - pkey_set(ro.metadata_pkey, PKEY_DISABLE_ACCESS); + thread_set_metadata_access(PKEY_DISABLE_ACCESS); #endif }