From patchwork Fri Jan 5 18:44:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10146961 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 E44D861671 for ; Fri, 5 Jan 2018 18:57:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D10DA28537 for ; Fri, 5 Jan 2018 18:57:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C604128939; Fri, 5 Jan 2018 18:57:52 +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=unavailable 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 7EEDA2893A for ; Fri, 5 Jan 2018 18:57:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752602AbeAES5c (ORCPT ); Fri, 5 Jan 2018 13:57:32 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:36137 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752488AbeAES5a (ORCPT ); Fri, 5 Jan 2018 13:57:30 -0500 Received: by mail-it0-f68.google.com with SMTP id d16so2719527itj.1; Fri, 05 Jan 2018 10:57:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pditCQK2XZdpQ9VTxvQjqPxtIICkU9PBqwiy89KJmf0=; b=t5UbbAt6j7UbCStjubTYy9T/o5YGcwEiSOHR7XXkh6+jYZak6f6mHNknCw4/GeAfbx ggBu1N7sfNNk7hEooMI7E7s9t/l9+X6Bi5oQKUNaUnc+Dq6iIzRCTkPnCtA/wbN3Iz51 6N0c/t3qeTasCvqJ+Rnf3R/vbJPhqaSs7mMHcGBVyqDlNhWqSn72DxrU960uDrJLxk82 dQVv90J1jlhU3MgODakXe4Ap0z0KI61RIh/x87GgdTk95vXx57345EhieODuE5kCuFdm 2hCP/+3j/CW/HBZcjT8pynmWNpFrvfZBarC5ezIaWyrHHTsWKfinEiiyt1nXSOjJtws2 xJ3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pditCQK2XZdpQ9VTxvQjqPxtIICkU9PBqwiy89KJmf0=; b=B1Kr+QgLqqObxIXlTpQQQb3Ga3EoaLxJvMmGRCMO8HqjUuPBpoNpyu4gO++QluWhRI TUJEKnLrcqa5dx+5Hq2tU8BmsuCEN6NXC9Txzw5rkC7N7doDWP0FuMZBMgl1d9h5oOY2 lRPNKShPblHls1Su5mxlThRDOotGE3CqlCcTdbx5iApq37Pv4g9gPBkRy7CPXPT6BFgJ sz6mk721ZwVIMntq3DoD0ABhIaQJyiL7ljTY2VG4D+iNLwF7EiIC0iRsYWcYbEv72msb qXNXXwd1lAqX5fnXArY2h/9Ek1elfShogwIYNjUldK/YJTlr5SJWKJR/kuPhB+v5Nm7P oDRA== X-Gm-Message-State: AKGB3mKTPEmlkDNaWSTqz0dgRBZNFVFw4+qgtH1UmX84kzgeGV4UeXdb mRkvNKxFv7pwWN03H2WqSA5FyOZG X-Google-Smtp-Source: ACJfBouNE2M2E3kArpJu5EqiqlNycp1FUZNI2+uVl0vHbCWZh75XQfpSa+/6y0qtvMJKP7gJW/iRQA== X-Received: by 10.36.69.83 with SMTP id y80mr4056130ita.87.1515178649874; Fri, 05 Jan 2018 10:57:29 -0800 (PST) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.175.88]) by smtp.gmail.com with ESMTPSA id j68sm3863899iod.53.2018.01.05.10.57.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 05 Jan 2018 10:57:29 -0800 (PST) From: Eric Biggers To: linux-fscrypt@vger.kernel.org, "Theodore Y . Ts'o" Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, linux-fsdevel@vger.kernel.org, Eric Biggers Subject: [PATCH v2 07/11] fscrypt: move fscrypt_valid_enc_modes() to fscrypt_private.h Date: Fri, 5 Jan 2018 10:44:58 -0800 Message-Id: <20180105184502.48473-8-ebiggers3@gmail.com> X-Mailer: git-send-email 2.16.0.rc0.223.g4a4ac83678-goog In-Reply-To: <20180105184502.48473-1-ebiggers3@gmail.com> References: <20180105184502.48473-1-ebiggers3@gmail.com> Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers The encryption modes are validated by fs/crypto/, not by individual filesystems. Therefore, move fscrypt_valid_enc_modes() from fscrypt.h to fscrypt_private.h. Signed-off-by: Eric Biggers --- fs/crypto/fscrypt_private.h | 14 ++++++++++++++ include/linux/fscrypt.h | 14 -------------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index 823c43a00bf7..2b848e7c92f0 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -71,6 +71,20 @@ typedef enum { #define FS_CTX_REQUIRES_FREE_ENCRYPT_FL 0x00000001 #define FS_CTX_HAS_BOUNCE_BUFFER_FL 0x00000002 +static inline bool fscrypt_valid_enc_modes(u32 contents_mode, + u32 filenames_mode) +{ + if (contents_mode == FS_ENCRYPTION_MODE_AES_128_CBC && + filenames_mode == FS_ENCRYPTION_MODE_AES_128_CTS) + return true; + + if (contents_mode == FS_ENCRYPTION_MODE_AES_256_XTS && + filenames_mode == FS_ENCRYPTION_MODE_AES_256_CTS) + return true; + + return false; +} + /* crypto.c */ extern struct kmem_cache *fscrypt_info_cachep; extern int fscrypt_initialize(unsigned int cop_flags); diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h index 33b95a91f720..2e4dce0365cf 100644 --- a/include/linux/fscrypt.h +++ b/include/linux/fscrypt.h @@ -57,20 +57,6 @@ struct fscrypt_name { /* Maximum value for the third parameter of fscrypt_operations.set_context(). */ #define FSCRYPT_SET_CONTEXT_MAX_SIZE 28 -static inline bool fscrypt_valid_enc_modes(u32 contents_mode, - u32 filenames_mode) -{ - if (contents_mode == FS_ENCRYPTION_MODE_AES_128_CBC && - filenames_mode == FS_ENCRYPTION_MODE_AES_128_CTS) - return true; - - if (contents_mode == FS_ENCRYPTION_MODE_AES_256_XTS && - filenames_mode == FS_ENCRYPTION_MODE_AES_256_CTS) - return true; - - return false; -} - static inline bool fscrypt_is_dot_dotdot(const struct qstr *str) { if (str->len == 1 && str->name[0] == '.')