Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp704893ybv; Thu, 13 Feb 2020 08:04:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwbRkYroFqcXy+nCbVsNOI0R0XO0MamvP63O3H97pV5CYkw0GOBwhwjtP04ywUc7Br53nls X-Received: by 2002:a05:6830:1296:: with SMTP id z22mr6660349otp.354.1581609869638; Thu, 13 Feb 2020 08:04:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581609869; cv=none; d=google.com; s=arc-20160816; b=0X6HFcniguHrEzm1JG2rY8xWPJ9tXEPAFLpgXUH2ki+FOx5+5MVuURyDEtNJmtfrSk UQ2CV4+pilJ6K28dqBB0WrSmlTsUNTK53ODiOYCwJVUae0zm4Z4ESpLUDxG6xKL+wgxd eLZFpMsDQkR653lbkcyViA33JgfUz5Hj32LPrGY7KCwXjeFPupH4/VALZSWnlVT1c7hs 1HdxnXblnRzsma3/i6F2eoDqV3Bscv5DfwzJng/PnLSpmYvY6Og9X/GRA69NzhFRdpTS k1nyp0oogXigRFIuv2fRk1uxuHEvNK1WkuDoXp3ehUFoWwk0f7F/x2nsCOmNKb5wX45o /dJg== 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=m0H/MBomxz8C/TzgE479NUmNnbO2q4mw8kxuKxwK0so=; b=R9uKOVih35uaPFAwNPeyJi05Nc4M9iu4GsAP0xAKT0j3PAwi1fFJTgoqRV/JmyJsNv NWXMpK2Kq+1/yXn8erhayx34yLLfjC6nCImVuh8b0GOmN9YUV7dKunfs4I+zTN+Ic6kv W3BlBNg1f2a8d3QXkYD7pZcNh3QMDLvC8TvqdE5I1hnqXHZqbd2X8ehQaVsJwx7rUxZD Ueat+Joby+oJd6yXmc1kLgI1YULv6qFdmPZQKDBjU+xmXcYAa0UNxyvOytKGfiE8V7yZ nDs4Q3ikSYrilFKywyVRjiqfXqFHjChHgL95mNp5ekxhcYeexJBMuVRc3+TfxKfJ9DGX E/RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="HPJbT/6s"; 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 c5si1241298otp.108.2020.02.13.08.04.12; Thu, 13 Feb 2020 08:04:29 -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="HPJbT/6s"; 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 S1730269AbgBMQDa (ORCPT + 99 others); Thu, 13 Feb 2020 11:03:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:37392 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387412AbgBMPYR (ORCPT ); Thu, 13 Feb 2020 10:24:17 -0500 Received: from localhost (unknown [104.132.1.104]) (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 E1A15246A4; Thu, 13 Feb 2020 15:24:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607457; bh=MhGbUH1dAkQV7rkFynhtHPmDL7QYfc/Ew0W304b/GjQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HPJbT/6sPCpA3Ts+XpyO4zJWvl0AfQfbfFKlHTy92nX6unVUBZGAQ9ZZhaqBObdsw yBHqKg0JnNkQG+eg3DlNOfZ0b3nEZm2LofTdkLLWLQeF7lMxMEDnMxczYLhcGfZrGX l3itKoPpyNLKSaC9jKK7ePaSX2MBvAXdKEVFNVlI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Howells , "David S. Miller" , Sasha Levin Subject: [PATCH 4.9 096/116] rxrpc: Fix service call disconnection Date: Thu, 13 Feb 2020 07:20:40 -0800 Message-Id: <20200213151920.153053666@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151842.259660170@linuxfoundation.org> References: <20200213151842.259660170@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 b39a934ec72fa2b5a74123891f25273a38378b90 ] The recent patch that substituted a flag on an rxrpc_call for the connection pointer being NULL as an indication that a call was disconnected puts the set_bit in the wrong place for service calls. This is only a problem if a call is implicitly terminated by a new call coming in on the same connection channel instead of a terminating ACK packet. In such a case, rxrpc_input_implicit_end_call() calls __rxrpc_disconnect_call(), which is now (incorrectly) setting the disconnection bit, meaning that when rxrpc_release_call() is later called, it doesn't call rxrpc_disconnect_call() and so the call isn't removed from the peer's error distribution list and the list gets corrupted. KASAN finds the issue as an access after release on a call, but the position at which it occurs is confusing as it appears to be related to a different call (the call site is where the latter call is being removed from the error distribution list and either the next or pprev pointer points to a previously released call). Fix this by moving the setting of the flag from __rxrpc_disconnect_call() to rxrpc_disconnect_call() in the same place that the connection pointer was being cleared. Fixes: 5273a191dca6 ("rxrpc: Fix NULL pointer deref due to call->conn being cleared on disconnect") Signed-off-by: David Howells Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/rxrpc/conn_object.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c index dcf438f677840..e7c89b978587d 100644 --- a/net/rxrpc/conn_object.c +++ b/net/rxrpc/conn_object.c @@ -169,8 +169,6 @@ void __rxrpc_disconnect_call(struct rxrpc_connection *conn, _enter("%d,%x", conn->debug_id, call->cid); - set_bit(RXRPC_CALL_DISCONNECTED, &call->flags); - if (rcu_access_pointer(chan->call) == call) { /* Save the result of the call so that we can repeat it if necessary * through the channel, whilst disposing of the actual call record. @@ -213,6 +211,7 @@ void rxrpc_disconnect_call(struct rxrpc_call *call) __rxrpc_disconnect_call(conn, call); spin_unlock(&conn->channel_lock); + set_bit(RXRPC_CALL_DISCONNECTED, &call->flags); conn->idle_timestamp = jiffies; } -- 2.20.1