Return-Path: Received: from mx2.suse.de ([195.135.220.15]:43176 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751656AbdATI4L (ORCPT ); Fri, 20 Jan 2017 03:56:11 -0500 From: Jiri Slaby To: stable@vger.kernel.org Cc: Ilya Dryomov , Jiri Slaby Subject: [patch added to 3.12-stable] libceph: verify authorize reply on connect Date: Fri, 20 Jan 2017 09:55:54 +0100 Message-Id: <20170120085559.25003-18-jslaby@suse.cz> In-Reply-To: <20170120085559.25003-1-jslaby@suse.cz> References: <20170120085559.25003-1-jslaby@suse.cz> Sender: stable-owner@vger.kernel.org List-ID: From: Ilya Dryomov This patch has been added to the 3.12 stable tree. If you have any objections, please let us know. =============== commit 5c056fdc5b474329037f2aa18401bd73033e0ce0 upstream. 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. Signed-off-by: Ilya Dryomov Reviewed-by: Sage Weil Signed-off-by: Jiri Slaby --- net/ceph/messenger.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 469f3138d0f6..ecdf164c80fe 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -1972,6 +1972,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," -- 2.11.0