Skip to content

Commit f0a7d18

Browse files
dhowellsgregkh
authored andcommitted
afs: Fix clearance of reply
The recent patch to fix the afs_server struct leak didn't actually fix the bug, but rather fixed some of the symptoms. The problem is that an asynchronous call that holds a resource pointed to by call->reply[0] will find the pointer cleared in the call destructor, thereby preventing the resource from being cleaned up. In the case of the server record leak, the afs_fs_get_capabilities() function in devel code sets up a call with reply[0] pointing at the server record that should be altered when the result is obtained, but this was being cleared before the destructor was called, so the put in the destructor does nothing and the record is leaked. Commit f014ffb removed the additional ref obtained by afs_install_server(), but the removal of this ref is actually used by the garbage collector to mark a server record as being defunct after the record has expired through lack of use. The offending clearance of call->reply[0] upon completion in afs_process_async_call() has been there from the origin of the code, but none of the asynchronous calls actually use that pointer currently, so it should be safe to remove (note that synchronous calls don't involve this function). Fix this by the following means: (1) Revert commit f014ffb. (2) Remove the clearance of reply[0] from afs_process_async_call(). Without this, afs_manage_servers() will suffer an assertion failure if it sees a server record that didn't get used because the usage count is not 1. Fixes: f014ffb ("afs: Fix afs_server struct leak") Fixes: 08e0e7c ("[AF_RXRPC]: Make the in-kernel AFS filesystem use AF_RXRPC.") Signed-off-by: David Howells <dhowells@redhat.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 35a7f35 commit f0a7d18

File tree

2 files changed

+0
-4
lines changed

2 files changed

+0
-4
lines changed

fs/afs/rxrpc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -690,8 +690,6 @@ static void afs_process_async_call(struct work_struct *work)
690690
}
691691

692692
if (call->state == AFS_CALL_COMPLETE) {
693-
call->reply[0] = NULL;
694-
695693
/* We have two refs to release - one from the alloc and one
696694
* queued with the work item - and we can't just deallocate the
697695
* call because the work item may be queued again.

fs/afs/server.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,9 @@ static struct afs_server *afs_install_server(struct afs_net *net,
199199

200200
write_sequnlock(&net->fs_addr_lock);
201201
ret = 0;
202-
goto out;
203202

204203
exists:
205204
afs_get_server(server);
206-
out:
207205
write_sequnlock(&net->fs_lock);
208206
return server;
209207
}

0 commit comments

Comments
 (0)