Commit 039c4d7a authored by Trond Myklebust's avatar Trond Myklebust
Browse files

NFS: Fix up a race in the NFS implementation of GETLK

 ...and fix a memory corruption bug due to improper use of memcpy() on
 a struct file_lock.

Signed-off-by: default avatarTrond Myklebust <>
parent 06735b34
......@@ -376,22 +376,31 @@ out_swapfile:
static int do_getlk(struct file *filp, int cmd, struct file_lock *fl)
struct file_lock *cfl;
struct inode *inode = filp->f_mapping->host;
int status = 0;
/* Use local locking if mounted with "-onolock" */
if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM))
status = NFS_PROTO(inode)->lock(filp, cmd, fl);
else {
struct file_lock *cfl = posix_test_lock(filp, fl);
fl->fl_type = F_UNLCK;
if (cfl != NULL)
memcpy(fl, cfl, sizeof(*fl));
/* Try local locking first */
cfl = posix_test_lock(filp, fl);
if (cfl != NULL) {
locks_copy_lock(fl, cfl);
goto out;
if (nfs_have_delegation(inode, FMODE_READ))
goto out_noconflict;
if (NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM)
goto out_noconflict;
status = NFS_PROTO(inode)->lock(filp, cmd, fl);
return status;
fl->fl_type = F_UNLCK;
goto out;
static int do_vfs_lock(struct file *file, struct file_lock *fl)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment