freebsd-dev/sys/compat
Hans Petter Selasky e23ae408c0 Decouple Linux files from the belonging character device right after open
in the LinuxKPI. This is done by calling finit() just before returning a magic
value of ENXIO in the "linux_dev_fdopen" function.

The Linux file structure should mimic the BSD file structure as much as
possible. This patch decouples the Linux file structure from the belonging
character device right after the "linux_dev_fdopen" function has returned.
This fixes an issue which allows a Linux file handle to exist after a
character device has been destroyed and removed from the directory index
of /dev. Only when the reference count of the BSD file handle reaches zero,
the Linux file handle is destroyed. This fixes use-after-free issues related
to accessing the Linux file structure after the character device has been
destroyed.

While at it add a missing NULL check for non-present file operation.
Calling a NULL pointer will result in a segmentation fault.

Reviewed by:	kib @
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2018-01-26 10:49:02 +00:00
..
cloudabi Allow timed waits with relative timeouts on locks and condvars. 2018-01-04 21:57:37 +00:00
cloudabi32 Use mallocarray(9) in CloudABI kernel code where possible. 2018-01-07 22:38:45 +00:00
cloudabi64 Use mallocarray(9) in CloudABI kernel code where possible. 2018-01-07 22:38:45 +00:00
freebsd32 Regenerate auto-generated files 2018-01-12 23:06:35 +00:00
ia32 sys/compat: further adoption of SPDX licensing ID tags. 2017-11-27 15:13:23 +00:00
linprocfs spdx: initial adoption of licensing ID tags. 2017-11-18 14:26:50 +00:00
linsysfs sys/compat: further adoption of SPDX licensing ID tags. 2017-11-27 15:13:23 +00:00
linux sys/compat: further adoption of SPDX licensing ID tags. 2017-11-27 15:13:23 +00:00
linuxkpi/common Decouple Linux files from the belonging character device right after open 2018-01-26 10:49:02 +00:00
ndis Revert r327828, r327949, r327953, r328016-r328026, r328041: 2018-01-21 15:42:36 +00:00
netbsd sys/compat: further adoption of SPDX licensing ID tags. 2017-11-27 15:13:23 +00:00
x86bios x86bios: spelling fix in a comment. 2016-04-30 00:34:04 +00:00