Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Jun 2003 03:44:42 -0700 (PDT)
From:      Don Lewis <truckman@FreeBSD.org>
To:        current@FreeBSD.org
Subject:   fdrop_locked() and FILE_LOCK() vs. Giant
Message-ID:  <200306171044.h5HAigM7051410@gw.catspoiler.org>

next in thread | raw e-mail | index | archive | help
The FILE_LOCK() implementation uses "pool mutex" under the hood, which
means it should only be used as a leaf level mutex.  The fdrop_locked()
code wants to be called with FILE_LOCK() held, but the fdrop_locked()
implementation calls mtx_lock(&Giant) before calling FILE_UNLOCK().  In
addition to violating the proper usage of the "pool mutex", there is
also the potential for a lock order violation.  The close()
implementation grabs Giant and eventually calls fdrop(), which calls
FILE_LOCK() immediately before calling fdrop_locked().  If another
caller of fdrop_locked() calls FILE_LOCK() without grabbing Giant first,
then the lock order will be reversed when fdrop_locked() grabs Giant.

It looks like fdrop_locked() should require that Giant be grabbed by the
caller before fdrop_locked() is called.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200306171044.h5HAigM7051410>