summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTed Unangst <tedu@cvs.openbsd.org>2004-05-30 22:35:44 +0000
committerTed Unangst <tedu@cvs.openbsd.org>2004-05-30 22:35:44 +0000
commit4cef0a0a624be440c173311156bd21f070b60d0b (patch)
tree689526f15ca7262fb84c5c7227f01a290c5fba8c /sys
parent853dc29baeebbd393803d2adfeb4a7485573fcd2 (diff)
only free pages if we have write permission and they are not COW.
prevents msync/madvise funniness from art@ ok deraadt@
Diffstat (limited to 'sys')
-rw-r--r--sys/uvm/uvm_map.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c
index cb292c7362d..90290b5a61e 100644
--- a/sys/uvm/uvm_map.c
+++ b/sys/uvm/uvm_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uvm_map.c,v 1.66 2004/05/03 07:14:53 tedu Exp $ */
+/* $OpenBSD: uvm_map.c,v 1.67 2004/05/30 22:35:43 tedu Exp $ */
/* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */
/*
@@ -3039,11 +3039,18 @@ uvm_map_clean(map, start, end, flags)
flush_object:
/*
* flush pages if we've got a valid backing object.
+ *
+ * Don't PGO_FREE if we don't have write permission
+ * and don't flush if this is a copy-on-write object
+ * since we can't know our permissions on it.
*/
offset = current->offset + (start - current->start);
size = MIN(end, current->end) - start;
- if (uobj != NULL) {
+ if (uobj != NULL &&
+ ((flags & PGO_FREE) == 0 ||
+ ((entry->max_protection & VM_PROT_WRITE) != 0 &&
+ (entry->etype & UVM_ET_COPYONWRITE) == 0))) {
simple_lock(&uobj->vmobjlock);
rv = uobj->pgops->pgo_flush(uobj, offset,
offset + size, flags);