kernel - Fix /dev/fd/N and clean up the old dup error-code-driven path
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 20 Mar 2021 02:27:11 +0000 (19:27 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sun, 21 Mar 2021 18:44:15 +0000 (11:44 -0700)
commit5bd455973731fc90e519dbed944ca7806eb8c424
tree11db3cc882bb659b63db3d62b12a0b6c070aa3a9
parent9d0b0704e9d61582dd7d2fde998fecc0aeb259bf
kernel - Fix /dev/fd/N and clean up the old dup error-code-driven path

* When opening /dev/fd/N, replicate the file pointer for descriptors
  that represent vnodes instead of dup()ing.  This ensures that the seek
  offset and other fp-related elements are not shared unexpectedly.

* Refactor the open() path to allow dev_dopen() to replace the
  struct file by passing a struct file ** instead of a struct file *.
  This removes old error-code-based hacks.

* This fixes the shared seek position that fexecve() was operating with
  due to its use of /dev/fd/N for scripts.

Reported-by: aly
24 files changed:
sys/bus/u4b/usb_dev.c
sys/dev/drm/drm_file.c
sys/dev/misc/evdev/cdev.c
sys/dev/misc/ipmi/ipmi.c
sys/kern/kern_descrip.c
sys/kern/kern_device.c
sys/kern/kern_fp.c
sys/kern/kern_shutdown.c
sys/kern/subr_diskiocom.c
sys/kern/subr_diskslice.c
sys/kern/tty_cons.c
sys/kern/vfs_default.c
sys/kern/vfs_syscalls.c
sys/kern/vfs_vnops.c
sys/kern/vfs_vopops.c
sys/sys/device.h
sys/sys/filedesc.h
sys/sys/proc.h
sys/sys/vfsops.h
sys/sys/vnode.h
sys/vfs/devfs/devfs_vnops.c
sys/vfs/fuse/fuse_device.c
sys/vfs/fuse/fuse_io.c
sys/vfs/fuse/fuse_vnops.c