ref: b96573b481440455ea92c67a0bc629b88901b319
parent: c309f466eff33a331f9a8d8c8b18cfe613c1d3f4
author: cinap_lenrek <[email protected]>
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;