From 2149600d129944f60cbc858bc669193af0523409 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Tue, 27 Aug 2019 03:47:18 +0200 Subject: kernel: catch execution read fault on SG_NOEXEC segment fault() now has an additional pc argument that is used to detect fault on a non-executable segment. that is, we check on read fault if the segment has the SG_NOEXEC attribute and the program counter is within faulting page. --- sys/src/9/kw/trap.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'sys/src/9/kw') diff --git a/sys/src/9/kw/trap.c b/sys/src/9/kw/trap.c index 131413c11..0ced0bd6e 100644 --- a/sys/src/9/kw/trap.c +++ b/sys/src/9/kw/trap.c @@ -319,8 +319,6 @@ faultarm(Ureg *ureg, uintptr va, int user, int read) { int n, insyscall; char buf[ERRMAX]; - static int cnt, lastpid; - static ulong lastva; if(up == nil) { dumpregs(ureg); @@ -328,21 +326,7 @@ faultarm(Ureg *ureg, uintptr va, int user, int read) } insyscall = up->insyscall; up->insyscall = 1; - - /* this is quite helpful during mmu and cache debugging */ - if(va == lastva && up->pid == lastpid) { - ++cnt; - if (cnt >= 2) - /* fault() isn't fixing the underlying cause */ - panic("fault: %d consecutive faults for va %#lux", - cnt+1, va); - } else { - cnt = 0; - lastva = va; - lastpid = up->pid; - } - - n = fault(va, read); + n = fault(va, ureg->pc, read); if(n < 0){ if(!user){ dumpregs(ureg); -- cgit v1.2.3