Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5469104imm; Tue, 16 Oct 2018 10:41:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV61jWYtKVAza4qnspkhvHI/oSwZtetHcU1KEzV27nDkYOvNYqzFVgulWF7Ts5qRxEGLKwMMG X-Received: by 2002:a62:2606:: with SMTP id m6-v6mr22920840pfm.104.1539711717955; Tue, 16 Oct 2018 10:41:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539711717; cv=none; d=google.com; s=arc-20160816; b=fjNN84jIZeMFKrgoex9gzuo8V9wKFsQ1+Cft8L/ByOibH3dyUqF5WEeUL0GmCaMD9Z IAQbyw9qdzAaOjEWzykr2WlxvcYf7lbhykpCYYhiFJJ7rCZkgw5o0+NPrjKWnEzmYoIz jQg2L7ByUGhqkK7JFr2A8XIRJBCy4fhgd+YD1XLxocPMnGLFvqM2g7diEP3cFAyz90Id f3Qbzxte8RDlcJQi6c9RP30gUbrv94QiatmQyz3LFTUfHYEz34Nh7iOWVKkS0SEwFaCZ DFVQEXLBiTj2/EeStNLCt++Mxql1PtEH5s85HTxbDX6aR0ArBbq6LvzGozNqPPW/Yanr fc1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ffOEaS8wBVy59kZW9w4pLQxA6wgTX0K0+PA3UIztuME=; b=Q4GIVOUwNIKuPLn1YqYc3vSiksSzRrtA4L6l2W7g/LTExNP7jJvXGgrIgQ65BkEjyo uVLa/SDUoTgbSsWAPjypWtgnYh7EyOMpI/qKUzGmnRPS2GKhjqm1JlAG0fjcuic4TXkv CtSucbPlnEgxH3jIdFEIkCJ8JrAUWVcN3nZ6cfLftoTMrPLFxZP7lqtdSGdgOj46xE4X Vh/7ICQ4C83DFBd7cQOWhWLODRmXAaU3gxUVsIKPw02oBgNI2eBo+9eAb0/HFDVyWJSU fm29TSals/3VrCN8Zk1KDvY/ZUCAvS26UlbjvBUgk6Tw2S/a1Bf7LBQto4wBx41Yfsrk HfQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e5u3LSr6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w90-v6si14692823pfk.208.2018.10.16.10.41.42; Tue, 16 Oct 2018 10:41:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=e5u3LSr6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729428AbeJQBG6 (ORCPT + 99 others); Tue, 16 Oct 2018 21:06:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:51126 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728422AbeJQBG6 (ORCPT ); Tue, 16 Oct 2018 21:06:58 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 333592089E; Tue, 16 Oct 2018 17:15:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539710133; bh=TbY17Jf0SnyPu7F6grMWhfbxNs3GPunck/oCLjLMdfU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e5u3LSr6TktQAJSFM1ZOA1Azxmn5ONZEFt8o5QtggmkpmYX2Nz9hR8D5EeXLcoMz5 TCaV3NLkGhF35CLWs0mUw4dAiTRLhEG8KbXHabxYRpXIdyXG1/aZtscTi7A0vR/1w8 jQC7vQUMoXJ+txoyI2+ICc/oO0UnwDuWWFNlczMU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells Subject: [PATCH 4.18 112/135] afs: Fix clearance of reply Date: Tue, 16 Oct 2018 19:05:42 +0200 Message-Id: <20181016170523.063427203@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181016170515.447235311@linuxfoundation.org> References: <20181016170515.447235311@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Howells commit f0a7d1883d9f78ae7bf15fc258bf9a2b20f35b76 upstream. 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 f014ffb025c1 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 f014ffb025c1. (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: f014ffb025c1 ("afs: Fix afs_server struct leak") Fixes: 08e0e7c82eea ("[AF_RXRPC]: Make the in-kernel AFS filesystem use AF_RXRPC.") Signed-off-by: David Howells Cc: stable Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- fs/afs/rxrpc.c | 2 -- fs/afs/server.c | 2 -- 2 files changed, 4 deletions(-) --- a/fs/afs/rxrpc.c +++ b/fs/afs/rxrpc.c @@ -690,8 +690,6 @@ static void afs_process_async_call(struc } if (call->state == AFS_CALL_COMPLETE) { - call->reply[0] = NULL; - /* We have two refs to release - one from the alloc and one * queued with the work item - and we can't just deallocate the * call because the work item may be queued again. --- a/fs/afs/server.c +++ b/fs/afs/server.c @@ -199,11 +199,9 @@ static struct afs_server *afs_install_se write_sequnlock(&net->fs_addr_lock); ret = 0; - goto out; exists: afs_get_server(server); -out: write_sequnlock(&net->fs_lock); return server; }