freebsd-dev/sys/compat/linux
Kyle Evans 18348a2369 kern_mmap: add a variant that allows caller to inspect fp
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
2020-01-04 23:39:58 +00:00
..
check_error.d
check_internal_locks.d
linux_common.c Make linux(4) create /dev/shm. Linux applications often expect 2019-11-06 20:53:33 +00:00
linux_common.h Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functions 2019-05-13 17:48:16 +00:00
linux_dtrace.h
linux_emul.c Follow the FreeBSD and implement PDEATH_SIG prctl ops in the Linuxulator. 2019-04-30 17:18:05 +00:00
linux_emul.h Implement PTRACE_O_TRACESYSGOOD. This makes Linux strace(1) work. 2019-05-19 12:58:44 +00:00
linux_errno.c Share Linux errno table with libsysdecode 2018-03-22 12:58:49 +00:00
linux_errno.inc Create new EINTEGRITY error with message "Integrity check failed". 2019-01-17 06:35:45 +00:00
linux_event.c Linux epoll: Allow passing of any negative timeout value to epoll_wait 2019-11-24 20:51:09 +00:00
linux_event.h Linux epoll: Register events with zero event mask 2019-11-24 20:47:40 +00:00
linux_file.c linux(4): implement copy_file_range(2) 2019-12-30 18:11:06 +00:00
linux_file.h Add sync_file_range(2) implementation to linux(4); it's a thin wrapper 2019-12-14 13:37:17 +00:00
linux_fork.c schedlock 1/4 2019-12-15 21:11:15 +00:00
linux_futex.c linux: futex_mtx should follow futex_list 2019-10-18 12:25:33 +00:00
linux_futex.h linux: futex_mtx should follow futex_list 2019-10-18 12:25:33 +00:00
linux_getcwd.c Linuxulator depends on a fundamental kernel settings such as SMP. Many 2019-05-13 18:24:29 +00:00
linux_ioctl.c Implement Linux BLKGETSIZE64 ioctl. 2019-12-29 12:22:11 +00:00
linux_ioctl.h Implement Linux BLKGETSIZE64 ioctl. 2019-12-29 12:22:11 +00:00
linux_ipc64.h
linux_ipc.c Linux between 4.18 and 5.0 split IPC system calls. 2019-03-24 14:44:35 +00:00
linux_ipc.h Update syscall.master to 5.0. 2019-03-24 14:50:02 +00:00
linux_mib.c Add a hack to make ^T work for Linux binaries, enabled with 2019-12-16 20:15:44 +00:00
linux_mib.h Add a hack to make ^T work for Linux binaries, enabled with 2019-12-16 20:15:44 +00:00
linux_misc.c vfs: drop the mostly unused flags argument from VOP_UNLOCK 2020-01-03 22:29:58 +00:00
linux_misc.h Implement Linux syslog(2) syscall; just enough to make Linux dmesg(8) 2019-12-29 15:53:55 +00:00
linux_mmap.c kern_mmap: add a variant that allows caller to inspect fp 2020-01-04 23:39:58 +00:00
linux_mmap.h Let linuxulator mprotect mask unsupported bits before calling kern_mprotect. 2019-07-10 08:19:33 +00:00
linux_persona.h
linux_signal.c Add kern_kill() and use it in Linuxulator. It's just a cleanup, 2019-12-13 18:44:02 +00:00
linux_signal.h Rationalize license text on Linuxolator files 2018-03-23 14:39:34 +00:00
linux_socket.c Complete LOCAL_PEERCRED support. Cache pid of the remote process in the 2019-05-30 14:24:26 +00:00
linux_socket.h Our bsd_to_linux_sockaddr() and linux_to_bsd_sockaddr() functions 2019-05-13 17:48:16 +00:00
linux_stats.c Make Linux stat(2) et al distinguish between block and character 2019-12-29 13:54:02 +00:00
linux_sysctl.c Quiet unused fn warning for linuxulator w/o legacy syscalls 2018-06-25 19:24:50 +00:00
linux_sysproto.h
linux_time.c
linux_timer.c
linux_timer.h
linux_uid16.c compat/linux: Remove obsoleted and somewhat confusing comments related to COMPAT_43. 2019-08-11 19:17:29 +00:00
linux_util.c Add compat.linux.emul_path, so it can be set to something other 2019-12-16 20:07:04 +00:00
linux_util.h Add compat.linux.emul_path, so it can be set to something other 2019-12-16 20:07:04 +00:00
linux_vdso.c Fix the last few cases that grab without busy or valid. The grab functions must 2019-12-02 22:38:25 +00:00
linux_vdso.h
linux_videodev2_compat.h
linux_videodev_compat.h
linux.c Make linux(4) create /dev/shm. Linux applications often expect 2019-11-06 20:53:33 +00:00
linux.h Make linux(4) create /dev/shm. Linux applications often expect 2019-11-06 20:53:33 +00:00
stats_timing.d
trace_futexes.d