[PATCH 2/2] locks: add warning about mandatory locking races

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Trond Myklebust <trond.myklebust@...>
Cc: Pavel Emelyanov <xemul@...>, Andrew Morton <akpm@...>, Linux Kernel Mailing List <linux-kernel@...>, <devel@...>
Date: Tuesday, September 25, 2007 - 12:56 pm

The mandatory file locking implementation has long-standing races that
probably render it useless.  I know of no plans to fix them.  Till we
do, we should at least warn people.

Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
---
 Documentation/filesystems/mandatory-locking.txt |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/Documentation/filesystems/mandatory-locking.txt b/Documentation/filesystems/mandatory-locking.txt
index bc449d4..8ac5cfb 100644
--- a/Documentation/filesystems/mandatory-locking.txt
+++ b/Documentation/filesystems/mandatory-locking.txt
@@ -3,7 +3,26 @@
 		Andy Walker <andy@lysaker.kvaerner.no>
 
 			   15 April 1996
-
+		     (Updated September 2007)
+
+0. Why should I avoid mandatory locking?
+----------------------------------------
+
+The Linux implementation is prey to a number of difficult-to-fix race
+conditions which in practice make it not dependable:
+
+	- The write system call checks for a mandatory lock only once
+	  at its start.  It is therefore possible for a lock request to
+	  be granted after this check but before the data is modified.
+	  A process may then see file data change even while a mandatory
+	  lock was held.
+	- Similarly, an exclusive lock may be granted on a file after
+	  the kernel has decided to proceed with a read, but before the
+	  read has actually completed, and the reading process may see
+	  the file data in a state which should not have been visible
+	  to it.
+	- Similar races make the claimed mutual exclusion between lock
+	  and mmap similarly unreliable.
 
 1. What is  mandatory locking?
 ------------------------------
-- 
1.5.3.1.139.g9346b

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] Wake up mandatory locks waiter on chmod (v2), Pavel Emelyanov, (Mon Sep 17, 4:13 am)
Re: [PATCH] Wake up mandatory locks waiter on chmod (v2), Trond Myklebust, (Mon Sep 17, 9:55 am)
Re: [PATCH] Wake up mandatory locks waiter on chmod (v2), Pavel Emelyanov, (Mon Sep 17, 10:16 am)
Re: [PATCH] Wake up mandatory locks waiter on chmod (v2), Trond Myklebust, (Mon Sep 17, 12:00 pm)
Re: [PATCH] Wake up mandatory locks waiter on chmod (v2), Pavel Emelyanov, (Tue Sep 18, 2:33 am)
Re: [PATCH] Wake up mandatory locks waiter on chmod (v2), J. Bruce Fields, (Tue Sep 18, 11:19 am)
Re: [PATCH] Wake up mandatory locks waiter on chmod (v2), Trond Myklebust, (Tue Sep 18, 12:14 pm)
Re: [PATCH] Wake up mandatory locks waiter on chmod (v2), J. Bruce Fields, (Tue Sep 18, 12:52 pm)
Re: [PATCH] Wake up mandatory locks waiter on chmod (v2), Trond Myklebust, (Tue Sep 18, 12:54 pm)
Re: [PATCH] Wake up mandatory locks waiter on chmod (v2), J. Bruce Fields, (Tue Sep 18, 1:40 pm)
[PATCH 2/2] locks: add warning about mandatory locking races, J. Bruce Fields, (Tue Sep 25, 12:56 pm)