kernel: avoid panic with segio and SG_FAULT segments

the problem is that segio doesnt check segment attributes
and it can't really in case of SG_FAULT which can be
inherited from pseg and toggle at any time.

so instead of returning -1 from fault into the fault$cputype
handler which then panics when fault happend kernel mode,
we jump into segio's waserror() block just like in the
demand load i/o error case (faulterror()).
This commit is contained in:
cinap_lenrek 2017-05-21 16:36:11 +02:00
parent 1dc5f9222a
commit 760e539811
2 changed files with 3 additions and 1 deletions

View file

@ -921,7 +921,7 @@ procread(Chan *c, void *va, long n, vlong off)
continue;
j += sprint(statbuf+j, "%-6s %c%c %8p %8p %4ld\n",
sname[sg->type&SG_TYPE],
sg->type&SG_RONLY ? 'R' : ' ',
sg->type&SG_FAULT ? 'F' : (sg->type&SG_RONLY ? 'R' : ' '),
sg->profile ? 'P' : ' ',
sg->base, sg->top, sg->ref);
}

View file

@ -40,6 +40,8 @@ fault(uintptr addr, int read)
if((attr & SG_FAULT) != 0 || !read && (attr & SG_RONLY) != 0) {
qunlock(s);
up->psstate = sps;
if(up->kp && up->nerrlab) /* for segio */
error(Eio);
return -1;
}