From patchwork Mon Jul 17 18:30:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 9845929 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 8E9EB60392 for ; Mon, 17 Jul 2017 18:31:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8365C27F7F for ; Mon, 17 Jul 2017 18:31:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7830D28541; Mon, 17 Jul 2017 18:31:46 +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 CAC8827F7F for ; Mon, 17 Jul 2017 18:31:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751356AbdGQSbp (ORCPT ); Mon, 17 Jul 2017 14:31:45 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35725 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751301AbdGQSbo (ORCPT ); Mon, 17 Jul 2017 14:31:44 -0400 Received: by mail-pf0-f196.google.com with SMTP id q85so20393204pfq.2 for ; Mon, 17 Jul 2017 11:31:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=w9o7r4PpV5lMV4hwbn/KUIQcA/6moDXRZbouxzPbI6g=; b=TQ/e4fwuUr5rk33+SamZRa+dTQkrI16lUaJr+mfMvVmWyS0gm1DObZiFHs389p6RK4 t5Kx6JoLCmx3DW7fLTeQ/mL+fYM+MCRJEw5uyWi8hbW1uIyGF0WsWXyObK9uAyIz+7wm Ll85qMugFKbJGnG3KKTi0OvQf8gYp8CSijT7SH8J19VDILJvU9KcDkZ2kqURunhkXst4 8M6uE35eC22Zv3hrPfAI3CYPnmN6HJUtTy6ZJk55x8USSeCWFoFQiXA6jvP/762wl8gO /piHTv6A1Ns2SQ2wmX+87XWD6uAemgs4YzQsd6Ooq184toEPkeQ1Q4ueV5riB1rZvasH BqoA== 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; bh=w9o7r4PpV5lMV4hwbn/KUIQcA/6moDXRZbouxzPbI6g=; b=duvkQ9JtT1VFFKE9ZjKLjtMRxmxeFOjonXkp3ZTbqG4Ob/50KBGvthjzRZjqSUyvVq IlPRkQH+JYp8LwEwtcUUr9zJU0H1kseLHS/niCvRHTKE5zSlRnb0UmyGRWCk3gUR32jq YkWc6Mk9ns6XNk5+aYhFVFADu30mB0TTuxHwbgWsBYDJnN5I69VfpOcQhzwag0xuphUl zZeu5pWYIWq5QpN7Vse/h2ZB4Dl4eduCHUN6bEkD8Dk1Z33miejwTCfeTQEuXwXV1BVg eLwoptgeVGof0tovpH9n75sm3UU7pMZfIngUsgugklCg+utf4JjYUla8i5P/mSfTkk32 VoHQ== X-Gm-Message-State: AIVw113OuNfwLaVvfzErEIPWayj3Y+E0aSPHkR0gsXbumFIN2gRbR1eE itRIXnMzXPA8NOUttG4= X-Received: by 10.84.169.36 with SMTP id g33mr32529027plb.52.1500316304023; Mon, 17 Jul 2017 11:31:44 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.174.81]) by smtp.gmail.com with ESMTPSA id r207sm38439913pfr.106.2017.07.17.11.31.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 11:31:43 -0700 (PDT) From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: "Theodore Y . Ts'o" , Jaegeuk Kim , Eric Biggers Subject: [PATCH] fscrypt: trim down fscrypt_common.h Date: Mon, 17 Jul 2017 11:30:54 -0700 Message-Id: <20170717183054.114503-1-ebiggers3@gmail.com> X-Mailer: git-send-email 2.13.2.932.g7449e964c-goog 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 fscrypt_common.h is only meant to include declarations that are exposed to filesystems both with and without encryption enabled. Trim it down a bit by removing stuff that is only needed inside fs/crypto/ itself, instead moving it into fscrypt_private.h or specific .c files. Signed-off-by: Eric Biggers --- fs/crypto/bio.c | 1 - fs/crypto/crypto.c | 1 + fs/crypto/fname.c | 12 ++++++++++++ fs/crypto/fscrypt_private.h | 22 +++++++++++++++++++++- fs/crypto/keyinfo.c | 2 ++ fs/crypto/policy.c | 1 + include/linux/fscrypt_common.h | 38 -------------------------------------- include/linux/fscrypt_supp.h | 1 + 8 files changed, 38 insertions(+), 40 deletions(-) diff --git a/fs/crypto/bio.c b/fs/crypto/bio.c index 6181e9526860..8c76e3ee3953 100644 --- a/fs/crypto/bio.c +++ b/fs/crypto/bio.c @@ -22,7 +22,6 @@ #include #include #include -#include #include "fscrypt_private.h" /* diff --git a/fs/crypto/crypto.c b/fs/crypto/crypto.c index c7835df7e7b8..0d676838ec95 100644 --- a/fs/crypto/crypto.c +++ b/fs/crypto/crypto.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "fscrypt_private.h" static unsigned int num_prealloc_crypto_pages = 32; diff --git a/fs/crypto/fname.c b/fs/crypto/fname.c index ad9f814fdead..d81108ea6d53 100644 --- a/fs/crypto/fname.c +++ b/fs/crypto/fname.c @@ -12,8 +12,20 @@ #include #include +#include #include "fscrypt_private.h" +static inline bool fscrypt_is_dot_dotdot(const struct qstr *str) +{ + if (str->len == 1 && str->name[0] == '.') + return true; + + if (str->len == 2 && str->name[0] == '.' && str->name[1] == '.') + return true; + + return false; +} + /** * fname_crypt_complete() - completion callback for filename crypto * @req: The asynchronous cipher request context diff --git a/fs/crypto/fscrypt_private.h b/fs/crypto/fscrypt_private.h index a1d5021c31ef..5be27f37d065 100644 --- a/fs/crypto/fscrypt_private.h +++ b/fs/crypto/fscrypt_private.h @@ -12,7 +12,6 @@ #define _FSCRYPT_PRIVATE_H #include -#include /* Encryption parameters */ #define FS_IV_SIZE 16 @@ -78,6 +77,27 @@ struct fscrypt_completion_result { struct fscrypt_completion_result ecr = { \ COMPLETION_INITIALIZER_ONSTACK((ecr).completion), 0 } +static inline bool fscrypt_dummy_context_enabled(struct inode *inode) +{ + if (inode->i_sb->s_cop->dummy_context && + inode->i_sb->s_cop->dummy_context(inode)) + return true; + return false; +} + +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 int fscrypt_initialize(unsigned int cop_flags); diff --git a/fs/crypto/keyinfo.c b/fs/crypto/keyinfo.c index 018c588c7ac3..f4e02f0d0762 100644 --- a/fs/crypto/keyinfo.c +++ b/fs/crypto/keyinfo.c @@ -12,7 +12,9 @@ #include #include #include +#include #include +#include #include "fscrypt_private.h" static struct crypto_shash *essiv_hash_tfm; diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c index ce07a86200f3..7bb02eabbf7a 100644 --- a/fs/crypto/policy.c +++ b/fs/crypto/policy.c @@ -11,6 +11,7 @@ #include #include #include +#include #include "fscrypt_private.h" /* diff --git a/include/linux/fscrypt_common.h b/include/linux/fscrypt_common.h index 97f738628b36..050bb2294fd1 100644 --- a/include/linux/fscrypt_common.h +++ b/include/linux/fscrypt_common.h @@ -10,13 +10,8 @@ #ifndef _LINUX_FSCRYPT_COMMON_H #define _LINUX_FSCRYPT_COMMON_H -#include #include #include -#include -#include -#include -#include #define FS_CRYPTO_BLOCK_SIZE 16 @@ -86,39 +81,6 @@ struct fscrypt_operations { /* Maximum value for the third parameter of fscrypt_operations.set_context(). */ #define FSCRYPT_SET_CONTEXT_MAX_SIZE 28 -static inline bool fscrypt_dummy_context_enabled(struct inode *inode) -{ - if (inode->i_sb->s_cop->dummy_context && - inode->i_sb->s_cop->dummy_context(inode)) - return true; - return false; -} - -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] == '.') - return true; - - if (str->len == 2 && str->name[0] == '.' && str->name[1] == '.') - return true; - - return false; -} - static inline struct page *fscrypt_control_page(struct page *page) { #if IS_ENABLED(CONFIG_FS_ENCRYPTION) diff --git a/include/linux/fscrypt_supp.h b/include/linux/fscrypt_supp.h index 32e2fcf13b01..d411407945b1 100644 --- a/include/linux/fscrypt_supp.h +++ b/include/linux/fscrypt_supp.h @@ -8,6 +8,7 @@ #define _LINUX_FSCRYPT_SUPP_H #include +#include /* crypto.c */ extern struct kmem_cache *fscrypt_info_cachep;