]> git.lizzy.rs Git - plan9front.git/commitdiff
pc64: fix wrong Ureg* argument on note handler (thanks _sl!)
authorcinap_lenrek <cinap_lenrek@felloff.net>
Thu, 7 Aug 2014 17:55:25 +0000 (19:55 +0200)
committercinap_lenrek <cinap_lenrek@felloff.net>
Thu, 7 Aug 2014 17:55:25 +0000 (19:55 +0200)
_sl reported crash:

stats 593: suicide: sys: trap: fault write addr=0xffffffff8258d1b0 pc=0x204cc7

; acid 593
/proc/593/text:amd64 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/amd64
acid: lstk()
notejmp(ret=0x1,j=0x40ac90)+0x13 /sys/src/libc/amd64/notejmp.c:10
alarmed(a=0xffffffff8258d1b0,s=0x7ffffeffea58)+0x3f /sys/src/cmd/stats.c:718
notifier+0x3e /sys/src/libc/port/atnotify.c:15
acid:

note how a in alarmed is a kernel address!

the first Ureg* argument is passed to the note handler in the
RARG (BX) register, which was not loaded when returning to
userspace from syscall() thru forkret(). fix by returning thru
noteret() from syscall().

sys/src/9/pc64/trap.c

index a88f41b9340d8521f82b6e206a92a322db836ee3..71374b418ee02a732138e96867fcb3d1bccf0548 100644 (file)
@@ -769,6 +769,7 @@ syscall(Ureg* ureg)
        if(scallnr!=RFORK && (up->procctl || up->nnote)){
                splhi();
                notify(ureg);
+               ((void**)&ureg)[-1] = (void*)noteret;   /* loads RARG */
        }
        /* if we delayed sched because we held a lock, sched now */
        if(up->delaysched)