]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
pkeys.7: Rely on the glibc implementations
authorStephen Kitt <steve@sk2.org>
Sat, 8 Jan 2022 15:43:03 +0000 (16:43 +0100)
committerAlejandro Colomar <alx.manpages@gmail.com>
Sat, 8 Jan 2022 19:48:38 +0000 (20:48 +0100)
glibc 2.27 added implementations of pkey_set(), pkey_mprotect(),
pkey_alloc(), and pkey_free(); rely on those instead of defining them
in the example. wrpkru() is only used in pkey_set() and can be removed
too (it's the internal-use-only pkey_write() in glibc).

Signed-off-by: Stephen Kitt <steve@sk2.org>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
man7/pkeys.7

index 7c0d37a37732130e9f5d04e65be7517b563fc220..055e57ce32d46a3c61906bc59f0fa218e19b1220 100644 (file)
@@ -184,48 +184,10 @@ Segmentation fault (core dumped)
 .EX
 #define _GNU_SOURCE
 #include <unistd.h>
-#include <sys/syscall.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/mman.h>
 
-static inline void
-wrpkru(unsigned int pkru)
-{
-    unsigned int eax = pkru;
-    unsigned int ecx = 0;
-    unsigned int edx = 0;
-
-    asm volatile(".byte 0x0f,0x01,0xef\en\et"
-                 : : "a" (eax), "c" (ecx), "d" (edx));
-}
-
-int
-pkey_set(int pkey, unsigned int rights)
-{
-    unsigned int pkru = (rights << (2 * pkey));
-    wrpkru(pkru);
-    return 0;
-}
-
-int
-pkey_mprotect(void *ptr, size_t size, int orig_prot, int pkey)
-{
-    return syscall(SYS_pkey_mprotect, ptr, size, orig_prot, pkey);
-}
-
-int
-pkey_alloc(unsigned int flags, unsigned int rights)
-{
-    return syscall(SYS_pkey_alloc, flags, rights);
-}
-
-int
-pkey_free(int pkey)
-{
-    return syscall(SYS_pkey_free, pkey);
-}
-
 #define errExit(msg)    do { perror(msg); exit(EXIT_FAILURE); \e
                            } while (0)