Page MenuHomeFreeBSD

D3316.1795984517.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D3316.1795984517.diff

Index: head/sys/fs/devfs/devfs_vnops.c
===================================================================
--- head/sys/fs/devfs/devfs_vnops.c
+++ head/sys/fs/devfs/devfs_vnops.c
@@ -1774,13 +1774,24 @@
return (EACCES);
/*
- * Character devices always share mappings, so
- * require a writable fd for writable mappings.
+ * If we are sharing potential changes via MAP_SHARED and we
+ * are trying to get write permission although we opened it
+ * without asking for it, bail out.
+ *
+ * Note that most character devices always share mappings.
+ * The one exception is that D_MMAP_ANON devices
+ * (i.e. /dev/zero) permit private writable mappings.
+ *
+ * Rely on vm_mmap_cdev() to fail invalid MAP_PRIVATE requests
+ * as well as updating maxprot to permit writing for
+ * D_MMAP_ANON devices rather than doing that here.
*/
- if ((fp->f_flag & FWRITE) != 0)
- maxprot |= VM_PROT_WRITE;
- else if ((prot & VM_PROT_WRITE) != 0)
- return (EACCES);
+ if ((flags & MAP_SHARED) != 0) {
+ if ((fp->f_flag & FWRITE) != 0)
+ maxprot |= VM_PROT_WRITE;
+ else if ((prot & VM_PROT_WRITE) != 0)
+ return (EACCES);
+ }
maxprot &= cap_maxprot;
fpop = td->td_fpop;

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 29, 8:35 PM (16 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42096072
Default Alt Text
D3316.1795984517.diff (1 KB)

Event Timeline