]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
misc: Enable internal use of memory protection keys
authorFlorian Weimer <fweimer@redhat.com>
Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Tue, 24 Sep 2024 11:23:10 +0000 (13:23 +0200)
This adds the necessary hidden prototypes.

sysdeps/unix/sysv/linux/include/bits/mman-shared.h [new file with mode: 0644]
sysdeps/unix/sysv/linux/pkey_get.c
sysdeps/unix/sysv/linux/pkey_mprotect.c
sysdeps/unix/sysv/linux/pkey_set.c
sysdeps/unix/sysv/linux/powerpc/powerpc64/pkey_get.c
sysdeps/unix/sysv/linux/powerpc/powerpc64/pkey_set.c
sysdeps/unix/sysv/linux/syscalls.list
sysdeps/unix/sysv/linux/x86/pkey_get.c
sysdeps/unix/sysv/linux/x86/pkey_set.c

diff --git a/sysdeps/unix/sysv/linux/include/bits/mman-shared.h b/sysdeps/unix/sysv/linux/include/bits/mman-shared.h
new file mode 100644 (file)
index 0000000..7c14b5d
--- /dev/null
@@ -0,0 +1,16 @@
+#include <sysdeps/unix/sysv/linux/bits/mman-shared.h>
+
+#ifndef _ISOMAC
+
+extern __typeof (pkey_alloc) __pkey_alloc;
+libc_hidden_proto (__pkey_alloc)
+extern __typeof (pkey_free) __pkey_free;
+libc_hidden_proto (__pkey_free)
+extern __typeof (pkey_mprotect) __pkey_mprotect;
+libc_hidden_proto (__pkey_mprotect)
+extern __typeof (pkey_get) __pkey_get;
+libc_hidden_proto (__pkey_get)
+extern __typeof (pkey_set) __pkey_set;
+libc_hidden_proto (__pkey_set)
+
+#endif
index 743bd092689340004b3356c17357cff3775d4264..ed9b6297d1a85111f12e269428742c652ce2dfef 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
+#include <sys/mman.h>
 
 int
-pkey_get (int key)
+__pkey_get (int key)
 {
   __set_errno (ENOSYS);
   return -1;
 }
+libc_hidden_def (__pkey_get)
+weak_alias (__pkey_get, pkey_get)
index b7afa7946d016ddaa8d4dea5b000dfb04b45491e..e321a7eb1b9833b493da03fb89607085252feca5 100644 (file)
@@ -22,7 +22,7 @@
 #include <sysdep.h>
 
 int
-pkey_mprotect (void *addr, size_t len, int prot, int pkey)
+__pkey_mprotect (void *addr, size_t len, int prot, int pkey)
 {
   if (pkey == -1)
     /* If the key is -1, the system call is precisely equivalent to
@@ -30,3 +30,5 @@ pkey_mprotect (void *addr, size_t len, int prot, int pkey)
     return __mprotect (addr, len, prot);
   return INLINE_SYSCALL_CALL (pkey_mprotect, addr, len, prot, pkey);
 }
+libc_hidden_def (__pkey_mprotect)
+weak_alias (__pkey_mprotect, pkey_mprotect)
index d5d59e3031ff1c161cc3cbae82675a93fa2c57be..30463ef89bd58a67106b4de366e56a262b830b35 100644 (file)
    <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
+#include <sys/mman.h>
 
 int
-pkey_set (int key, unsigned int access_rights)
+__pkey_set (int key, unsigned int access_rights)
 {
   __set_errno (ENOSYS);
   return -1;
 }
+libc_hidden_def (__pkey_set)
+weak_alias (__pkey_set, pkey_set)
index 217ecd004fdeb15acdb0feeef0f2ec32f6c8a4a3..ac9ea3a1c132e1f9f888dd0b24c61dd70a3a38d4 100644 (file)
@@ -21,7 +21,7 @@
 #include <sys/mman.h>
 
 int
-pkey_get (int key)
+__pkey_get (int key)
 {
   if (key < 0 || key > PKEY_MAX)
     {
@@ -40,3 +40,5 @@ pkey_get (int key)
     return PKEY_DISABLE_WRITE;
   return 0;
 }
+libc_hidden_def (__pkey_get)
+weak_alias (__pkey_get, pkey_get)
index cc67b0acff254271bfb63f9ebcdb942494600d91..ac10b5de2264c28a29c4c8ff3122137f58cc6ac7 100644 (file)
@@ -21,7 +21,7 @@
 #include <sys/mman.h>
 
 int
-pkey_set (int key, unsigned int rights)
+__pkey_set (int key, unsigned int rights)
 {
   if (key < 0 || key > PKEY_MAX || rights > 3)
     {
@@ -46,3 +46,5 @@ pkey_set (int key, unsigned int rights)
   pkey_write (amr);
   return 0;
 }
+libc_hidden_def (__pkey_set)
+weak_alias (__pkey_set, pkey_set)
index 9ac42c3436dd1520a0db883b31e4456778b9931e..f1cfe8dc139e56d43f0d2b55941666795f7697e2 100644 (file)
@@ -102,8 +102,8 @@ name_to_handle_at EXTRA     name_to_handle_at i:isppi name_to_handle_at
 setns          EXTRA   setns           i:ii    setns
 
 memfd_create    EXTRA  memfd_create    i:si    memfd_create
-pkey_alloc     EXTRA   pkey_alloc      i:ii    pkey_alloc
-pkey_free      EXTRA   pkey_free       i:i     pkey_free
+pkey_alloc     EXTRA   pkey_alloc      i:ii    __pkey_alloc    pkey_alloc
+pkey_free      EXTRA   pkey_free       i:i     __pkey_free     pkey_free
 gettid          EXTRA   gettid          Ei:     __gettid       gettid
 tgkill          EXTRA   tgkill          i:iii   __tgkill       tgkill
 close_range     -       close_range     i:iii   __close_range   close_range
index eb988a5c450532673497ea39e9392c7ad0452ad1..0fb52ba18c0941a7b5fb64c6ead164c5dd99f7e9 100644 (file)
 
 #include <arch-pkey.h>
 #include <errno.h>
+#include <sys/mman.h>
 
 int
-pkey_get (int key)
+__pkey_get (int key)
 {
   if (key < 0 || key > 15)
     {
@@ -31,3 +32,5 @@ pkey_get (int key)
   return (pkru >> (2 * key)) & 3;
   return 0;
 }
+libc_hidden_def (__pkey_get)
+weak_alias (__pkey_get, pkey_get)
index 3fd2c95580ecbe91019e603d4a8e3865ebe31201..51e3d68d92227d03a295ecea10f8d64880274661 100644 (file)
 
 #include <arch-pkey.h>
 #include <errno.h>
+#include <sys/mman.h>
 
 int
-pkey_set (int key, unsigned int rights)
+__pkey_set (int key, unsigned int rights)
 {
   if (key < 0 || key > 15 || rights > 3)
     {
@@ -33,3 +34,5 @@ pkey_set (int key, unsigned int rights)
   pkey_write (pkru);
   return 0;
 }
+libc_hidden_def (__pkey_set)
+weak_alias (__pkey_set, pkey_set)