mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2025-04-19 22:10:19 +02:00
add inlined check for -1 with pkey_set
This commit is contained in:
parent
05ac717cf2
commit
59def67979
1 changed files with 11 additions and 2 deletions
13
malloc.c
13
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue