Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp833460pxb; Tue, 3 Nov 2020 13:52:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyVXzUPRJvRUhiV/+xdpXzRHhZ0RIBWhcfjRA65z19oyOdnr0KkIP5PJwjnaIc9s7cLoEW X-Received: by 2002:a50:bc02:: with SMTP id j2mr20074946edh.317.1604440379268; Tue, 03 Nov 2020 13:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604440379; cv=none; d=google.com; s=arc-20160816; b=WpbRLKiHRx0ImHHuqy66Ns6cuSAAZ1i3dFW2iIh+2iLPl6KV0fp0f3FeBlNdktpPBP OFicfuoBujHj7chW77J2xR+65+6DKLQMViAD7Ire9U8HTk3eEp80JcztMAlNV1QXS6qU G/F73m+evAwFF5bzqaIaATmItqSVvlCOFMsTA4wWCxtytNmr4poQtGaSpWpotVAfZSdr kznt4GA4UEEFYXUlffsgVhJ8fVv8uEQ8GmfdHzKvO4VeOkRcxb9Zdh403dp/0S63Ebdk OOPEVu8ljOhk+JnlcCckSRvUFhlL5+LluYi4WqhSznEGr35jSG7rTgqd4yU4J5Sv+xoP fe2Q== 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=ErYGpXzO9atwHYHFhjhDLfQTbXDZQaVa0OCngZ6Yk4U=; b=pjI8pTAb/tInW8iAyaFBfYv/uZSQhAsqmJ0I3j39WSwCenVvdQlPJAmuA4a/6+4OTy jfagu0iGPapO8sdLNFRpCI9eDpqGZWAl2lLaplwRR4Phzyzf9vKOuDivZP8SZeFFQLW1 hujYT/fNLDwA8j4xU1LD5cHDvghaNlNR47O0dzWtdanYCJhTv9VGg6jEiNYVBB+c9fkm n9yy4YH6uzhs40K0lLutbdHmZd5bBsxl3zMi3pyVOJTzl2A/VQLMi3XjZr9K/rUiqUaM dgLyXlhxS0+mRF2D/n8tvYVozs8xF2/LAjQGz+r2rDPug0vED1t3olZmZ47ms0Ryb24n 6N+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="CfiID4/B"; 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 ly11si107822ejb.28.2020.11.03.13.52.36; Tue, 03 Nov 2020 13:52:59 -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="CfiID4/B"; 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 S1731801AbgKCUu2 (ORCPT + 99 others); Tue, 3 Nov 2020 15:50:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:44222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730624AbgKCUuT (ORCPT ); Tue, 3 Nov 2020 15:50:19 -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 AB21B20719; Tue, 3 Nov 2020 20:50:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436619; bh=2lLin1UMFgZxZN/6MIvzU0Oxp7YEYHcbfIz7hkiIpf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CfiID4/BFtwM/ZZMP2v3eXfnjqt/fvIN5wHpATjNH8pZuRUxELFVUU4P4mHRs8vut hd8DUiPszgo67TVpwWeihKlm+4v1Le+mUyric0v8M8u2NJLsEc9tbKpuHbutaosOVj Ak5n2fTVIJvwNSNuUrGMA6lOtta7YCvMg9O34EG8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Dryomov , Jeff Layton Subject: [PATCH 5.9 329/391] libceph: clear con->out_msg on Policy::stateful_server faults Date: Tue, 3 Nov 2020 21:36:20 +0100 Message-Id: <20201103203409.324535544@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@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 @@ -2998,6 +2998,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);