Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4912072imc; Mon, 25 Feb 2019 13:29:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IaQkf6g7URvBDdMa+ggV8R7DCznYSXRnoHTQkDRhY6b09JgcqWjV6+P1kKxw+pscq5ynnC7 X-Received: by 2002:a65:5507:: with SMTP id f7mr20700198pgr.44.1551130153213; Mon, 25 Feb 2019 13:29:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551130153; cv=none; d=google.com; s=arc-20160816; b=hnifwZ2lO5hbasFdh5NeB4X/Y4mQoP2JyzpsF1JqjqngjYHIEq8H+i4TurFCZAUKk+ YO2acQ/DDtflmKltj3xJ75lCPmYajsC3XrcLTALoJiCB6sz4Zz2qC0VHiqVoKv6CCUXH /82pORpzNzIPtKo2twQRXjK/m+ds64pAOzkS8+3rwiLszjxqgMT0APsSt8FLRebyFwQE BMckcXjFA/8i8D0x4EEonHe6pwy8rFbYXxHqvA7kxO6N4dmtv1gzBYXLFvemBvZM74cP 9qeuGoIMke8aQgdBaouyqGCR37N5TGWd6C3Z/If1tqHJxGmHhXoND2O1v0jndcB4nJId mrsA== 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=V4eoY1AzIsBadV1uCiHLPC/dOE+LdqWZfI9thf+8+O4=; b=Iwcdu7F99Ugx/1JGlr/TSanfBY5b94OT4uWYYOF68/snNrm/qynVnEyd+nLyobiB6S MXRGQaqzUV5vteh+Ra1WktG48bvwNWbA15a2At0XudpRBkv66I1hIpmpGm6aTAyiQteR l1nWrObGV345h/GIP9QyUlPIcTU0Fu7w0NLphtROwCN3kyOa1REo7G0C/OnaOYTceW7F 7U9f0WPE/JQvvN/9+JYtvfJk7panubPXQ00kRJR7Tz/ErRwtY73Hw6WBT/Sm99rQuTqW gmKxDWO1cjj3raDn0gAZjNsOUQkDP5AStVPnx89KeMSQS+D9EIhNLBWtSBq8eJmanfC4 m1Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tSfV8QXb; 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 91si10642759pla.89.2019.02.25.13.28.58; Mon, 25 Feb 2019 13:29:13 -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=tSfV8QXb; 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 S1731838AbfBYV2P (ORCPT + 99 others); Mon, 25 Feb 2019 16:28:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:34002 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730504AbfBYV2M (ORCPT ); Mon, 25 Feb 2019 16:28:12 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (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 AA96E2146F; Mon, 25 Feb 2019 21:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551130092; bh=ffmKsoztWzE+IZY7ctBJRPfV078SyBaIVYJe9SHLUsQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tSfV8QXblshRMInRYB2wQScbyvTTU8HBxShn7XORklPE7QiOj6nTV3846WyZ6z5tc R5XrV+UpYhuaf0ydZiBFZbzwzZ4PzOOgsMzLs2DagbohRc2xSpwrpQd6+7RApCHWqs dtKLm+FbYC+gu7Yun2Qs3jMtejm+F6R1PD22MKT4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilya Dryomov , Sage Weil Subject: [PATCH 4.20 012/183] libceph: handle an empty authorize reply Date: Mon, 25 Feb 2019 22:09:45 +0100 Message-Id: <20190225195056.733644865@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225195054.748060397@linuxfoundation.org> References: <20190225195054.748060397@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ilya Dryomov commit 0fd3fd0a9bb0b02b6435bb7070e9f7b82a23f068 upstream. The authorize reply can be empty, for example when the ticket used to build the authorizer is too old and TAG_BADAUTHORIZER is returned from the service. Calling ->verify_authorizer_reply() results in an attempt to decrypt and validate (somewhat) random data in au->buf (most likely the signature block from calc_signature()), which fails and ends up in con_fault_finish() with !con->auth_retry. The ticket isn't invalidated and the connection is retried again and again until a new ticket is obtained from the monitor: libceph: osd2 192.168.122.1:6809 bad authorize reply libceph: osd2 192.168.122.1:6809 bad authorize reply libceph: osd2 192.168.122.1:6809 bad authorize reply libceph: osd2 192.168.122.1:6809 bad authorize reply Let TAG_BADAUTHORIZER handler kick in and increment con->auth_retry. Cc: stable@vger.kernel.org Fixes: 5c056fdc5b47 ("libceph: verify authorize reply on connect") Link: https://tracker.ceph.com/issues/20164 Signed-off-by: Ilya Dryomov Reviewed-by: Sage Weil Signed-off-by: Greg Kroah-Hartman --- net/ceph/messenger.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -2071,6 +2071,8 @@ static int process_connect(struct ceph_c dout("process_connect on %p tag %d\n", con, (int)con->in_tag); if (con->auth) { + int len = le32_to_cpu(con->in_reply.authorizer_len); + /* * Any connection that defines ->get_authorizer() * should also define ->add_authorizer_challenge() and @@ -2080,8 +2082,7 @@ static int process_connect(struct ceph_c */ if (con->in_reply.tag == CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER) { ret = con->ops->add_authorizer_challenge( - con, con->auth->authorizer_reply_buf, - le32_to_cpu(con->in_reply.authorizer_len)); + con, con->auth->authorizer_reply_buf, len); if (ret < 0) return ret; @@ -2091,10 +2092,12 @@ static int process_connect(struct ceph_c return 0; } - ret = con->ops->verify_authorizer_reply(con); - if (ret < 0) { - con->error_msg = "bad authorize reply"; - return ret; + if (len) { + ret = con->ops->verify_authorizer_reply(con); + if (ret < 0) { + con->error_msg = "bad authorize reply"; + return ret; + } } }