ref: 6f61580a2beeac3e7109f577b0f16de3f64d400c
parent: 31c1b7bf798078fbd0217a8f3118e03808eca014
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Fri May 23 21:27:57 EDT 2014
kernel: fix read size calculation in pio() demand load on amd64, the text segment is aligned and padded to 2MB, but segment granularity is 4K which can give us page faults that are beyond the highest file offset. this is perfectly valid, but was not handled correctly in pio().
--- a/sys/src/9/port/fault.c
+++ b/sys/src/9/port/fault.c
@@ -211,9 +211,11 @@
}
c = s->image->c;
- ask = s->flen-soff;
- if(ask > BY2PG)
- ask = BY2PG;
+ ask = BY2PG;
+ if(soff >= s->flen)
+ ask = 0;
+ else if((soff+ask) > s->flen)
+ ask = s->flen-soff;
}
else { /* from a swap image */daddr = swapaddr(loadrec);
--
⑨