aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/file.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2008-05-20 19:34:39 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-07-09 12:08:40 -0400
commit2116271a347d1181b5497602c2bfada1de8fd53b (patch)
tree537498aa91bbe1fbbfc7f2c1e00910ca7fbc2261 /fs/nfs/file.c
parentf3d47a3a6a1484a93c8cfe1e8c8d4399c95199c7 (diff)
NFS: Add correct bounds checking to NFSv2 locks
NFSv2 file locking currently fails the Connectathon tests, because the calls to the VFS locking code do not return an EINVAL error if the struct file_lock overflows the 32-bit boundaries. The problem is due to the fact that we occasionally call helpers from fs/locks.c in order to avoid RPC calls to the server when we know that a local process holds the lock. These helpers are, of course, always 64-bit enabled, so EINVAL is not returned in cases when it would if the call had gone to the NLM code. For consistency, we therefore add support for a bounds-checking helper. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/file.c')
-rw-r--r--fs/nfs/file.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index d84a3d8f32af..7c73f06692b6 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -593,6 +593,7 @@ out:
593static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl) 593static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
594{ 594{
595 struct inode * inode = filp->f_mapping->host; 595 struct inode * inode = filp->f_mapping->host;
596 int ret = -ENOLCK;
596 597
597 dprintk("NFS: nfs_lock(f=%s/%ld, t=%x, fl=%x, r=%Ld:%Ld)\n", 598 dprintk("NFS: nfs_lock(f=%s/%ld, t=%x, fl=%x, r=%Ld:%Ld)\n",
598 inode->i_sb->s_id, inode->i_ino, 599 inode->i_sb->s_id, inode->i_ino,
@@ -602,13 +603,22 @@ static int nfs_lock(struct file *filp, int cmd, struct file_lock *fl)
602 603
603 /* No mandatory locks over NFS */ 604 /* No mandatory locks over NFS */
604 if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK) 605 if (__mandatory_lock(inode) && fl->fl_type != F_UNLCK)
605 return -ENOLCK; 606 goto out_err;
607
608 if (NFS_PROTO(inode)->lock_check_bounds != NULL) {
609 ret = NFS_PROTO(inode)->lock_check_bounds(fl);
610 if (ret < 0)
611 goto out_err;
612 }
606 613
607 if (IS_GETLK(cmd)) 614 if (IS_GETLK(cmd))
608 return do_getlk(filp, cmd, fl); 615 ret = do_getlk(filp, cmd, fl);
609 if (fl->fl_type == F_UNLCK) 616 else if (fl->fl_type == F_UNLCK)
610 return do_unlk(filp, cmd, fl); 617 ret = do_unlk(filp, cmd, fl);
611 return do_setlk(filp, cmd, fl); 618 else
619 ret = do_setlk(filp, cmd, fl);
620out_err:
621 return ret;
612} 622}
613 623
614/* 624/*