diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-02-18 23:36:13 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-02-18 23:36:13 +0000 |
commit | 7963d24cf8459c979a28a708f8f27af0d795bc51 (patch) | |
tree | 40859a54c8030c9ab9fe86550bd7c100ad988d08 | |
parent | 08a8655a569181a52290fa30929a49382b77618f (diff) |
do not permit read+write mmap on a read-only device-based descriptor;
mostly from chuck@maria.wustl.edu
-rw-r--r-- | sys/vm/vm_mmap.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 89315f43311..7d7855d341f 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_mmap.c,v 1.10 1997/11/14 20:56:08 deraadt Exp $ */ +/* $OpenBSD: vm_mmap.c,v 1.11 1998/02/18 23:36:12 deraadt Exp $ */ /* $NetBSD: vm_mmap.c,v 1.47 1996/03/16 23:15:23 christos Exp $ */ /* @@ -237,7 +237,13 @@ sys_mmap(p, v, retval) maxprot |= VM_PROT_READ; else if (prot & PROT_READ) return (EACCES); - if (flags & MAP_SHARED) { + + if ((flags & MAP_SHARED) != 0 || + ((flags & (MAP_PRIVATE|MAP_SHARED|MAP_COPY)) == MAP_FILE && + vp->v_type == VCHR)) { + if (fp->f_flag & FWRITE) + maxprot |= VM_PROT_WRITE; + } else if (flags & MAP_SHARED) { if (fp->f_flag & FWRITE) maxprot |= VM_PROT_WRITE; else if (prot & PROT_WRITE) |