NFS: Revert "NFS: Move the flock open mode check into nfs_flock()"
commitfcfa447062
upstream. Commite12937279c
"NFS: Move the flock open mode check into nfs_flock()" changed NFSv3 behavior for flock() such that the open mode must match the lock type, however that requirement shouldn't be enforced for flock(). Signed-off-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
afaacc000e
commit
57f3c05d03
@ -6568,6 +6568,20 @@ nfs4_proc_lock(struct file *filp, int cmd, struct file_lock *request)
|
||||
!test_bit(NFS_STATE_POSIX_LOCKS, &state->flags))
|
||||
return -ENOLCK;
|
||||
|
||||
/*
|
||||
* Don't rely on the VFS having checked the file open mode,
|
||||
* since it won't do this for flock() locks.
|
||||
*/
|
||||
switch (request->fl_type) {
|
||||
case F_RDLCK:
|
||||
if (!(filp->f_mode & FMODE_READ))
|
||||
return -EBADF;
|
||||
break;
|
||||
case F_WRLCK:
|
||||
if (!(filp->f_mode & FMODE_WRITE))
|
||||
return -EBADF;
|
||||
}
|
||||
|
||||
status = nfs4_set_lock_state(state, request);
|
||||
if (status != 0)
|
||||
return status;
|
||||
|
Reference in New Issue
Block a user