Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F136005397
D3316.id7711.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D3316.id7711.diff
View Options
Index: sys/fs/devfs/devfs_vnops.c
===================================================================
--- sys/fs/devfs/devfs_vnops.c
+++ 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
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 16, 12:30 AM (10 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25345958
Default Alt Text
D3316.id7711.diff (1 KB)
Attached To
Mode
D3316: Permit private writable mappings of read-only /dev/zero descriptors.
Attached
Detach File
Event Timeline
Log In to Comment