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 <[email protected]>
---
kern/src/mm.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kern/src/mm.c b/kern/src/mm.c
index 91b3d768feae..906d297f8d4c 100644
--- a/kern/src/mm.c
+++ b/kern/src/mm.c
@@ -1053,8 +1053,10 @@ refault:
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). */
--
2.14.1.342.g6490525c54-goog
--
You received this message because you are subscribed to the Google Groups
"Akaros" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/d/optout.