kernel - Fix devfs bitmap races for pty and other devices
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 22 Aug 2019 15:31:29 +0000 (08:31 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 22 Aug 2019 15:31:29 +0000 (08:31 -0700)
commit1991e949fd5daddb34cbf77ff2b492cd33ac0570
tree35abcebdb063b2c8c1d6fe148f650e4797cec521
parent8d9409b8a068bae6aff004f897140a131d6e78fb
kernel - Fix devfs bitmap races for pty and other devices

* Use an internal lock to protect the integrity of bitmap
  operations for devfs_clone_bitmap_*() functions, allowing
  devices to use the functions without having to lock themselves.

* Devices which use devfs_clone_bitmap_chk() + devfs_clone_bitmap_set()
  sequences have to be more careful, either having their own covering
  lock or checking the return code from devfs_clone_bitmap_set() and
  looping.

* This fixes serious /dev/ptmx pty allocation races which become obvious
  when pty's are allocated concurrently at a high rate, such as by the
  dsynth code.
sys/dev/disk/vn/vn.c
sys/dev/misc/snp/snp.c
sys/net/bpf.c
sys/sys/devfs.h
sys/vfs/devfs/devfs_helper.c