From patchwork Mon Dec 12 20:48:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9471315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5FB71607D3 for ; Mon, 12 Dec 2016 20:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5588E28518 for ; Mon, 12 Dec 2016 20:50:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 48C972851B; Mon, 12 Dec 2016 20:50:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 002B328518 for ; Mon, 12 Dec 2016 20:50:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932537AbcLLUu1 (ORCPT ); Mon, 12 Dec 2016 15:50:27 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:36702 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932510AbcLLUuQ (ORCPT ); Mon, 12 Dec 2016 15:50:16 -0500 Received: by mail-wm0-f65.google.com with SMTP id m203so13732291wma.3 for ; Mon, 12 Dec 2016 12:50:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=TllK+E11Sy8l8Yw7sRkcpqXT/Kjxy6dR3lgojkLJGyY=; b=CwrsT+r36qnRSe52pOrACbUHoLfI4U4x6jvnLb6oHfEE1+mOAZGySmtf1f4v2rtICg OcuXeo0zCJ5o4VB+isQZ3S5VAzSnGuIeIugtJIlZTlI0usjvDjex+tawVHSS6vvrYQky Y6ZJOWEd4EXGc8PxtfUpfbMJN3S1sGJkA45mJjzAFYfa/drfrvaz+NO9cyb8x3KUTQQj RB3s54BMPlO2ZuLDbMK1NyE0nNHWjZE3tnkXYZJwMZrih+7KfTRF0jB6cjiQgYJY1tWX rbYVO9zltTX/Dk0KBJKVcl6vbJx2YZGL1jMsyqvJ8xuxmU66u+1plhCYh2VG+7Di3zFl WSYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=TllK+E11Sy8l8Yw7sRkcpqXT/Kjxy6dR3lgojkLJGyY=; b=h+XRj9oXfiI6Al3CHnhHbEYdRbsZsf0dJXcpzgesACJ8bSUOgzeK4fAOQ4WnuLb423 TwTXEFrgO3tcC6tQGbu4k+YbRPRMM33r8ruCJMC0bq71XxAStYarSCwmhtwKMJxYKUAR OeOdFZa4ILmxgLChoMUbPg3YDyaHGFehLbXbCx8LkGHUb95+7qbq6tn+OXW7aNYfT6cB lnaL5hL8xQNijQaByCJEhecIRNjId8gHp+Gvjlwts7ept6YIENYyZ7HuFZOu4spll6Bc klrSBfJ3Obk9DigCvhdSok7Zk0vBhGHMGz//dmzCvIhhB6VxQdiWRmi1RltSkRKvav+9 ub3g== X-Gm-Message-State: AKaTC026/bgo2e6LbYFds0duFxe+C4HM+YeXyE3DsvtUKk4X3GPawjNI9f8Ih+Kc2lmyGQ== X-Received: by 10.28.24.67 with SMTP id 64mr10460625wmy.136.1481575814593; Mon, 12 Dec 2016 12:50:14 -0800 (PST) Received: from dhcp-1-105.brq.redhat.com ([213.175.37.12]) by smtp.gmail.com with ESMTPSA id 135sm37201887wmh.14.2016.12.12.12.50.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 12:50:13 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 13/15] libceph: verify authorize reply on connect Date: Mon, 12 Dec 2016 21:48:58 +0100 Message-Id: <1481575740-1834-14-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1481575740-1834-1-git-send-email-idryomov@gmail.com> References: <1481575740-1834-1-git-send-email-idryomov@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP After sending an authorizer (ceph_x_authorize_a + ceph_x_authorize_b), the client gets back a ceph_x_authorize_reply, which it is supposed to verify to ensure the authenticity and protect against replay attacks. The code for doing this is there (ceph_x_verify_authorizer_reply(), ceph_auth_verify_authorizer_reply() + plumbing), but it is never invoked by the the messenger. AFAICT this goes back to 2009, when ceph authentication protocols support was added to the kernel client in 4e7a5dcd1bba ("ceph: negotiate authentication protocol; implement AUTH_NONE protocol"). The second param of ceph_connection_operations::verify_authorizer_reply is unused all the way down. Pass 0 to facilitate backporting, and kill it in the next commit. Cc: stable@vger.kernel.org Signed-off-by: Ilya Dryomov --- net/ceph/messenger.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index a5502898ea33..2efb335deada 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -2027,6 +2027,19 @@ static int process_connect(struct ceph_connection *con) dout("process_connect on %p tag %d\n", con, (int)con->in_tag); + if (con->auth_reply_buf) { + /* + * Any connection that defines ->get_authorizer() + * should also define ->verify_authorizer_reply(). + * See get_connect_authorizer(). + */ + ret = con->ops->verify_authorizer_reply(con, 0); + if (ret < 0) { + con->error_msg = "bad authorize reply"; + return ret; + } + } + switch (con->in_reply.tag) { case CEPH_MSGR_TAG_FEATURES: pr_err("%s%lld %s feature set mismatch,"