[PATCH] Splitting a posix lock causes an infinite loop

From: Stephen Rothwell (sfr@linuxcare.com)
Date: Fri Aug 11 2000 - 02:44:19 EST


Hi Willy,

Chris Yeoh has been doing more Posix compliance testing and managed to find
a test that locked the kernel tight. Basically, splitting a fcntl lock
(by unlocking the middle of an existing one) would cause a lock to
point to itself in a couple of lists! The next time you try to take
a lock on the same file, you end up spinning inside the kernel.
(cat'ting /proc/locks was very bad as well! :-))

Please apply this patch:

--- 2.4.0-test6/fs/locks.c Tue Jul 11 12:08:08 2000
+++ 2.4.0-test6-fixed/fs/locks.c Fri Aug 11 17:37:22 2000
@@ -816,13 +816,12 @@
         if (right) {
                 if (left == right) {
                         /* The new lock breaks the old one in two pieces,
- * so we have to use the second new lock (in this
- * case, even F_UNLCK may fail!).
+ * so we have to use the second new lock.
                          */
- locks_copy_lock(new_fl2, right);
- locks_insert_lock(before, left);
                         left = new_fl2;
                         new_fl2 = NULL;
+ locks_copy_lock(left, right);
+ locks_insert_lock(before, left);
                 }
                 right->fl_start = caller->fl_end + 1;
                 locks_wake_up_blocks(right, 0);

Cheers,
Stephen

-- 
Stephen Rothwell, Open Source Researcher, Linuxcare, Inc.
+61-2-62628990 tel, +61-2-62628991 fax 
sfr@linuxcare.com, http://www.linuxcare.com/ 
Linuxcare. Support for the revolution.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:23 EST