mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
locks: fix locks_mandatory_locked to respect file-private locks
As Trond pointed out, you can currently deadlock yourself by setting a file-private lock on a file that requires mandatory locking and then trying to do I/O on it. Avoid this problem by plumbing some knowledge of file-private locks into the mandatory locking code. In order to do this, we must pass down information about the struct file that's being used to locks_verify_locked. Reported-by: Trond Myklebust <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Acked-by: J. Bruce Fields <[email protected]>
This commit is contained in:
parent
90478939dc
commit
d7a06983a0
5 changed files with 18 additions and 17 deletions
|
|
@ -1155,13 +1155,14 @@ EXPORT_SYMBOL(posix_lock_file_wait);
|
|||
|
||||
/**
|
||||
* locks_mandatory_locked - Check for an active lock
|
||||
* @inode: the file to check
|
||||
* @file: the file to check
|
||||
*
|
||||
* Searches the inode's list of locks to find any POSIX locks which conflict.
|
||||
* This function is called from locks_verify_locked() only.
|
||||
*/
|
||||
int locks_mandatory_locked(struct inode *inode)
|
||||
int locks_mandatory_locked(struct file *file)
|
||||
{
|
||||
struct inode *inode = file_inode(file);
|
||||
fl_owner_t owner = current->files;
|
||||
struct file_lock *fl;
|
||||
|
||||
|
|
@ -1172,7 +1173,7 @@ int locks_mandatory_locked(struct inode *inode)
|
|||
for (fl = inode->i_flock; fl != NULL; fl = fl->fl_next) {
|
||||
if (!IS_POSIX(fl))
|
||||
continue;
|
||||
if (fl->fl_owner != owner)
|
||||
if (fl->fl_owner != owner && fl->fl_owner != (fl_owner_t)file)
|
||||
break;
|
||||
}
|
||||
spin_unlock(&inode->i_lock);
|
||||
|
|
|
|||
Loading…
Reference in a new issue