Linux: Implement interfaces for memory protection keys

System Internals / glibc - Florian Weimer [redhat.com] - 5 December 2017 14:20 EST

This adds system call wrappers for pkey_alloc, pkey_free, pkey_mprotect, and x86-64 implementations of pkey_get and pkey_set, which abstract over the PKRU CPU register and hide the actual number of memory protection keys supported by the CPU. pkey_mprotect with a -1 key is implemented using mprotect, so it will work even if the kernel does not support the pkey_mprotect system call.

The system call wrapers use unsigned int instead of unsigned long for parameters, so that no special treatment for x32 is needed. The flags argument is currently unused, and the access rights bit mask is limited to two bits by the current PKRU register layout anyway.

446d22e91d Linux: Implement interfaces for memory protection keys
ChangeLog | 34 ++
NEWS | 4 +
manual/memory.texi | 232 ++++++++++++
support/Makefile | 6 +-
support/xraise.c | 27 ++
support/xsigaction.c | 27 ++
support/xsignal.c | 29 ++
support/xsignal.h | 8 +
support/xsysconf.c | 36 ++
support/xunistd.h | 1 +
sysdeps/unix/sysv/linux/Makefile | 6 +-
sysdeps/unix/sysv/linux/Versions | 1 +
sysdeps/unix/sysv/linux/aarch64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/alpha/libc.abilist | 5 +
sysdeps/unix/sysv/linux/arm/libc.abilist | 5 +
sysdeps/unix/sysv/linux/bits/mman-shared.h | 28 ++
sysdeps/unix/sysv/linux/bits/siginfo-consts.h | 6 +-
sysdeps/unix/sysv/linux/hppa/libc.abilist | 5 +
sysdeps/unix/sysv/linux/i386/libc.abilist | 5 +
sysdeps/unix/sysv/linux/ia64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist | 5 +
sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist | 5 +
sysdeps/unix/sysv/linux/microblaze/libc.abilist | 5 +
.../unix/sysv/linux/mips/mips32/fpu/libc.abilist | 5 +
.../unix/sysv/linux/mips/mips32/nofpu/libc.abilist | 5 +
.../unix/sysv/linux/mips/mips64/n32/libc.abilist | 5 +
.../unix/sysv/linux/mips/mips64/n64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/nios2/libc.abilist | 5 +
sysdeps/unix/sysv/linux/pkey_get.c | 26 ++
sysdeps/unix/sysv/linux/pkey_mprotect.c | 37 ++
sysdeps/unix/sysv/linux/pkey_set.c | 26 ++
.../sysv/linux/powerpc/powerpc32/fpu/libc.abilist | 5 +
.../linux/powerpc/powerpc32/nofpu/libc.abilist | 5 +
.../sysv/linux/powerpc/powerpc64/libc-le.abilist | 5 +
.../unix/sysv/linux/powerpc/powerpc64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist | 5 +
sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/sh/libc.abilist | 5 +
sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist | 5 +
sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/syscalls.list | 2 +
.../sysv/linux/tile/tilegx/tilegx32/libc.abilist | 5 +
.../sysv/linux/tile/tilegx/tilegx64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist | 5 +
sysdeps/unix/sysv/linux/tst-pkey.c | 399 +++++++++++++++++++++
sysdeps/unix/sysv/linux/x86/arch-pkey.h | 40 +++
sysdeps/unix/sysv/linux/x86/pkey_get.c | 33 ++
sysdeps/unix/sysv/linux/x86/pkey_set.c | 35 ++
sysdeps/unix/sysv/linux/x86_64/64/libc.abilist | 5 +
sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist | 5 +
50 files changed, 1179 insertions(+), 4 deletions(-)

Upstream: sourceware.org


  • Share