[PATCH] pkeys.7: Update the example to match glibc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The pkeys function are now part of glibc and the prototype changed. As a
result the example does not compile anymore.
Remove the functions which are part of glibc and update pkey_alloc() and
pkey_set() to match the glibc signature.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
 man7/pkeys.7 | 41 ++---------------------------------------
 1 file changed, 2 insertions(+), 39 deletions(-)

diff --git a/man7/pkeys.7 b/man7/pkeys.7
index 63be26ee88681..fa73722d65159 100644
--- a/man7/pkeys.7
+++ b/man7/pkeys.7
@@ -189,43 +189,6 @@ Segmentation fault (core dumped)
 #include <stdio.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\\n\\t"
-                 : : "a" (eax), "c" (ecx), "d" (edx));
-}
-
-int
-pkey_set(int pkey, unsigned long rights, unsigned long flags)
-{
-    unsigned int pkru = (rights << (2 * pkey));
-    return wrpkru(pkru);
-}
-
-int
-pkey_mprotect(void *ptr, size_t size, unsigned long orig_prot,
-              unsigned long pkey)
-{
-    return syscall(SYS_pkey_mprotect, ptr, size, orig_prot, pkey);
-}
-
-int
-pkey_alloc(void)
-{
-    return syscall(SYS_pkey_alloc, 0, 0);
-}
-
-int
-pkey_free(unsigned long pkey)
-{
-    return syscall(SYS_pkey_free, pkey);
-}
-
 #define errExit(msg)    do { perror(msg); exit(EXIT_FAILURE); \\
                            } while (0)
 
@@ -253,7 +216,7 @@ main(void)
     /*
      * Allocate a protection key:
      */
-    pkey = pkey_alloc();
+    pkey = pkey_alloc(0, 0);
     if (pkey == \-1)
         errExit("pkey_alloc");
 
@@ -261,7 +224,7 @@ main(void)
      * Disable access to any memory with "pkey" set,
      * even though there is none right now
      */
-    status = pkey_set(pkey, PKEY_DISABLE_ACCESS, 0);
+    status = pkey_set(pkey, PKEY_DISABLE_ACCESS);
     if (status)
         errExit("pkey_set");
 
-- 
2.19.0




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux