Fix deadlock in __hpf() When erroring out, we were not unlocking first. As a side note, if you give the kernel a virtual address and tell it to use it for an operation (e.g. read(fd, VIRT_ADDR, amt), that memory should be anonymous memory. At the very least, it must be soft-faultable (i.e. not a file that isn't in the page cache). Considering there's limited control over that, I currently don't allow that either. So something like this will fail: va = mmap(..., fd, 0) read(another_fd, va, amt); This restriction is stricter than Linux, and is because of userspace's role in managing its own memory - it's up to the user to know what is or isn't resident. Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
diff --git a/kern/src/mm.c b/kern/src/mm.c index 91b3d76..906d297 100644 --- a/kern/src/mm.c +++ b/kern/src/mm.c
@@ -1053,8 +1053,10 @@ goto out; } } else { - if (!file_ok) - return -EACCES; + if (!file_ok) { + ret = -EACCES; + goto out; + } /* If this fails, either something got screwed up with the VMR, or the * permissions changed after mmap/mprotect. Either way, I want to know * (though it's not critical). */