Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3696876ybv; Mon, 10 Feb 2020 04:54:23 -0800 (PST) X-Google-Smtp-Source: APXvYqzS/I4tpkqM4fyNOW/xxrXMhN1nI6uQm/fiJiOwHN4IzKwJa1O3a3jljnoESpha0ltBGfzL X-Received: by 2002:a9d:664a:: with SMTP id q10mr892985otm.298.1581339262981; Mon, 10 Feb 2020 04:54:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581339262; cv=none; d=google.com; s=arc-20160816; b=mx4eCyQ3eQ8i2Q8vmuoBHxshq1Z24LqAr4bode5ml0nC5T5n/hp/lkafHJhvZHs8ib T0c5deHAktiIvDhHDYevh42TjOiw8X3D2t2xVEmY85ckUwwWD8afpJKpGaSkp8qS2DDE NPtH58cg4zvd4zxzmlasFa+CRwS+Zq4QGlIy5sZy5oh6P+1GWplVONABPSkrO4z/WDmF tc+gprqV2LPJULJTizfwyTG6aXq4ejfqMnSNmNSs/tPyEgtd+pApJ1Aw83xfU7ICc+P3 ZiXba+RqbahsoChGDdo08+Aq45f+U2r1Vk6fbpJDpaJv9mIGdvaKb+q/olyY8MK7y2Ky UH3Q== 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=i0cPkl4EEC5dYQJ8MKOMsSFXlwzjGZ102orIiMkMJPM=; b=PolcL47wQ1wWW7NBbdpmHR6nqRNHb6J18DsWWu836TpUrikmaW6k/txDYKIhABcMbm pq0yfIYMJuHWZryY6TF2YYSwCCKNHs8GycSjajYkPRjBeAt+0yE7MHf8BLh3f82G69YM pXCmE7qiqJXfTYeJoPR0L/iSUdbB+KkqO5UPbKChVlNtbfWdKZ8AjsVqa3ICdWRkTqKZ Uld/wafKIeCMeOG01Hbq0KJpCcIlwkZ58DXQq/mEhGJrq14eYf9Ir18I7xurXaYReyYt 0IP8r4O8HQejNZkVhN9N5ydxR0JBYLU+JESIOp5/aCJylOgkUzPt9+9ri0xALpoCmzVA Q1AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mpT2vUmr; 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 k10si144975otn.323.2020.02.10.04.54.11; Mon, 10 Feb 2020 04:54:22 -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=mpT2vUmr; 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 S1729406AbgBJMxJ (ORCPT + 99 others); Mon, 10 Feb 2020 07:53:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:46234 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730189AbgBJMmO (ORCPT ); Mon, 10 Feb 2020 07:42:14 -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 A73F621569; Mon, 10 Feb 2020 12:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338533; bh=EyBX9TayLiTZralYPtUvJHjj8z/fIq3LyoI4StE/270=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mpT2vUmr4wRY8iqI7qyfCiwAwEjv6Jjhisv8wv4jMJf0SzI7WK5CUYgBhQFt2wHGh DJ6qL9f4UKW8bciCEnn4OFW9h5A9k/kYva8yvoyb6TylISdo5Rxe/NmSW9OC8N3rCW ioP6WbwWdLQQu/eBiocZeT0SQhxLrvzU0Vy/JJYQ= 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 5.5 360/367] rxrpc: Fix service call disconnection Date: Mon, 10 Feb 2020 04:34:33 -0800 Message-Id: <20200210122455.612514463@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 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 c0b3154f7a7e1..19e141eeed17d 100644 --- a/net/rxrpc/conn_object.c +++ b/net/rxrpc/conn_object.c @@ -171,8 +171,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. @@ -225,6 +223,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