Skip to content

Commit

Permalink
afs: Fix key refcounting in file locking code
Browse files Browse the repository at this point in the history
Fix the refcounting of the authentication keys in the file locking code.
The vnode->lock_key member points to a key on which it expects to be
holding a ref, but it isn't always given an extra ref, however.

Fixes: 0fafdc9 ("afs: Fix file locking")
Signed-off-by: David Howells <dhowells@redhat.com>
  • Loading branch information
dhowells committed Jan 17, 2019
1 parent 4882a27 commit 59d4907
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs/afs/flock.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ void afs_lock_work(struct work_struct *work)
/* The new front of the queue now owns the state variables. */
next = list_entry(vnode->pending_locks.next,
struct file_lock, fl_u.afs.link);
vnode->lock_key = afs_file_key(next->fl_file);
vnode->lock_key = key_get(afs_file_key(next->fl_file));
vnode->lock_type = (next->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE;
vnode->lock_state = AFS_VNODE_LOCK_WAITING_FOR_CB;
goto again;
Expand Down Expand Up @@ -413,7 +413,7 @@ static void afs_dequeue_lock(struct afs_vnode *vnode, struct file_lock *fl)
/* The new front of the queue now owns the state variables. */
next = list_entry(vnode->pending_locks.next,
struct file_lock, fl_u.afs.link);
vnode->lock_key = afs_file_key(next->fl_file);
vnode->lock_key = key_get(afs_file_key(next->fl_file));
vnode->lock_type = (next->fl_type == F_RDLCK) ? AFS_LOCK_READ : AFS_LOCK_WRITE;
vnode->lock_state = AFS_VNODE_LOCK_WAITING_FOR_CB;
afs_lock_may_be_available(vnode);
Expand Down
2 changes: 2 additions & 0 deletions fs/afs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ void afs_evict_inode(struct inode *inode)
#endif

afs_put_permits(rcu_access_pointer(vnode->permit_cache));
key_put(vnode->lock_key);
vnode->lock_key = NULL;
_leave("");
}

Expand Down

0 comments on commit 59d4907

Please sign in to comment.