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: <1387460065-28269-10-git-send-email-jlayton@redhat.com>
Date:	Thu, 19 Dec 2013 08:34:21 -0500
From:	Jeff Layton <jlayton@...hat.com>
To:	linux-fsdevel@...r.kernel.org
Cc:	nfs-ganesha-devel@...ts.sourceforge.net,
	samba-technical@...ts.samba.org, linux-kernel@...r.kernel.org
Subject: [PATCH v4 09/13] locks: don't reference original flock struct in F_GETLK handlers

The locks code currently sanity checks the type values in the flock
struct before doing the flock->file_lock conversion. That will be
problematic when new l_type values are introduced in a later patch.

Instead, do the flock_to_posix_lock conversion first, and then sanity
check the values in the file_lock instead.

Signed-off-by: Jeff Layton <jlayton@...hat.com>
---
 fs/locks.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index 820322d..8180141 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1905,14 +1905,15 @@ int fcntl_getlk(struct file *filp, struct flock __user *l)
 	error = -EFAULT;
 	if (copy_from_user(&flock, l, sizeof(flock)))
 		goto out;
-	error = -EINVAL;
-	if ((flock.l_type != F_RDLCK) && (flock.l_type != F_WRLCK))
-		goto out;
 
 	error = flock_to_posix_lock(filp, &file_lock, &flock);
 	if (error)
 		goto out;
 
+	error = -EINVAL;
+	if ((file_lock.fl_type != F_RDLCK) && (file_lock.fl_type != F_WRLCK))
+		goto out;
+
 	error = vfs_test_lock(filp, &file_lock);
 	if (error)
 		goto out;
@@ -2073,14 +2074,15 @@ int fcntl_getlk64(struct file *filp, struct flock64 __user *l)
 	error = -EFAULT;
 	if (copy_from_user(&flock, l, sizeof(flock)))
 		goto out;
-	error = -EINVAL;
-	if ((flock.l_type != F_RDLCK) && (flock.l_type != F_WRLCK))
-		goto out;
 
 	error = flock64_to_posix_lock(filp, &file_lock, &flock);
 	if (error)
 		goto out;
 
+	error = -EINVAL;
+	if ((file_lock.fl_type != F_RDLCK) && (file_lock.fl_type != F_WRLCK))
+		goto out;
+
 	error = vfs_test_lock(filp, &file_lock);
 	if (error)
 		goto out;
-- 
1.8.4.2

--
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