cvs commit: src/sys/kern uipc_usrreq.c

Robert Watson rwatson at FreeBSD.org
Thu Jun 10 21:34:58 GMT 2004


rwatson     2004-06-10 21:34:38 UTC

  FreeBSD src repository

  Modified files:
    sys/kern             uipc_usrreq.c 
  Log:
  Introduce a subsystem lock around UNIX domain sockets in order to protect
  global and allocated variables.  This strategy is derived from work
  originally developed by BSDi for BSD/OS, and applied to FreeBSD by Sam
  Leffler:
  
  - Add unp_mtx, a global mutex which will protect all UNIX domain socket
    related variables, structures, etc.
  
  - Add UNP_LOCK(), UNP_UNLOCK(), UNP_LOCK_ASSERT() macros.
  
  - Acquire unp_mtx on entering most UNIX domain socket code,
    drop/re-acquire around calls into VFS, and release it on return.
  
  - Avoid performing sodupsockaddr() while holding the mutex, so in general
    move to allocating storage before acquiring the mutex to copy the data.
  
  - Make a stack copy of the xucred rather than copying out while holding
    unp_mtx.  Copy the peer credential out after releasing the mutex.
  
  - Add additional assertions of vnode locks following VOP_CREATE().
  
  A few notes:
  
  - Use of an sx lock for the file list mutex may cause problems with regard
    to unp_mtx when garbage collection passed file descriptors.
  
  - The locking in unp_pcblist() for sysctl monitoring is correct subject to
    the unpcb zone not returning memory for reuse by other subsystems
    (consistent with similar existing concerns).
  
  - Sam's version of this change, as with the BSD/OS version, made use of
    both a global lock and per-unpcb locks.  However, in practice, the
    global lock covered all accesses, so I have simplified out the unpcb
    locks in the interest of getting this merged faster (reducing the
    overhead but not sacrificing granularity in most cases).  We will want
    to explore possibilities for improving lock granularity in this code in
    the future.
  
  Submitted by:   sam
  Sponsored by:   FreeBSD Foundatiuon
  Obtained from:  BSD/OS 5 snapshot provided by BSDi
  
  Revision  Changes    Path
  1.122     +193 -58   src/sys/kern/uipc_usrreq.c


More information about the cvs-src mailing list