cvs commit: src/sys/kern kern_conf.c src/sys/sys conf.h

Konstantin Belousov kib at
Mon Mar 17 06:17:10 PDT 2008

kib         2008-03-17 13:17:10 UTC

  FreeBSD src repository

  Modified files:
    sys/kern             kern_conf.c 
    sys/sys              conf.h 
  Fix two races in the handling of the d_gianttrick for the D_NEEDGIANT
  In the giant_XXX wrappers for the device methods of the D_NEEDGIANT
  drivers, do not dereference the cdev->si_devsw. It is racing with
  the destroy_devl() clearing of the si_devsw. Instead, use the
  dev_refthread() and return ENXIO for the destroyed device. [1]
  The check for the D_INIT in the prep_cdevsw() was not synchronized with
  the call of the fini_cdevsw() in destroy_devl(), that under rapid device
  creation/destruction may result in the use of uninitialized cdevsw [2].
  Change the protocol for the prep_cdevsw(), requiring it to be called
  under dev_mtx, where the check for D_INIT is done.
  Do not free the memory allocated for the gianttrick cdevsw while holding
  the dev_mtx, put it into the free list to be freed later. Reuse the
  d_gianttrick pointer to keep the size and layout of the struct cdevsw
  (requested by phk). Free the memory in the dev_unlock_and_free(), and do
  all the free after the dev_mtx is dropped (suggested by jhb).
  Reported by:    bsdimp + many [1], pho [2]
  Reviewed by:    phk, jhb
  Tested by:      pho
  MFC after:      1 week
  Revision  Changes    Path
  1.210     +121 -35   src/sys/kern/kern_conf.c
  1.236     +6 -1      src/sys/sys/conf.h

More information about the cvs-src mailing list