From patchwork Mon Oct 23 21:40:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10023239 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 CAAC1603D7 for ; Mon, 23 Oct 2017 21:44:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BA99428921 for ; Mon, 23 Oct 2017 21:44:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACDFD2893D; Mon, 23 Oct 2017 21:44:07 +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=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 3F2F828921 for ; Mon, 23 Oct 2017 21:44:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751576AbdJWVmQ (ORCPT ); Mon, 23 Oct 2017 17:42:16 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:45644 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751282AbdJWVmL (ORCPT ); Mon, 23 Oct 2017 17:42:11 -0400 Received: by mail-io0-f196.google.com with SMTP id i38so21712900iod.2; Mon, 23 Oct 2017 14:42:11 -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:in-reply-to:references; bh=RWzr6AEc1Y+08Sc6Z5TXghPCExRxgnlcGUvUgvGnKio=; b=glzQYSNsSBDLDE/nk4frqeg3HNva3bS7lXX45otUIZry+TOorx2ur4YhytLLdHBboa nJYL8OmAh+KT1AQsBTAT0fm8lCRzjhZF2x9JMNSiF0L8qXHirwRaFbyqAfX6NfP0ojSr i3Iv6kdyHr3Mefd8shSvkh/OQUdlZeXsGUElN5vr6CgmMk3vgpTsZs4djk1VxxORTn/j h/Hs07C+BkkGu3SuSJlcBJyb6ltNjLSveyGHUHiRBkvJ8jtiI1LFPvcrpOzspGUW9AIU Sa/fy7U9zAzOYj+MazmfPukQbaclsIAGVWqvEa8B4+6CJzUjrhVvvk3vzDl9TQtrnbCd 4E+w== 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=RWzr6AEc1Y+08Sc6Z5TXghPCExRxgnlcGUvUgvGnKio=; b=ennJgrDe2qcQAiGu2YQnSHCReBbmlzFd5OhS1nU/LD49wCSwryMS2GLSFGYJ4oteAw kC48qOFNH90AsRbK4p9kffMRdJDrY/mh0ZbuIN6T8yqNPJlA9GQRaGxqac/AyLBtwddQ PZTq5y3POKR05aBNBQiHG4A3GSBJnoKmhsOu0AFsYQB5WBCeyPBnco2iydp+AkPOyD+M c02EhHEHPt7sY1SQ8/mK2Nq4nScwKFz5MekX+H7bgKrlCrXyspJDrV1o+pTjDh748taB iqhHVQ/enNZZYy17qG5JhtOagnLQ1/AlVx/i48X3jeFcjOl7JRikPvcbL2F+3l7EfLD2 PYjQ== X-Gm-Message-State: AMCzsaXI2vAfFWKUG8TsYmGbVgkHJDRhT3BG8B91LOMk6blBq7obOcjn moL66LGC04fYU08lsq86hIEXkZvf X-Google-Smtp-Source: ABhQp+SkwdGNYgYLIZc75kQ10EaSGMzOQA0keAn+yXuFTLWSYti8dpoKFAj2BVpivHhmCf6mtFoV5w== X-Received: by 10.107.29.73 with SMTP id d70mr18396373iod.201.1508794930798; Mon, 23 Oct 2017 14:42:10 -0700 (PDT) Received: from ebiggers-linuxstation.kir.corp.google.com ([100.66.175.88]) by smtp.gmail.com with ESMTPSA id i63sm3558482ioi.68.2017.10.23.14.42.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Oct 2017 14:42:10 -0700 (PDT) From: Eric Biggers To: linux-fscrypt@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-mtd@lists.infradead.org, linux-api@vger.kernel.org, keyrings@vger.kernel.org, "Theodore Y . Ts'o" , Jaegeuk Kim , Gwendal Grignou , Ryo Hashimoto , Sarthak Kukreti , Nick Desaulniers , Michael Halcrow , Eric Biggers Subject: [RFC PATCH 01/25] fs, fscrypt: move uapi definitions to new header Date: Mon, 23 Oct 2017 14:40:34 -0700 Message-Id: <20171023214058.128121-2-ebiggers3@gmail.com> X-Mailer: git-send-email 2.15.0.rc0.271.g36b669edcc-goog In-Reply-To: <20171023214058.128121-1-ebiggers3@gmail.com> References: <20171023214058.128121-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 There are going to be more filesystem encryption definitions added, and we don't want to use a disproportionate amount of space in for filesystem encryption stuff. So move the fscrypt definitions to a new header . For compatibility with existing userspace programs which may be including , still includes the new header. (It's debatable whether we really need this, though; the filesystem encryption API is new enough that most if not all programs that are using it have to declare it themselves anyway.) Signed-off-by: Eric Biggers Reviewed-by: Michael Halcrow --- include/linux/fscrypt.h | 2 +- include/uapi/linux/fs.h | 50 +++-------------------------------------- include/uapi/linux/fscrypt.h | 53 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 48 deletions(-) create mode 100644 include/uapi/linux/fscrypt.h diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h index 53437bfdfcbc..f7aa7d62e235 100644 --- a/include/linux/fscrypt.h +++ b/include/linux/fscrypt.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #define FS_CRYPTO_BLOCK_SIZE 16 diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index 56235dddea7d..6ecd3ee9960c 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h @@ -12,6 +12,9 @@ #include #include #include +#ifndef __KERNEL__ +#include +#endif /* * It's silly to have NR_OPEN bigger than NR_FILE, but you can change @@ -253,53 +256,6 @@ struct fsxattr { #define FS_IOC_FSGETXATTR _IOR ('X', 31, struct fsxattr) #define FS_IOC_FSSETXATTR _IOW ('X', 32, struct fsxattr) -/* - * File system encryption support - */ -/* Policy provided via an ioctl on the topmost directory */ -#define FS_KEY_DESCRIPTOR_SIZE 8 - -#define FS_POLICY_FLAGS_PAD_4 0x00 -#define FS_POLICY_FLAGS_PAD_8 0x01 -#define FS_POLICY_FLAGS_PAD_16 0x02 -#define FS_POLICY_FLAGS_PAD_32 0x03 -#define FS_POLICY_FLAGS_PAD_MASK 0x03 -#define FS_POLICY_FLAGS_VALID 0x03 - -/* Encryption algorithms */ -#define FS_ENCRYPTION_MODE_INVALID 0 -#define FS_ENCRYPTION_MODE_AES_256_XTS 1 -#define FS_ENCRYPTION_MODE_AES_256_GCM 2 -#define FS_ENCRYPTION_MODE_AES_256_CBC 3 -#define FS_ENCRYPTION_MODE_AES_256_CTS 4 -#define FS_ENCRYPTION_MODE_AES_128_CBC 5 -#define FS_ENCRYPTION_MODE_AES_128_CTS 6 - -struct fscrypt_policy { - __u8 version; - __u8 contents_encryption_mode; - __u8 filenames_encryption_mode; - __u8 flags; - __u8 master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE]; -}; - -#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy) -#define FS_IOC_GET_ENCRYPTION_PWSALT _IOW('f', 20, __u8[16]) -#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy) - -/* Parameters for passing an encryption key into the kernel keyring */ -#define FS_KEY_DESC_PREFIX "fscrypt:" -#define FS_KEY_DESC_PREFIX_SIZE 8 - -/* Structure that userspace passes to the kernel keyring */ -#define FS_MAX_KEY_SIZE 64 - -struct fscrypt_key { - __u32 mode; - __u8 raw[FS_MAX_KEY_SIZE]; - __u32 size; -}; - /* * Inode flags (FS_IOC_GETFLAGS / FS_IOC_SETFLAGS) * diff --git a/include/uapi/linux/fscrypt.h b/include/uapi/linux/fscrypt.h new file mode 100644 index 000000000000..c09209fc42ea --- /dev/null +++ b/include/uapi/linux/fscrypt.h @@ -0,0 +1,53 @@ +#ifndef _UAPI_LINUX_FSCRYPT_H +#define _UAPI_LINUX_FSCRYPT_H + +#include + +/* + * File system encryption support + */ +/* Policy provided via an ioctl on the topmost directory */ +#define FS_KEY_DESCRIPTOR_SIZE 8 + +#define FS_POLICY_FLAGS_PAD_4 0x00 +#define FS_POLICY_FLAGS_PAD_8 0x01 +#define FS_POLICY_FLAGS_PAD_16 0x02 +#define FS_POLICY_FLAGS_PAD_32 0x03 +#define FS_POLICY_FLAGS_PAD_MASK 0x03 +#define FS_POLICY_FLAGS_VALID 0x03 + +/* Encryption algorithms */ +#define FS_ENCRYPTION_MODE_INVALID 0 +#define FS_ENCRYPTION_MODE_AES_256_XTS 1 +#define FS_ENCRYPTION_MODE_AES_256_GCM 2 +#define FS_ENCRYPTION_MODE_AES_256_CBC 3 +#define FS_ENCRYPTION_MODE_AES_256_CTS 4 +#define FS_ENCRYPTION_MODE_AES_128_CBC 5 +#define FS_ENCRYPTION_MODE_AES_128_CTS 6 + +struct fscrypt_policy { + __u8 version; + __u8 contents_encryption_mode; + __u8 filenames_encryption_mode; + __u8 flags; + __u8 master_key_descriptor[FS_KEY_DESCRIPTOR_SIZE]; +}; + +#define FS_IOC_SET_ENCRYPTION_POLICY _IOR('f', 19, struct fscrypt_policy) +#define FS_IOC_GET_ENCRYPTION_PWSALT _IOW('f', 20, __u8[16]) +#define FS_IOC_GET_ENCRYPTION_POLICY _IOW('f', 21, struct fscrypt_policy) + +/* Parameters for passing an encryption key into the kernel keyring */ +#define FS_KEY_DESC_PREFIX "fscrypt:" +#define FS_KEY_DESC_PREFIX_SIZE 8 + +/* Structure that userspace passes to the kernel keyring */ +#define FS_MAX_KEY_SIZE 64 + +struct fscrypt_key { + __u32 mode; + __u8 raw[FS_MAX_KEY_SIZE]; + __u32 size; +}; + +#endif /* _UAPI_LINUX_FSCRYPT_H */