Gracefully handle pkey unavailable

All other pkey syscalls already handle errors gracefully.
But in case of a seccomp filter that blocks pkey but doesn't terminate, this change is necessary to continue to function.

Signed-off-by: Tad <tad@spotco.us>
pull/232/head
Tad 2023-11-25 17:30:26 -05:00
parent 61821b02c8
commit 3ecd4ce354
No known key found for this signature in database
GPG Key ID: B286E9F57A07424B
1 changed files with 6 additions and 1 deletions

View File

@ -61,7 +61,12 @@ bool memory_unmap(void *ptr, size_t size) {
static bool memory_protect_prot(void *ptr, size_t size, int prot, UNUSED int pkey) {
#ifdef USE_PKEY
bool ret = pkey_mprotect(ptr, size, prot, pkey);
bool ret;
if (pkey > 0) {
ret = pkey_mprotect(ptr, size, prot, pkey);
} else {
ret = mprotect(ptr, size, prot);
}
#else
bool ret = mprotect(ptr, size, prot);
#endif