lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140105203934.GD22918@fieldses.org>
Date:	Sun, 5 Jan 2014 15:39:34 -0500
From:	"J. Bruce Fields" <bfields@...ldses.org>
To:	Jeff Layton <jlayton@...hat.com>
Cc:	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
	nfs-ganesha-devel@...ts.sourceforge.net,
	samba-technical@...ts.samba.org
Subject: Re: [PATCH v3 1/6] locks: consolidate common code in the
 flock_to_posix_lock routines

Ugh, I screwed up one more when rewriting flock{64}_to_posix_lock, an
off-by-one error caused by not noticing that the "end" offset of a lock
is at start + len - 1, not start + len. 

(So for example, a 1-byte lock starting at offset 5 is recorded as
(fl_start, fl_end) == (5, 5), not (5,6)....)

This actually causes "cthon -l" fails as it attempts a lock with
(start, len) == (1, OFFSET_MAX).

--b.

diff --git a/fs/locks.c b/fs/locks.c
index 9523b89..f017280 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -365,16 +365,17 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
 	fl->fl_start += l->l_start;
 	if (fl->fl_start < 0)
 		return -EINVAL;
-	if (l->l_len > 0 && l->l_len - 1 > OFFSET_MAX - fl->fl_start)
-		return -EOVERFLOW;
-	if (fl->fl_start + l->l_len < 0)
-		return -EINVAL;
 
 	/* POSIX-1996 leaves the case l->l_len < 0 undefined;
 	   POSIX-2001 defines it. */
-	if (l->l_len > 0)
+	if (l->l_len > 0) {
+		if (l->l_len - 1 > OFFSET_MAX - fl->fl_start)
+			return -EOVERFLOW;
 		fl->fl_end = fl->fl_start + l->l_len - 1;
-	else if (l->l_len < 0) {
+
+	} else if (l->l_len < 0) {
+		if (fl->fl_start + l->l_len < 0)
+			return -EINVAL;
 		fl->fl_end = fl->fl_start - 1;
 		fl->fl_start += l->l_len;
 	} else
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ