]> git.baikalelectronics.ru Git - kernel.git/commit
afs: Fix clearance of reply
authorDavid Howells <dhowells@redhat.com>
Mon, 15 Oct 2018 11:43:02 +0000 (12:43 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Oct 2018 13:31:47 +0000 (15:31 +0200)
commit0f82fe1528896ac9f60d474a4d69a69a35bb6a0c
treee1f73c1b06efe3f537da1a1667af9cff253079ab
parent56b5fbe60d89c3a08499c655cf014ee93f60ad15
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 ecc6ab04dbbd 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 ecc6ab04dbbd.

 (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: ecc6ab04dbbd ("afs: Fix afs_server struct leak")
Fixes: 1d83f55459ef ("[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>
fs/afs/rxrpc.c
fs/afs/server.c