From patchwork Mon Dec 12 20:48:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9471323 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 12DD6607D3 for ; Mon, 12 Dec 2016 20:50:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0996328518 for ; Mon, 12 Dec 2016 20:50:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F28A82851B; Mon, 12 Dec 2016 20:50:36 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 A676528518 for ; Mon, 12 Dec 2016 20:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932482AbcLLUuJ (ORCPT ); Mon, 12 Dec 2016 15:50:09 -0500 Received: from mail-wj0-f195.google.com ([209.85.210.195]:33368 "EHLO mail-wj0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752966AbcLLUuF (ORCPT ); Mon, 12 Dec 2016 15:50:05 -0500 Received: by mail-wj0-f195.google.com with SMTP id kp2so13540062wjc.0 for ; Mon, 12 Dec 2016 12:50:04 -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=0QUDh9/jdtXTsxYSzwCE/qyBRNtQPTnqQl0ani3xGjg=; b=a4VSduvw/wTzRPw0XlU4+u4dsRwUIA7koy+sYCwmw7TwGHy6XLkDyQ3WDwqoJcFGXd J8yhfwnCSOy+ixF1AffDUHTd1gL9LsNHXGZZK9CDvO37sVJ5UG7+JG2IvBDp+CJFdCEa 7avbHbf+6f/9wQSxIGR8KCjwiA19jzc1JCgWN7BHN0qRSubY2ou+ULdwaXFgl3Yngf25 1yr3gaG8tYrwX5sQcJcOVEmQ1CKRTHL2zZ28DvSmWChizC0QTg5cHLM7dLzxLmeK8EYJ eOzstTmNm3Bo+TKfaITjdk4tcStWmr97ZX1MhrQrutSHXKoGDjAf1Qdkkz+WQZLxggwE KvTA== 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=0QUDh9/jdtXTsxYSzwCE/qyBRNtQPTnqQl0ani3xGjg=; b=dAtP8hLqmC9R9u8v5S9PWfQCdR1BHdG+pwNAXXIYAdXAs8vZBB5t98gihBNRQNH6F+ qwA1iXXJiVVdLLQ8EHBmNfZwjOgmpkPQEesLiFFkmW0TfY3QXvA2YFr0GsukNOrHZidn 0jM0Jpc3dKc4Q57bB2izBjrTmKu+gi/g4WAnJDu/2S4SqkGZZNWd01+Te3Bq95AVFM1F nPV9Yoi54B3DFL3Ea8Pu5OuJNOsZDQLQkaDU5WFak0SUzFNFH2i8tWzSFcFhcCuCoAV2 1zLf8E6C8HF6OvBhHsdys59Q9WhYDmt+a/L6opvlvOJV8MsXsmWsEPu33B+kfhM417qk P7/A== X-Gm-Message-State: AKaTC02UhDXAbH0DO4SxiQZREckkEdh1/fbfLizw4PbtDWqEXit9kPKAOre6YpDGUkRbww== X-Received: by 10.194.9.34 with SMTP id w2mr77962993wja.24.1481575803345; Mon, 12 Dec 2016 12:50:03 -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.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 12:50:02 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 01/15] libceph: ceph_x_encrypt_buflen() takes in_len Date: Mon, 12 Dec 2016 21:48:46 +0100 Message-Id: <1481575740-1834-2-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 Pass what's going to be encrypted - that's msg_b, not ticket_blob. ceph_x_encrypt_buflen() returns the upper bound, so this doesn't change the maxlen calculation, but makes it a bit clearer. Signed-off-by: Ilya Dryomov --- net/ceph/auth_x.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c index a0905f04bd13..4d14dc8c7746 100644 --- a/net/ceph/auth_x.c +++ b/net/ceph/auth_x.c @@ -308,8 +308,8 @@ static int ceph_x_build_authorizer(struct ceph_auth_client *ac, if (ret) goto out_au; - maxlen = sizeof(*msg_a) + sizeof(msg_b) + - ceph_x_encrypt_buflen(ticket_blob_len); + maxlen = sizeof(*msg_a) + ticket_blob_len + + ceph_x_encrypt_buflen(sizeof(msg_b)); dout(" need len %d\n", maxlen); if (au->buf && au->buf->alloc_len < maxlen) { ceph_buffer_put(au->buf); @@ -350,11 +350,12 @@ static int ceph_x_build_authorizer(struct ceph_auth_client *ac, p, end - p); if (ret < 0) goto out_au; + p += ret; + WARN_ON(p > end); au->buf->vec.iov_len = p - au->buf->vec.iov_base; dout(" built authorizer nonce %llx len %d\n", au->nonce, (int)au->buf->vec.iov_len); - BUG_ON(au->buf->vec.iov_len > maxlen); return 0; out_au: