Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3712799ybv; Mon, 10 Feb 2020 05:09:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwAEHGPt/++sA1MU61FFf262Kd2hPeIfdNupExczM4aCyq5yBDaIMOihwTWBA3XnwfvZ0CT X-Received: by 2002:aca:c401:: with SMTP id u1mr783555oif.62.1581340197900; Mon, 10 Feb 2020 05:09:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581340197; cv=none; d=google.com; s=arc-20160816; b=l2EhJ3SFmvxeUlGRRy/ilkjVFksFR+vo8pM0B24yvE6ngQdIlJRLfl+aH9y8x1WnD7 1ttyV40k6hZzFvpHJwXsfsN/ddHG/pHTMlvfD24EPAs9JDcaDIx0a5SIZKIaQYSGDOxO 8XTEmLTmfJaZIWHvkYR0xgcLj7VnQ2Fl1mbGQ1KFQeXSp+oOLmws/1GETqYnrw08N1ML 7y+jkSkhGgoh75V9cqm9esheJ8fHE0pk9ZSerHYHQvDhY3hMH5ndL/zxsWYomgxOHUvf JNZnYcKGYH2hgNJUEpBCo7HZ8G+wYWDdv0u+Zl4A6h10sriBYToajz1UmVuYAk++Ly3m yM/g== 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=bbx0+mLzM6hdQhNxFIzb4TOoxpVon7A4kuqEVJNbZXY6BfHI0jf8iEan3OluS66XS6 dvsfIifUNVbzvRbi5Eh3278+/bOt4Ac/tHbNZG3qRd0oC54BWGHdvu/0QnaynnlJJ69L f01B1qM1nMd6PvT44LNlpQTHRm7CbnRqNgSMDcaeXT82kGtYPowTKnwq/+A+E2Rl7T4t NlKsiNtUP5xj02ZvtUk6jmGjaUuEfpGiD3WYOlmUYAFwDp4IssjRFH5J4kx0/ekdzHj/ feYqp29qDqaembb2J+yd1+q8a6zNVjhPm4zUiOqazc7wyqPkKfRtaS3kgP3iaud1L/pp v+Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RsP0tKvn; 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 i12si133359oik.171.2020.02.10.05.09.46; Mon, 10 Feb 2020 05:09:57 -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=RsP0tKvn; 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 S1730480AbgBJNJj (ORCPT + 99 others); Mon, 10 Feb 2020 08:09:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:36788 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729387AbgBJMjS (ORCPT ); Mon, 10 Feb 2020 07:39:18 -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 C582420661; Mon, 10 Feb 2020 12:39:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338357; bh=88zAnXw2hLqc8dBEYZYPem3Likizp9uLRhvjzs2exSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RsP0tKvnr+eyE7+uchr3EiAs/LJKoNezv/aS42O1MyNgP/iDo3/6ZcpXbWEQG+WJ8 jzIa0BXUS/Pd3Mftju8YjMSsohouoRzHzlIdNmY8sW2OXuFEJaFCUSXnOD8a9VIzHd kdpCg65lo2TVNsGzrhemjIqxkzINca5xvbpHJdis= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells Subject: [PATCH 5.5 016/367] rxrpc: Fix use-after-free in rxrpc_put_local() Date: Mon, 10 Feb 2020 04:28:49 -0800 Message-Id: <20200210122425.363774826@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122423.695146547@linuxfoundation.org> References: <20200210122423.695146547@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);