File locking related changes for v3.15 (pile #4)
- fix for regression in handling of F_GETLK commands -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJTcRqbAAoJEAAOaEEZVoIVu4wQALShwSEh77qTKLA7rhJC0AHT AF/P5u7MW8/r6VDkweproB2jEllBKWaOsehhHB+GGpSDYXEyaPVHn8YjfMxP9aI7 ivOCtR0dxJYTAlU+n3WH2fjLnWtyu8/eKFAUpHqFrU0gZnUUtiWSRZwPeKKSggPD WXbOCMIZKHSM5ccyJx93wYxLLto1gLRRGU7jKOamQhkdYfLD+W0N26vpz8JfMqL4 RshdqbHrjHzRKGrerWAHun/jjOcjErb6qBjSEpJSHYad1KuMFm4ViOR0QE9LRJnA 4tt1HovYmeZMtsv8f/sQzArbujyZYZzsosbod22pUG1ms3OYnrOXf9yp3gaj1ocf lRQ9XinnKVkzVi8tdJNchTxx123v8rV1dmU1qC4o/ivR8lhZi+MzdYj66zJi+hlw 11VYcQf+ZfwJxQtOH1lDXMX060QAMTQxDa5v/Cedk2I1oIdG7iYYXW/suyBzwZQs BlBB/eZGxC4iUELu7WN5AWoDei3ubSJTCR6u3KUXrj5CBtQyf2ZUl7nQl6eaqjnb LXETL8YjhZSZXRN8O4B/nTwMnIgVSbgXgpmuSL8l0BfuGTD+YHd+Kopqw2BJp6ic bABwn8NX0Mhaiajd1Qx2QDl4gt23aQM4EUxXnuNk8FZ1f7z9Nc+byetYgOrWvIkn mAACD3ZvWF+w2IwDp9wZ =Pr3z -----END PGP SIGNATURE----- Merge tag 'locks-v3.15-4' of git://git.samba.org/jlayton/linux Pull file locking fix from Jeff Layton: "Fix for regression in handling of F_GETLK commands" * tag 'locks-v3.15-4' of git://git.samba.org/jlayton/linux: locks: only validate the lock vs. f_mode in F_SETLK codepaths
This commit is contained in:
commit
14186fea0c
36
fs/locks.c
36
fs/locks.c
|
@ -389,18 +389,6 @@ static int flock64_to_posix_lock(struct file *filp, struct file_lock *fl,
|
|||
fl->fl_ops = NULL;
|
||||
fl->fl_lmops = NULL;
|
||||
|
||||
/* Ensure that fl->fl_filp has compatible f_mode */
|
||||
switch (l->l_type) {
|
||||
case F_RDLCK:
|
||||
if (!(filp->f_mode & FMODE_READ))
|
||||
return -EBADF;
|
||||
break;
|
||||
case F_WRLCK:
|
||||
if (!(filp->f_mode & FMODE_WRITE))
|
||||
return -EBADF;
|
||||
break;
|
||||
}
|
||||
|
||||
return assign_type(fl, l->l_type);
|
||||
}
|
||||
|
||||
|
@ -2034,6 +2022,22 @@ static int do_lock_file_wait(struct file *filp, unsigned int cmd,
|
|||
return error;
|
||||
}
|
||||
|
||||
/* Ensure that fl->fl_filp has compatible f_mode for F_SETLK calls */
|
||||
static int
|
||||
check_fmode_for_setlk(struct file_lock *fl)
|
||||
{
|
||||
switch (fl->fl_type) {
|
||||
case F_RDLCK:
|
||||
if (!(fl->fl_file->f_mode & FMODE_READ))
|
||||
return -EBADF;
|
||||
break;
|
||||
case F_WRLCK:
|
||||
if (!(fl->fl_file->f_mode & FMODE_WRITE))
|
||||
return -EBADF;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Apply the lock described by l to an open file descriptor.
|
||||
* This implements both the F_SETLK and F_SETLKW commands of fcntl().
|
||||
*/
|
||||
|
@ -2071,6 +2075,10 @@ again:
|
|||
if (error)
|
||||
goto out;
|
||||
|
||||
error = check_fmode_for_setlk(file_lock);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* If the cmd is requesting file-private locks, then set the
|
||||
* FL_OFDLCK flag and override the owner.
|
||||
|
@ -2206,6 +2214,10 @@ again:
|
|||
if (error)
|
||||
goto out;
|
||||
|
||||
error = check_fmode_for_setlk(file_lock);
|
||||
if (error)
|
||||
goto out;
|
||||
|
||||
/*
|
||||
* If the cmd is requesting file-private locks, then set the
|
||||
* FL_OFDLCK flag and override the owner.
|
||||
|
|
Loading…
Reference in New Issue