Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 449231d6 authored by Olaf Kirch's avatar Olaf Kirch Committed by Trond Myklebust
Browse files

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: default avatarOlaf Kirch <okir@suse.de>
 Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 20509f1b
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -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)
		/* Detect adjacent or overlapping regions (if same lock type)
		 */
		 */
		if (request->fl_type == fl->fl_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)
			if (fl->fl_end < request->fl_start - 1)
				goto next_lock;
				goto next_lock;
			/* If the next lock in the list has entirely bigger
			/* If the next lock in the list has entirely bigger
			 * addresses than the new one, insert the lock here.
			 * 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;
				break;


			/* If we come here, the new and old lock are of the
			/* If we come here, the new and old lock are of the