From 50cf6b9cb8be33ae848de15eac4f16eab8b04a28 Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 24 Jan 2023 00:12:03 +0000 Subject: [PATCH] ptrace reads/writes memory using uvm_io, which generates an temporary alias mapping using uvm_map_extract. With xonly now operational, this alias mapping is created with minprot, which for text will be xonly, and the kernel cannot read it (unless the architecture has implied read for exec from kernel pov). Pass UVM_IO_FIXPROT to create the alias with maxprot instead. ok kettenis --- sys/kern/sys_process.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 5d0df0cda2e..1fdfc652366 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_process.c,v 1.92 2023/01/02 23:09:48 guenther Exp $ */ +/* $OpenBSD: sys_process.c,v 1.93 2023/01/24 00:12:03 deraadt Exp $ */ /* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- @@ -864,8 +864,7 @@ process_domem(struct proc *curp, struct process *tr, struct uio *uio, int req) uvmspace_addref(vm); - error = uvm_io(&vm->vm_map, uio, - (uio->uio_rw == UIO_WRITE) ? UVM_IO_FIXPROT : 0); + error = uvm_io(&vm->vm_map, uio, UVM_IO_FIXPROT); uvmspace_free(vm); -- 2.20.1