diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2014-10-03 17:41:01 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2014-10-03 17:41:01 +0000 |
commit | 6783cb575f3a29041f69ca189b28b9a59427df68 (patch) | |
tree | d5f59caf175ecbb93eb8afff1b750b698818c9b0 /sys/uvm/uvm_fault.c | |
parent | da6fdbb49593911c53553c7c24953d722a21cd7b (diff) |
Introduce __MAP_NOFAULT, a mmap(2) flag that makes sure a mapping will not
cause a SIGSEGV or SIGBUS when a mapped file gets truncated. Access to
pages that are not backed by a file on such a mapping will be replaced by
zero-filled anonymous pages. Makes passing file descriptors of mapped files
usable without having to play tricks with signal handlers.
"steal your mmap flag" deraadt@
Diffstat (limited to 'sys/uvm/uvm_fault.c')
-rw-r--r-- | sys/uvm/uvm_fault.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/uvm/uvm_fault.c b/sys/uvm/uvm_fault.c index 7d3090e4998..b45b43c3024 100644 --- a/sys/uvm/uvm_fault.c +++ b/sys/uvm/uvm_fault.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_fault.c,v 1.77 2014/09/07 08:17:44 guenther Exp $ */ +/* $OpenBSD: uvm_fault.c,v 1.78 2014/10/03 17:41:00 kettenis Exp $ */ /* $NetBSD: uvm_fault.c,v 1.51 2000/08/06 00:22:53 thorpej Exp $ */ /* @@ -1114,7 +1114,11 @@ Case2: goto ReFault; } - return (EACCES); /* XXX i/o error */ + if (!UVM_ET_ISNOFAULT(ufi.entry)) + return (EACCES); /* XXX i/o error */ + + uobjpage = PGO_DONTCARE; + promote = TRUE; } /* re-verify the state of the world. */ @@ -1132,7 +1136,7 @@ Case2: } /* didn't get the lock? release the page and retry. */ - if (locked == FALSE) { + if (locked == FALSE && uobjpage != PGO_DONTCARE) { uvm_lock_pageq(); /* make sure it is in queues */ uvm_pageactivate(uobjpage); |