diff options
Diffstat (limited to 'man7/pkeys.7')
-rw-r--r-- | man7/pkeys.7 | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/man7/pkeys.7 b/man7/pkeys.7 index 2ef56711f..6edfe9fcf 100644 --- a/man7/pkeys.7 +++ b/man7/pkeys.7 @@ -169,14 +169,14 @@ Segmentation fault (core dumped) #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> - +\& int main(void) { int status; int pkey; int *buffer; - +\& /* * Allocate one page of memory. */ @@ -184,20 +184,20 @@ main(void) MAP_ANONYMOUS | MAP_PRIVATE, \-1, 0); if (buffer == MAP_FAILED) err(EXIT_FAILURE, "mmap"); - +\& /* * Put some random data into the page (still OK to touch). */ *buffer = __LINE__; printf("buffer contains: %d\en", *buffer); - +\& /* * Allocate a protection key: */ pkey = pkey_alloc(0, 0); if (pkey == \-1) err(EXIT_FAILURE, "pkey_alloc"); - +\& /* * Disable access to any memory with "pkey" set, * even though there is none right now. @@ -205,7 +205,7 @@ main(void) status = pkey_set(pkey, PKEY_DISABLE_ACCESS); if (status) err(EXIT_FAILURE, "pkey_set"); - +\& /* * Set the protection key on "buffer". * Note that it is still read/write as far as mprotect() is @@ -215,18 +215,18 @@ main(void) PROT_READ | PROT_WRITE, pkey); if (status == \-1) err(EXIT_FAILURE, "pkey_mprotect"); - +\& printf("about to read buffer again...\en"); - +\& /* * This will crash, because we have disallowed access. */ printf("buffer contains: %d\en", *buffer); - +\& status = pkey_free(pkey); if (status == \-1) err(EXIT_FAILURE, "pkey_free"); - +\& exit(EXIT_SUCCESS); } .EE |