From patchwork Mon Dec 12 20:48:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9471327 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 5D68660762 for ; Mon, 12 Dec 2016 20:50:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5397228518 for ; Mon, 12 Dec 2016 20:50:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 47E022851B; Mon, 12 Dec 2016 20:50:41 +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 EF85828518 for ; Mon, 12 Dec 2016 20:50:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753225AbcLLUug (ORCPT ); Mon, 12 Dec 2016 15:50:36 -0500 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33492 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932320AbcLLUuI (ORCPT ); Mon, 12 Dec 2016 15:50:08 -0500 Received: by mail-wm0-f67.google.com with SMTP id u144so13765299wmu.0 for ; Mon, 12 Dec 2016 12:50:08 -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=KU5hO7xXR196TkdjYDDCCU+oUsVYskKeV2fwwKLJjmQ=; b=NcoACOZ/unu0IOfmxIqHIHlXhvH0PW8GfP4aJZF+R+9aT57HMd2VjJsIPv2GQ/7KPx On1CGFSzaQ5I7M54TZueF96fj9YuuQjl1M9QBHPfyoHVZUxa6ODnT+H63sCVjnjugKrb /q3CAuPoBO0G+7pUjclwKUqDR9RbYhxVa0u+WATk7rPyhOjz3WvSTZwl2XaC22xFcdZm qWU+vDQSvvj5iuLqI4NXUWdAbOJtm4Z2DbaT87ODQDNdAouHj9t90fmKrF01p/kmTX+e IrGCa+6UqkoQ7yb/nYT4naq2ZHll//hqyTBaTww6Q2dgj4gmAuOCiGa5ysR7CSWsXZFQ G5kA== 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=KU5hO7xXR196TkdjYDDCCU+oUsVYskKeV2fwwKLJjmQ=; b=m8mGp91/wTinA6sRM5xHHuadUWt0Saa5D3p49pJGuQenlkIWN9+UvM3figD5VPdMAB oq/h7bAL/1PhUSlCUY9tIOlGpKibzMG3gSnE7DrkWx3Vi2oJqUn5trgDr68O1dZhznyy k5KZWyVvRlbOH5jE5RmAQZ+XS9USTS/lLdQJV5Dkr1Xy9kjTF/NkoFw8DDEufksX/w33 TDQuWJwelKHX05rqduH0ylTYMP7GObz3IklA0MNRMpfNH94LgCxX47o0ctKyTHLBeZc6 Em8nSEA7oWf2krEtpJ4PzWX0+4kXrAKK0qh9I/ZGIWMxjaTyDw854wiH/HKGTBK57xrW 8yrw== X-Gm-Message-State: AKaTC02aC9+7kHraUhPrPNnrHF0nSaD0pkYS16bsyCpqetUk/aVutwfSFCcnNvVwgCnHMQ== X-Received: by 10.28.94.205 with SMTP id s196mr18795504wmb.1.1481575806788; Mon, 12 Dec 2016 12:50:06 -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.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Dec 2016 12:50:06 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 05/15] libceph: rename and align ceph_x_authorizer::reply_buf Date: Mon, 12 Dec 2016 21:48:50 +0100 Message-Id: <1481575740-1834-6-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 It's going to be used as a temporary buffer for in-place en/decryption with ceph_crypt() instead of on-stack buffers, so rename to enc_buf. Ensure alignment to avoid GFP_ATOMIC allocations in the crypto stack. Signed-off-by: Ilya Dryomov --- net/ceph/auth_x.c | 10 +++++----- net/ceph/auth_x.h | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/net/ceph/auth_x.c b/net/ceph/auth_x.c index de30c585c2a2..ef1423294517 100644 --- a/net/ceph/auth_x.c +++ b/net/ceph/auth_x.c @@ -603,8 +603,8 @@ static int ceph_x_create_authorizer( auth->authorizer = (struct ceph_authorizer *) au; auth->authorizer_buf = au->buf->vec.iov_base; auth->authorizer_buf_len = au->buf->vec.iov_len; - auth->authorizer_reply_buf = au->reply_buf; - auth->authorizer_reply_buf_len = sizeof (au->reply_buf); + auth->authorizer_reply_buf = au->enc_buf; + auth->authorizer_reply_buf_len = CEPHX_AU_ENC_BUF_LEN; auth->sign_message = ac->ops->sign_message; auth->check_message_signature = ac->ops->check_message_signature; @@ -638,10 +638,10 @@ static int ceph_x_verify_authorizer_reply(struct ceph_auth_client *ac, int ret = 0; struct ceph_x_authorize_reply reply; void *preply = &reply; - void *p = au->reply_buf; - void *end = p + sizeof(au->reply_buf); + void *p = au->enc_buf; - ret = ceph_x_decrypt(&au->session_key, &p, end, &preply, sizeof(reply)); + ret = ceph_x_decrypt(&au->session_key, &p, p + CEPHX_AU_ENC_BUF_LEN, + &preply, sizeof(reply)); if (ret < 0) return ret; if (ret != sizeof(reply)) diff --git a/net/ceph/auth_x.h b/net/ceph/auth_x.h index 21a5af904bae..48e9ad41bd2a 100644 --- a/net/ceph/auth_x.h +++ b/net/ceph/auth_x.h @@ -24,6 +24,7 @@ struct ceph_x_ticket_handler { unsigned long renew_after, expires; }; +#define CEPHX_AU_ENC_BUF_LEN 128 /* big enough for encrypted blob */ struct ceph_x_authorizer { struct ceph_authorizer base; @@ -32,7 +33,7 @@ struct ceph_x_authorizer { unsigned int service; u64 nonce; u64 secret_id; - char reply_buf[128]; /* big enough for encrypted blob */ + char enc_buf[CEPHX_AU_ENC_BUF_LEN] __aligned(8); }; struct ceph_x_info {