summaryrefslogtreecommitdiff
path: root/sys/src/9/alphapc
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2013-12-29 07:48:19 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2013-12-29 07:48:19 +0100
commit42074003ca31dea9589012fe3e235e4ddec5be1f (patch)
tree853027cfd12f6cad1f310de95927455d71101656 /sys/src/9/alphapc
parentafc2d547e18381ce2dd0f69f0e88860d49b7e54f (diff)
kernel: dont call pprint() while holding up->debug qlock
pprint() might block or even (maliciously) call into devproc write which will corrupt the qlock chain on attempt to qlock up->debug again.
Diffstat (limited to 'sys/src/9/alphapc')
-rw-r--r--sys/src/9/alphapc/trap.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/sys/src/9/alphapc/trap.c b/sys/src/9/alphapc/trap.c
index 556b0bb13..70317bb0c 100644
--- a/sys/src/9/alphapc/trap.c
+++ b/sys/src/9/alphapc/trap.c
@@ -543,9 +543,9 @@ notify(Ureg *ur)
}
if(n->flag != NUser && (up->notified || up->notify==0)) {
+ qunlock(&up->debug);
if(n->flag == NDebug)
pprint("suicide: %s\n", n->msg);
- qunlock(&up->debug);
pexit(n->msg, n->flag!=NDebug);
}
@@ -564,9 +564,8 @@ notify(Ureg *ur)
if(!okaddr((ulong)up->notify, BY2WD, 0)
|| !okaddr(sp-ERRMAX-6*BY2WD, sizeof(Ureg)+ERRMAX-6*BY2WD, 1)) {
- pprint("suicide: bad address or sp in notify\n");
-print("suicide: bad address or sp in notify\n");
qunlock(&up->debug);
+ pprint("suicide: bad address or sp in notify\n");
pexit("Suicide", 0);
}
@@ -618,7 +617,6 @@ noted(Ureg *kur, Ureg **urp, ulong arg0)
if(arg0!=NRSTR && !up->notified) {
qunlock(&up->debug);
pprint("call to noted() when not notified\n");
-print("call to noted() when not notified\n");
pexit("Suicide", 0);
}
up->notified = 0;
@@ -630,16 +628,14 @@ print("call to noted() when not notified\n");
oureg = (ulong)nur;
if((oureg & (BY2V-1))
|| !okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){
- pprint("bad ureg in noted or call to noted() when not notified\n");
-print("bad ureg in noted or call to noted() when not notified\n");
qunlock(&up->debug);
+ pprint("bad ureg in noted or call to noted() when not notified\n");
pexit("Suicide", 0);
}
if(!validstatus(kur->status, nur->status)) {
qunlock(&up->debug);
pprint("bad noted ureg status %lux\n", (ulong)nur->status);
-print("bad noted ureg status %lux\n", (ulong)nur->status);
pexit("Suicide", 0);
}
@@ -648,9 +644,8 @@ print("bad noted ureg status %lux\n", (ulong)nur->status);
case NCONT:
case NRSTR:
if(!okaddr(nur->pc, BY2WD, 0) || !okaddr(nur->usp, BY2WD, 0)){
- pprint("suicide: trap in noted\n");
-print("suicide: trap in noted\n");
qunlock(&up->debug);
+ pprint("suicide: trap in noted\n");
pexit("Suicide", 0);
}
up->ureg = (Ureg*)(*(ulong*)(oureg-BY2WD));
@@ -661,9 +656,8 @@ print("suicide: trap in noted\n");
case NSAVE:
if(!okaddr(nur->pc, BY2WD, 0) || !okaddr(nur->usp, BY2WD, 0)){
- pprint("suicide: trap in noted\n");
-print("suicide: trap in noted\n");
qunlock(&up->debug);
+ pprint("suicide: trap in noted\n");
pexit("Suicide", 0);
}
qunlock(&up->debug);
@@ -677,15 +671,13 @@ print("suicide: trap in noted\n");
break;
default:
- pprint("unknown noted arg 0x%lux\n", arg0);
-print("unknown noted arg 0x%lux\n", arg0);
up->lastnote.flag = NDebug;
/* fall through */
case NDFLT:
+ qunlock(&up->debug);
if(up->lastnote.flag == NDebug)
pprint("suicide: %s\n", up->lastnote.msg);
- qunlock(&up->debug);
pexit(up->lastnote.msg, up->lastnote.flag!=NDebug);
}
}