Date: Sun, 03 May 2026 15:45:41 +0000 From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 59aa556aa833 - stable/15 - pkru.3: Note that the kernel may not respect PKRU protections Message-ID: <69f76da5.1d95f.5b2fdef6@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/15 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=59aa556aa833c075d43b7095a28a6c856285794a commit 59aa556aa833c075d43b7095a28a6c856285794a Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2026-04-16 17:46:11 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2026-05-03 14:40:10 +0000 pkru.3: Note that the kernel may not respect PKRU protections There are cases where the kernel will be able to access memory covered by a PKRU key which nomially prohibits accesses. I believe regular copyin()/copyout() are subject to the contents of PKRU, but memory accesses via uiomove_fromphys() will not be. This can arise when performing fault I/O, for instance. I didn't test, but I suspect AIO is another case. Update the man page to acknowledge this. Reviewed by: alc, kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D56416 (cherry picked from commit fa77fecb0e06ec697e3d7a9ed899e568f1d2090c) --- lib/libsys/x86/pkru.3 | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/libsys/x86/pkru.3 b/lib/libsys/x86/pkru.3 index b977082c362f..45b7093bd094 100644 --- a/lib/libsys/x86/pkru.3 +++ b/lib/libsys/x86/pkru.3 @@ -71,13 +71,16 @@ Only one key may apply to a given range at a time. The default protection key index is zero, it is used even if no key was explicitly assigned to the address, or if the key was removed. .Pp -The protection prevents the system from accessing user addresses as well -as the user applications. -When a system call was unable to read or write user memory due to key -protection, it returns the -.Er EFAULT -error code. -Note that some side effects may have occurred if this error is reported. +If the user application attempts a memory access which is prohibited by the +PKRU register, the offending thread receives a synchronous +.Dv SIGSEGV +signal with +.Va si_code +set to +.Dv SEGV_PKUERR . +PKRU protections might prevent the kernel from accessing protected +user addresses when handling system calls, but this is not guaranteed and +must not be relied upon. .Pp Both 64-bit and 32-bit applications can use protection keys. More information about the hardware feature is provided in the IA32 Softwarehome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69f76da5.1d95f.5b2fdef6>
