Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3209790pxb; Mon, 9 Nov 2020 05:40:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzCeUw6FV8Z+leSQkv27INFNMatgUk+Ujm4kjy0nAFYAEsrNN8j9Jl0EbkDPvd+t+8Cj+j4 X-Received: by 2002:aa7:cc84:: with SMTP id p4mr15001344edt.97.1604929208829; Mon, 09 Nov 2020 05:40:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604929208; cv=none; d=google.com; s=arc-20160816; b=CQmdfGsMGU6b27Z9V2/Nlj3CUsVcS2uH72KV3VdEFRineVFb9NXzceyacs8SJqrhH4 oTZj+YeZoteTQ6viZqfsHanN/5jVHOnMivnp0E/0Q6SUW/2ZfvsZtHXMDxmzd5pyqFAh 2ZKUV4iDcIzGt7a9lea9KMXWHnrKkCpKhc7oyTf+Ukn3w89HgEFCfChceKySaxuyVBVt PIwlkJFKQkb6y3xccKmS2DcziR4qUCP4RxBKim1LJNYwxrmYYVA3mGOlbvklExP/11W7 C/oX4s1EoXrwyyvtLnndu3EQtOjNfqDZ99Db4YHDHwjIuYI981A+43HSUh8OuDGdHlGQ RlOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TqnvRTkR3hY2bReXSRKz3Ar7RvYyGP0isoJKdUU0LNs=; b=o4ysSsZhNMuiFx0GnD7qcXRPbxdmf2N3BG+CJaiVzwb6laVzjWmw7y95LKb2yiKIms R9Jp2RgM8wmHxTLP2IgSzu8AzokzJNTYmjk76IC0hiGubvCKKsiMKbLuAjQQIWNnS7rY ANxOpzycFIaTmXAkmW0g7bxj0fD6R5RF8aSvc9esHYu+97oAt9AmUEZK5QA7Q7C2tOIO n3on96PXG7o4VIb51ndT4saseScAwidbZ8uJY0AhiN+4vu0Y03IL8Jqm5U6rRUjm8xlz bueWRqVodEbseEs6BGNf/TIWvHsu7nn46rmMYqBhRUfx+V/HdeeGSi38K6E/QELlFrJG VHzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=klpHeJJG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qt18si6856266ejb.602.2020.11.09.05.39.42; Mon, 09 Nov 2020 05:40:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=klpHeJJG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732171AbgKINiY (ORCPT + 99 others); Mon, 9 Nov 2020 08:38:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:56402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730690AbgKINDl (ORCPT ); Mon, 9 Nov 2020 08:03:41 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 945312222C; Mon, 9 Nov 2020 13:03:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927000; bh=u3WBktj7CI9tK4i6T5L4hnYgGGH5m2S31m5RoCp2rdE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=klpHeJJG6HefVnUDBiSO5XiLBA6Cam0TNFFYCNokrNRxlzxcBsFszwpA2XWs89GvG JeJatYXs8GvNwoJoPc8bDyn1bEssQ/1l6SEwOe+y+aR9/F7nrOo7625iVByM1Gy1Se eoZwFN5nuOfMiiaxdnBzJXmrIBF2hKqBo6JQjNHM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Dryomov , Jeff Layton Subject: [PATCH 4.9 075/117] libceph: clear con->out_msg on Policy::stateful_server faults Date: Mon, 9 Nov 2020 13:55:01 +0100 Message-Id: <20201109125029.240760641@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125025.630721781@linuxfoundation.org> References: <20201109125025.630721781@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilya Dryomov commit 28e1581c3b4ea5f98530064a103c6217bedeea73 upstream. con->out_msg must be cleared on Policy::stateful_server (!CEPH_MSG_CONNECT_LOSSY) faults. Not doing so botches the reconnection attempt, because after writing the banner the messenger moves on to writing the data section of that message (either from where it got interrupted by the connection reset or from the beginning) instead of writing struct ceph_msg_connect. This results in a bizarre error message because the server sends CEPH_MSGR_TAG_BADPROTOVER but we think we wrote struct ceph_msg_connect: libceph: mds0 (1)172.21.15.45:6828 socket error on write ceph: mds0 reconnect start libceph: mds0 (1)172.21.15.45:6829 socket closed (con state OPEN) libceph: mds0 (1)172.21.15.45:6829 protocol version mismatch, my 32 != server's 32 libceph: mds0 (1)172.21.15.45:6829 protocol version mismatch AFAICT this bug goes back to the dawn of the kernel client. The reason it survived for so long is that only MDS sessions are stateful and only two MDS messages have a data section: CEPH_MSG_CLIENT_RECONNECT (always, but reconnecting is rare) and CEPH_MSG_CLIENT_REQUEST (only when xattrs are involved). The connection has to get reset precisely when such message is being sent -- in this case it was the former. Cc: stable@vger.kernel.org Link: https://tracker.ceph.com/issues/47723 Signed-off-by: Ilya Dryomov Reviewed-by: Jeff Layton Signed-off-by: Greg Kroah-Hartman --- net/ceph/messenger.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -2983,6 +2983,11 @@ static void con_fault(struct ceph_connec ceph_msg_put(con->in_msg); con->in_msg = NULL; } + if (con->out_msg) { + BUG_ON(con->out_msg->con != con); + ceph_msg_put(con->out_msg); + con->out_msg = NULL; + } /* Requeue anything that hasn't been acked */ list_splice_init(&con->out_sent, &con->out_queue);