11.. _fscrypt :
22
33Fscrypt Encryption on CephFS
4- ==========================================================
4+ ============================
55
66Fscrypt is an encryption implementation at the file system level. This file
7- system encryption allows for encrypting on a per directory level. This allows
7+ system encryption allows for encrypting on a per- directory level. This allows
88for file systems to have encrypted and regular non-encrypted portions. Fscrypt
99encryption encrypts file names and data contents.
1010
11- How fscrypt encryption works
12- -------------
11+ How Fscrypt Encryption Works
12+ ----------------------------
1313
14- Encryption keys
15- ~~~~~~~~~~~~
14+ Encryption Keys
15+ ~~~~~~~~~~~~~~~
1616
17- Each fscrypt tree has a master encryption key. This master key, will provide the
18- “ secret” that is needed to encrypt directories. This key can be up to 256 bits
17+ Each fscrypt tree has a master encryption key. This master key will provide the
18+ " secret" that is needed to encrypt directories. This key can be up to 256 bits
1919in length.
2020
2121Policies
22- ~~~~~~~~~~~~
22+ ~~~~~~~~
2323
24- An fscrypt root is assigned an encryption policy. This policy contains items such
24+ An fscrypt root is assigned to an encryption policy. This policy contains items such
2525as which encryption cipher to use and a master key id. This tells the client how
2626to encrypt/decrypt and to validate a given master key id to the encrypted inode.
2727
28- Encryption happens completely on the client side. The mds and osd are not aware
28+ Encryption happens completely on the client side. The MDS and OSD are not aware
2929of encryption policies or master keys. There has been minimal change to those
3030server components. They continue for the most part to store file names and data
31- contents (in this case happen to be encrypted).
31+ contents (which in this case happen to be encrypted).
3232
3333Access Semantics
34- ~~~~~~~~~~~~
34+ ~~~~~~~~~~~~~~~~
3535
3636There are semantics that allow different access depending on if the client has
3737the master key present for a directory or not.
@@ -50,31 +50,32 @@ Without the key
5050* You will see other metadata such as times, mode, ownership, and extended attributes.
5151
5252.. note ::
53- You cannot backup or restore without the key
53+ You cannot backup or restore without the key.
5454
55- Learning by example
56- ~~~~~~~~~~~~
55+ Learning by Example
56+ ~~~~~~~~~~~~~~~~~~~
5757
58- Consider a filesystem named cephfs. A client has two master keys and two
59- directories (encdir1 and encdira). Each directory can have a different encryption
60- master key. For example, encdir1 can have ``key1 `` and then encdira can use ``keyb ``.
61- Then a regular directory will also be present. Please note that regdir is an
58+ Consider a filesystem named `` cephfs `` . A client has two master keys and two
59+ directories (`` encdir1 `` and `` encdira `` ). Each directory can have a different encryption
60+ master key. For example, `` encdir1 `` can have ``key1 `` and then `` encdira `` can use ``keyb ``.
61+ Then a regular directory (`` regdir ``) will also be present. Please note that `` regdir `` is an
6262unencrypted directory and shown for multi-tenant purposes. Figure 1 below
6363illustrates this.
6464
6565When a policy is set on the directory, the directory must be empty. Then any subsequent
6666directories, files or links created in the subtree will inherit policy information
6767from its parent directory.
6868
69- .. image :: cephfs_fscrypt_overview.svg
70- Figure 1
69+ .. figure :: cephfs_fscrypt_overview.svg
70+
71+ Figure 1
7172
7273Key Management
73- -------------
74+ --------------
7475
75- Each client has a unique view of a the filesystem and the fscrypt tree. For this
76+ Each client has a unique view of the filesystem and the fscrypt tree. For this
7677example please refer to Figure 2 below. There are three clients, the first two
77- has a newer version of the CephFS client that includes the fscrypt feature
78+ have a newer version of the CephFS client that includes the fscrypt feature
7879and the third does not. The key management of the keys are on a per-client basis.
7980What one client does pertaining to fscrypt the other is not aware of. Let's take
8081a closer look to see the nuances in detail.
@@ -84,100 +85,105 @@ encrypted tree transparently, this is the unlocked mode.
8485
8586The second, Client 2, does not have the master key and does not have full
8687functionality, this is the locked mode. During locked mode, users cannot view
87- plaintext filenames or data contents. When a user does things list listdir , it
88- will see a hashed version of the encrypted file name. Then when an open() occurs,
88+ plaintext filenames or data contents. When a user lists the directory contents , it
89+ will see a hashed version of the encrypted file name. Then when an `` open() `` occurs,
8990an error will be returned and operation will be denied. Things such as file
9091sizes, mode, timestamps and other inode metadata will be stored plaintext and
91- available in this mode.
92+ are available in this mode.
9293
9394Finally, Client 3, is using an older version of CephFS client and does not have
9495fscrypt feature present. In this mode, users have the same view as before, but
9596are able to do some data operations to encrypted files. This mode is not
9697recommend and not supported.
9798
98- .. image :: cephfs_fscrypt_multiclient.svg
99- Figure 2
99+ .. figure :: cephfs_fscrypt_multiclient.svg
100+
101+ Figure 2
100102
101103CephFS Support
102- -------------
104+ --------------
103105
104106There are two implementations of fscrypt within CephFS. It is supported in the
105107CephFS kernel client. This implementation extends capabilities that exist within
106- the kernel libraries utilizes the crypto keyring.
108+ the kernel libraries and utilizes the kernel crypto keyring.
107109
108- Secondly, the userspace client supports fscrypt within ceph-fuse and libcephfs.
109- Both of these versions are meant to be inter-operable , but with some limitations.
110+ Secondly, the userspace client supports fscrypt within `` ceph-fuse `` and `` libcephfs `` .
111+ Both of these versions are meant to be interoperable , but with some limitations.
110112
111- Userspace limitations
112- -------------
113+ Userspace Limitations
114+ ---------------------
113115
114- A custom fscrypt cli will be needed to use userspace fscrypt. This is due to
115- permanent configurations in the kernel (which ceph-fuse utilize) are incorrectly
116- defined. Instead, there’ s a fscrypt command line utility that is maintained that
117- is part of the ceph project. This version includes necessary changes to configure
116+ A custom fscrypt CLI will be needed to use userspace fscrypt. This is due to
117+ permanent configurations in the kernel (which `` ceph-fuse `` utilizes) that are incorrectly
118+ defined. Instead, there' s a fscrypt command line utility that is maintained
119+ as a part of the Ceph project. This version includes necessary changes to configure
118120and use fscrypt.
119121
120122This version is available at: https://github.com/ceph/fscrypt/tree/wip-ceph-fuse
121123
122124Currently a subset of fscrypt ciphers are supported in user space.
123- They are
124- AES-256-XTS for contents
125- AES-256-CBC-CTS for filenames
126- Any other ciphers used during setting policy on a folder, will be rejected.
125+ They are:
126+
127+ - AES-256-XTS for contents
128+ - AES-256-CBC-CTS for filenames
127129
128- How to use
129- -------------
130+ Any other ciphers used during setting a policy on a folder will be rejected.
130131
131- Setup system wide encryption. This will initialize /etc/fscrypt.conf
132+ How to Use
133+ ----------
132134
133- .. code ::
135+ Setup system-wide encryption. This will initialize ``/etc/fscrypt.conf ``
136+
137+ .. prompt :: bash #
134138
135- $ fscrypt setup
139+ fscrypt setup
136140
137- Setup mount wide encryption. This has to be applied to the mount point for the
138- filesystem. This will setup internal fscrypt cli config files for managing and
141+ Setup mount- wide encryption. This has to be applied to the mount point for the
142+ filesystem. This will setup internal fscrypt CLI config files for managing and
139143keeping track of encryption keys
140144
141- .. code ::
145+ .. prompt :: bash #
142146
143- $ fscrypt setup <mount pt>
147+ fscrypt setup <mount pt>
144148
145149To setup a dir to be encrypted (it must be empty)
146150
147- .. code ::
151+ .. prompt :: bash #
148152
149- $ fscrypt encrypt <dir>
153+ fscrypt encrypt <dir>
150154
151155To lock an encrypted dir
152156
153- .. code ::
157+ .. prompt :: bash #
154158
155- $ fscrypt lock <dir>
159+ fscrypt lock <dir>
156160
157161To unlock an encrypted dir
158162
159- .. code ::
163+ .. prompt :: bash #
160164
161- $ fscrypt unlock <dir>
165+ fscrypt unlock <dir>
162166
163167To view status of a directory (it can be a regular or encrypted dir)
164168
165- .. code ::
169+ .. prompt :: bash #
166170
167- $ fscrypt status <dir>
171+ fscrypt status <dir>
168172
169- Behavior of master key in snapshots and clones
170- -------------
173+ Behavior of Master Key in Snapshots and Clones
174+ ----------------------------------------------
171175
172176All snapshots and clones derived from an fscrypt directory will have their lock
173177state tied together. This means that all derived datasets will be locked or
174178unlocked at the same time.
175179
176180For example, consider:
177- encrypted encdir1 is unlocked
178- snapshot of encdir1 is created encdir1_snap
179- clone of snapshot encdir1_snap is created encdir1_snap_clone1
180- In this current state, encdir1, encdir1_snap and encdir1_snap_clone1 are unlocked
181+
182+ #. Encrypted ``encdir1 `` is unlocked.
183+ #. Snapshot of ``encdir1 `` is created as ``encdir1_snap ``.
184+ #. Clone of snapshot ``encdir1_snap `` is created as ``encdir1_snap_clone1 ``.
185+
186+ In this current state, ``encdir1 ``, ``encdir1_snap `` and ``encdir1_snap_clone1 `` are unlocked
181187and file names and data is accessible as expected in each state. If you perform a
182188lock on any of the three, all three will become locked.
183189
0 commit comments