18348a2369
Linux mmap rejects mmap() on a write-only file with EACCES. linux_mmap_common currently does a fun dance to grab the fp associated with the passed in fd, validates it, then drops the reference and calls into kern_mmap(). Doing so is perhaps both fragile and premature; there's still plenty of chance for the request to get rejected with a more appropriate error, and it's prone to a race where the file we ultimately mmap has changed after it drops its referenced. This change alleviates the need to do this by providing a kern_mmap variant that allows the caller to inspect the fp just before calling into the fileop layer. The callback takes flags, prot, and maxprot as one could imagine scenarios where any of these, in conjunction with the file itself, may influence a caller's decision. The file type check in the linux compat layer has been removed; EINVAL is seemingly not an appropriate response to the file not being a vnode or device. The fileop layer will reject the operation with ENODEV if it's not supported, which more closely matches the common linux description of mmap(2) return values. If we discover that we're allowing an mmap() on a file type that Linux normally wouldn't, we should restrict those explicitly. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22977 |
||
---|---|---|
.. | ||
check_error.d | ||
check_internal_locks.d | ||
linux_common.c | ||
linux_common.h | ||
linux_dtrace.h | ||
linux_emul.c | ||
linux_emul.h | ||
linux_errno.c | ||
linux_errno.inc | ||
linux_event.c | ||
linux_event.h | ||
linux_file.c | ||
linux_file.h | ||
linux_fork.c | ||
linux_futex.c | ||
linux_futex.h | ||
linux_getcwd.c | ||
linux_ioctl.c | ||
linux_ioctl.h | ||
linux_ipc64.h | ||
linux_ipc.c | ||
linux_ipc.h | ||
linux_mib.c | ||
linux_mib.h | ||
linux_misc.c | ||
linux_misc.h | ||
linux_mmap.c | ||
linux_mmap.h | ||
linux_persona.h | ||
linux_signal.c | ||
linux_signal.h | ||
linux_socket.c | ||
linux_socket.h | ||
linux_stats.c | ||
linux_sysctl.c | ||
linux_sysproto.h | ||
linux_time.c | ||
linux_timer.c | ||
linux_timer.h | ||
linux_uid16.c | ||
linux_util.c | ||
linux_util.h | ||
linux_vdso.c | ||
linux_vdso.h | ||
linux_videodev2_compat.h | ||
linux_videodev_compat.h | ||
linux.c | ||
linux.h | ||
stats_timing.d | ||
trace_futexes.d |