mirror of
https://github.com/adulau/aha.git
synced 2024-12-29 04:06:22 +00:00
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>
This commit is contained in:
parent
06735b3454
commit
039c4d7a82
1 changed files with 18 additions and 9 deletions
|
@ -376,22 +376,31 @@ out_swapfile:
|
||||||
|
|
||||||
static int do_getlk(struct file *filp, int cmd, struct file_lock *fl)
|
static int do_getlk(struct file *filp, int cmd, struct file_lock *fl)
|
||||||
{
|
{
|
||||||
|
struct file_lock *cfl;
|
||||||
struct inode *inode = filp->f_mapping->host;
|
struct inode *inode = filp->f_mapping->host;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
lock_kernel();
|
lock_kernel();
|
||||||
/* Use local locking if mounted with "-onolock" */
|
/* Try local locking first */
|
||||||
if (!(NFS_SERVER(inode)->flags & NFS_MOUNT_NONLM))
|
cfl = posix_test_lock(filp, fl);
|
||||||
status = NFS_PROTO(inode)->lock(filp, cmd, fl);
|
if (cfl != NULL) {
|
||||||
else {
|
locks_copy_lock(fl, cfl);
|
||||||
struct file_lock *cfl = posix_test_lock(filp, fl);
|
goto out;
|
||||||
|
|
||||||
fl->fl_type = F_UNLCK;
|
|
||||||
if (cfl != NULL)
|
|
||||||
memcpy(fl, cfl, sizeof(*fl));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
unlock_kernel();
|
||||||
return status;
|
return status;
|
||||||
|
out_noconflict:
|
||||||
|
fl->fl_type = F_UNLCK;
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int do_vfs_lock(struct file *file, struct file_lock *fl)
|
static int do_vfs_lock(struct file *file, struct file_lock *fl)
|
||||||
|
|
Loading…
Reference in a new issue