freebsd-skq/sys/compat
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
..
cloudabi vfs: drop the mostly unused flags argument from VOP_UNLOCK 2020-01-03 22:29:58 +00:00
cloudabi32 sysent: Reduce duplication and improve readability. 2019-12-06 23:59:23 +00:00
cloudabi64 sysent: Reduce duplication and improve readability. 2019-12-06 23:59:23 +00:00
freebsd32 Copy out aux args after the argument and environment vectors. 2019-12-09 19:17:28 +00:00
ia32 Use uintptr_t instead of register_t * for the stack base. 2019-12-03 23:17:54 +00:00
lindebugfs LinuxKPI: Finalize move of lindebugfs from ports to base. 2019-05-19 15:44:21 +00:00
linprocfs Make linprocfs(5) provide an empty /proc/modules. This should silence 2019-12-29 15:46:59 +00:00
linsysfs Create a "drm" subdirectory for drm devices in linsysfs. Recent versions of 2019-09-23 12:27:55 +00:00
linux kern_mmap: add a variant that allows caller to inspect fp 2020-01-04 23:39:58 +00:00
linuxkpi/common vfs: drop the mostly unused flags argument from VOP_UNLOCK 2020-01-03 22:29:58 +00:00
ndis vfs: drop the mostly unused flags argument from VOP_UNLOCK 2020-01-03 22:29:58 +00:00
netbsd sys/compat: further adoption of SPDX licensing ID tags. 2017-11-27 15:13:23 +00:00
x86bios x86bios: use M_NOWAIT with mallocs 2018-09-13 07:04:00 +00:00