diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-10-18 14:20:16 -0700 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-10-18 14:20:16 -0700 |
commit | 039c4d7a82d8268ec71f59679460b41d0dd9b225 (patch) | |
tree | a2f76afdda97f92df432b5d04e335ee90c42ced6 /fs/nfs | |
parent | 06735b3454824bd561decbde46111f144e905923 (diff) | |
download | kernel_samsung_aries-039c4d7a82d8268ec71f59679460b41d0dd9b225.zip kernel_samsung_aries-039c4d7a82d8268ec71f59679460b41d0dd9b225.tar.gz kernel_samsung_aries-039c4d7a82d8268ec71f59679460b41d0dd9b225.tar.bz2 |
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: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/file.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c index 6bdcfa9..572d859 100644 --- a/fs/nfs/file.c +++ b/fs/nfs/file.c @@ -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; lock_kernel(); - /* 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); +out: unlock_kernel(); return status; +out_noconflict: + fl->fl_type = F_UNLCK; + goto out; } static int do_vfs_lock(struct file *file, struct file_lock *fl) |