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@xxxxxxxxxx> --- 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-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html