summaryrefslogtreecommitdiff
path: root/sys/src/9/port/fault.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2014-05-24 01:27:57 +0200
committercinap_lenrek <cinap_lenrek@felloff.net>2014-05-24 01:27:57 +0200
commit2185188f8360ea1952c7339c2702a16f15b12be1 (patch)
treeccd6af4653f031805276eb91488d8cfafdef7986 /sys/src/9/port/fault.c
parenteef4565003def0a1e72bf381665027ebe0420c6f (diff)
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().
Diffstat (limited to 'sys/src/9/port/fault.c')
-rw-r--r--sys/src/9/port/fault.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/src/9/port/fault.c b/sys/src/9/port/fault.c
index 1919c2890..3d4530401 100644
--- a/sys/src/9/port/fault.c
+++ b/sys/src/9/port/fault.c
@@ -211,9 +211,11 @@ retry:
}
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);