]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
fix SMP ordering hole in fcntl_setlk() (CVE-2008-1669)
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 6 May 2008 17:58:34 +0000 (13:58 -0400)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 6 May 2008 23:21:10 +0000 (16:21 -0700)
commitc493a1dd8b3a93b57208319a77a8238f76dabca2
treef21c54225f9ce7b1954041463470263bd043316e
parent1420f09c0b8a88f9df2034e6ba04fcc4c3f6925e
fix SMP ordering hole in fcntl_setlk() (CVE-2008-1669)

commit 0b2bac2f1ea0d33a3621b27ca68b9ae760fca2e9 upstream.

fcntl_setlk()/close() race prevention has a subtle hole - we need to
make sure that if we *do* have an fcntl/close race on SMP box, the
access to descriptor table and inode->i_flock won't get reordered.

As it is, we get STORE inode->i_flock, LOAD descriptor table entry vs.
STORE descriptor table entry, LOAD inode->i_flock with not a single
lock in common on both sides.  We do have BKL around the first STORE,
but check in locks_remove_posix() is outside of BKL and for a good
reason - we don't want BKL on common path of close(2).

Solution is to hold ->file_lock around fcheck() in there; that orders
us wrt removal from descriptor table that preceded locks_remove_posix()
on close path and we either come first (in which case eviction will be
handled by the close side) or we'll see the effect of close and do
eviction ourselves.  Note that even though it's read-only access,
we do need ->file_lock here - rcu_read_lock() won't be enough to
order the things.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
fs/locks.c