Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3731608ybv; Mon, 10 Feb 2020 05:28:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwWTmoU6OxdCAs89wfjbzBQntGNGPyf/ps9833BsQF0wTlYxA0mrUzHAkFodnx9sTdu6ONp X-Received: by 2002:a05:6830:22ee:: with SMTP id t14mr1049972otc.236.1581341338519; Mon, 10 Feb 2020 05:28:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581341338; cv=none; d=google.com; s=arc-20160816; b=ok1VN9EFYAk/jP6SDy6V+7CQw0WkCshui+YJOCkHMnZPK9i4xOHtfpOUhL0O8F609M LDSQt/z21YiBSekmBFYhTqBO/U9uEmSZmI0mSUwa4Gs4x8ZcT7Yat8Ref0qCIatBWyGd 2ddxTMuo/kD/YlWjCa+klI3xGj6bSn1jFseatwUR6YWmT+jzpV/ElPSpDfJDXyA6Mv4Z WLg2BgEF4UUNXFrL/pEXzasIHwRnNcNUGbQVkMfvOXpsu9o1qd1LkfxADJUKWqBaL7Pz 9aT6+f0WXz05Z5+NG1l5muzMT8yWI/58RFDi3XjcXtOYgjLxZnMNrCwfyqzLIaGgGI14 Y8JQ== 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=yj0HQKJtZ0VBnfTf28Dj5JyRheAn0S24j6f9PzujvZE=; b=hN+7gzk0XKkR0ZSVozfBRI1qj42u/wMIF/QCHCDSKP+HmipH/EC7ZOD68UJS18uUEV n/bzjn76a+HKdU/h8cWhQdNgFqk0SBDZIQcvrHAwFqnfqBluWuEq+KvS4ujQugYbutJd OR6lUONiYZ4koiib8/k6VjqzmGwNXDK2RSZZnSZ/17FbApvwOa7ewTXqWAAWWVDTsRci yfgDFePFXprYFvPKBwNgLMEztJIRbUQVlicdxoRdr14AS0GBTJ5D5reJeAnNlpRLo+jv m5HfP+lAjBrkLfUOY32+86Qlg3bsjPI1GuTwcK3WdVp8Fo3I2tqr5zd8LprE//qgWPO7 6asg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="QPw8ia/d"; 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 g18si194448otp.61.2020.02.10.05.28.47; Mon, 10 Feb 2020 05:28:58 -0800 (PST) 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="QPw8ia/d"; 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 S1731206AbgBJN1Q (ORCPT + 99 others); Mon, 10 Feb 2020 08:27:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:56418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728449AbgBJMgh (ORCPT ); Mon, 10 Feb 2020 07:36:37 -0500 Received: from localhost (unknown [209.37.97.194]) (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 64BAA20873; Mon, 10 Feb 2020 12:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338197; bh=88zAnXw2hLqc8dBEYZYPem3Likizp9uLRhvjzs2exSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QPw8ia/dwTZLye+Ml57T/jV8ipcLwb+nDlA+leN599Y6fxHvbN3eZ7cpznCE2wlgL yN90wrK8cK5iCR11rDBmpoG2Vo0eB9/tVlzLjfbyFueb/LHykzDtM2yFXC6UI8Imk1 fQY1oi80a73WdMcuWx8I82nzCDA5r1O2qkXOXeS0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells Subject: [PATCH 5.4 010/309] rxrpc: Fix use-after-free in rxrpc_put_local() Date: Mon, 10 Feb 2020 04:29:26 -0800 Message-Id: <20200210122407.044750061@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122406.106356946@linuxfoundation.org> References: <20200210122406.106356946@linuxfoundation.org> User-Agent: quilt/0.66 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 From: David Howells [ Upstream commit fac20b9e738523fc884ee3ea5be360a321cd8bad ] Fix rxrpc_put_local() to not access local->debug_id after calling atomic_dec_return() as, unless that returned n==0, we no longer have the right to access the object. Fixes: 06d9532fa6b3 ("rxrpc: Fix read-after-free in rxrpc_queue_local()") Signed-off-by: David Howells Signed-off-by: Greg Kroah-Hartman --- net/rxrpc/local_object.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/net/rxrpc/local_object.c +++ b/net/rxrpc/local_object.c @@ -364,11 +364,14 @@ void rxrpc_queue_local(struct rxrpc_loca void rxrpc_put_local(struct rxrpc_local *local) { const void *here = __builtin_return_address(0); + unsigned int debug_id; int n; if (local) { + debug_id = local->debug_id; + n = atomic_dec_return(&local->usage); - trace_rxrpc_local(local->debug_id, rxrpc_local_put, n, here); + trace_rxrpc_local(debug_id, rxrpc_local_put, n, here); if (n == 0) call_rcu(&local->rcu, rxrpc_local_rcu);