linux/fs/afs
David Howells 34fa47612b afs: Fix race in async call refcounting
There's a race between afs_make_call() and afs_wake_up_async_call() in the
case that an error is returned from rxrpc_kernel_send_data() after it has
queued the final packet.

afs_make_call() will try and clean up the mess, but the call state may have
been moved on thereby causing afs_process_async_call() to also try and to
delete the call.

Fix this by:

 (1) Getting an extra ref for an asynchronous call for the call itself to
     hold.  This makes sure the call doesn't evaporate on us accidentally
     and will allow the call to be retained by the caller in a future
     patch.  The ref is released on leaving afs_make_call() or
     afs_wait_for_call_to_complete().

 (2) In the event of an error from rxrpc_kernel_send_data():

     (a) Don't set the call state to AFS_CALL_COMPLETE until *after* the
     	 call has been aborted and ended.  This prevents
     	 afs_deliver_to_call() from doing anything with any notifications
     	 it gets.

     (b) Explicitly end the call immediately to prevent further callbacks.

     (c) Cancel any queued async_work and wait for the work if it's
     	 executing.  This allows us to be sure the race won't recur when we
     	 change the state.  We put the work queue's ref on the call if we
     	 managed to cancel it.

     (d) Put the call's ref that we got in (1).  This belongs to us as long
     	 as the call is in state AFS_CALL_CL_REQUESTING.

Fixes: 341f741f04 ("afs: Refcount the afs_call struct")
Signed-off-by: David Howells <dhowells@redhat.com>
2019-01-17 15:17:28 +00:00
..
addr_list.c
afs_cm.h
afs_fs.h
afs_vl.h
afs.h
cache.c
callback.c
cell.c
cmservice.c
dir_edit.c
dir.c
dynroot.c
file.c fs: don't open code lru_to_page() 2019-01-04 13:13:48 -08:00
flock.c afs: Fix key refcounting in file locking code 2019-01-17 15:17:28 +00:00
fs_probe.c
fsclient.c
inode.c afs: Fix key refcounting in file locking code 2019-01-17 15:17:28 +00:00
internal.h
Kconfig
main.c
Makefile
misc.c
mntpt.c
netdevices.c
proc.c
protocol_yfs.h afs: Set correct lock type for the yfs CreateFile 2019-01-10 17:12:05 +00:00
rotate.c
rxrpc.c afs: Fix race in async call refcounting 2019-01-17 15:17:28 +00:00
security.c
server_list.c afs: Use struct_size() in kzalloc() 2019-01-10 17:12:05 +00:00
server.c
super.c
vl_list.c
vl_probe.c
vl_rotate.c
vlclient.c
volume.c
write.c
xattr.c
xdr_fs.h
yfsclient.c afs: Set correct lock type for the yfs CreateFile 2019-01-10 17:12:05 +00:00