git: 9front

Download patch

ref: 3ddb2e652a782498d7e567645ff50a8fc56177a4
parent: 853f92087bd12f37771f326d31a8ccdfdc77096b
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Thu Mar 28 17:52:38 EDT 2024

kernel: zero up->ureg on sysexec() and pexit()

The up->ureg pointer points to the last delivered
note in the user-space stack.

On exec(), all the notes are cleared and the
ureg pointer should be zeroed as well as it
points into the previous programs stack.

Note, this can only happen if someone does
exec() from a note handler.

When we pexit(), also zero the up->ureg and up->dbgreg
as we are about to release the memory segments
and nobody should debugging user-space anymore.

--- a/sys/src/9/port/proc.c
+++ b/sys/src/9/port/proc.c
@@ -1348,6 +1348,8 @@
 	freenote(up->lastnote);
 	up->lastnote = nil;
 	up->notified = 0;
+	up->ureg = nil;
+	up->dbgreg = nil;
 
 	/* release debuggers */
 	if(up->pdbg != nil) {
--- a/sys/src/9/port/sysproc.c
+++ b/sys/src/9/port/sysproc.c
@@ -607,6 +607,7 @@
 	up->lastnote = nil;
 	up->notify = nil;
 	up->notified = 0;
+	up->ureg = nil;
 	up->privatemem = 0;
 	up->noswap = 0;
 	up->pcycles = -up->kentry;
--