aboutsummaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorOlaf Kirch <okir@suse.de>2005-08-25 16:25:35 -0700
committerTrond Myklebust <Trond.Myklebust@netapp.com>2005-09-23 12:37:59 -0400
commit449231d6ddf50ca46b7fb2f76ecf790135222913 (patch)
tree0c493d7f4fb68f1f639c56258bcd025d5b904fb0 /fs
parent20509f1bc553ed7fafa88fa8d01c6212d1876d9f (diff)
From: Olaf Kirch <okir@suse.de>
[PATCH] Fix miscompare in __posix_lock_file If an application requests the same lock twice, the kernel should just leave the existing lock in place. Currently, it will install a second lock of the same type. Signed-off-by: Olaf Kirch <okir@suse.de> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/locks.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/fs/locks.c b/fs/locks.c
index f7daa5f4894..7eb1d77b920 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -829,12 +829,16 @@ static int __posix_lock_file(struct inode *inode, struct file_lock *request)
/* Detect adjacent or overlapping regions (if same lock type)
*/
if (request->fl_type == fl->fl_type) {
+ /* In all comparisons of start vs end, use
+ * "start - 1" rather than "end + 1". If end
+ * is OFFSET_MAX, end + 1 will become negative.
+ */
if (fl->fl_end < request->fl_start - 1)
goto next_lock;
/* If the next lock in the list has entirely bigger
* addresses than the new one, insert the lock here.
*/
- if (fl->fl_start > request->fl_end + 1)
+ if (fl->fl_start - 1 > request->fl_end)
break;
/* If we come here, the new and old lock are of the