From: Trond Myklebust Date: Fri, 31 Mar 2006 10:30:55 +0000 (-0800) Subject: [PATCH] fs/locks.c: Fix sys_flock() race X-Git-Tag: v2.6.17-rc1~79 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=993dfa8776308dcfd311cf77a3bbed4aa11e9868;p=pandora-kernel.git [PATCH] fs/locks.c: Fix sys_flock() race sys_flock() currently has a race which can result in a double free in the multi-thread case. Thread 1 Thread 2 sys_flock(file, LOCK_EX) sys_flock(file, LOCK_UN) If Thread 2 removes the lock from inode->i_lock before Thread 1 tests for list_empty(&lock->fl_link) at the end of sys_flock, then both threads will end up calling locks_free_lock for the same lock. Fix is to make flock_lock_file() do the same as posix_lock_file(), namely to make a copy of the request, so that the caller can always free the lock. This also has the side-effect of fixing up a reference problem in the lockd handling of flock. Signed-off-by: Trond Myklebust Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- Reading git-diff-tree failed