1 // SPDX-License-Identifier: GPL-2.0
3 * Encryption policy functions for per-file encryption support.
5 * Copyright (C) 2015, Google, Inc.
6 * Copyright (C) 2015, Motorola Mobility.
8 * Originally written by Michael Halcrow, 2015.
9 * Modified by Jaegeuk Kim, 2015.
10 * Modified by Eric Biggers, 2019 for v2 policy support.
13 #include <linux/random.h>
14 #include <linux/seq_file.h>
15 #include <linux/string.h>
16 #include <linux/mount.h>
17 #include "fscrypt_private.h"
20 * fscrypt_policies_equal() - check whether two encryption policies are the same
21 * @policy1: the first policy
22 * @policy2: the second policy
24 * Return: %true if equal, else %false
26 bool fscrypt_policies_equal(const union fscrypt_policy *policy1,
27 const union fscrypt_policy *policy2)
29 if (policy1->version != policy2->version)
32 return !memcmp(policy1, policy2, fscrypt_policy_size(policy1));
35 static const union fscrypt_policy *
36 fscrypt_get_dummy_policy(struct super_block *sb)
38 if (!sb->s_cop->get_dummy_policy)
40 return sb->s_cop->get_dummy_policy(sb);
43 static bool fscrypt_valid_enc_modes(u32 contents_mode, u32 filenames_mode)
45 if (contents_mode == FSCRYPT_MODE_AES_256_XTS &&
46 filenames_mode == FSCRYPT_MODE_AES_256_CTS)
49 if (contents_mode == FSCRYPT_MODE_AES_128_CBC &&
50 filenames_mode == FSCRYPT_MODE_AES_128_CTS)
53 if (contents_mode == FSCRYPT_MODE_ADIANTUM &&
54 filenames_mode == FSCRYPT_MODE_ADIANTUM)
60 static bool supported_direct_key_modes(const struct inode *inode,
61 u32 contents_mode, u32 filenames_mode)
63 const struct fscrypt_mode *mode;
65 if (contents_mode != filenames_mode) {
67 "Direct key flag not allowed with different contents and filenames modes");
70 mode = &fscrypt_modes[contents_mode];
72 if (mode->ivsize < offsetofend(union fscrypt_iv, nonce)) {
73 fscrypt_warn(inode, "Direct key flag not allowed with %s",
80 static bool supported_iv_ino_lblk_policy(const struct fscrypt_policy_v2 *policy,
81 const struct inode *inode,
83 int max_ino_bits, int max_lblk_bits)
85 struct super_block *sb = inode->i_sb;
86 int ino_bits = 64, lblk_bits = 64;
89 * IV_INO_LBLK_* exist only because of hardware limitations, and
90 * currently the only known use case for them involves AES-256-XTS.
91 * That's also all we test currently. For these reasons, for now only
92 * allow AES-256-XTS here. This can be relaxed later if a use case for
93 * IV_INO_LBLK_* with other encryption modes arises.
95 if (policy->contents_encryption_mode != FSCRYPT_MODE_AES_256_XTS) {
97 "Can't use %s policy with contents mode other than AES-256-XTS",
103 * It's unsafe to include inode numbers in the IVs if the filesystem can
104 * potentially renumber inodes, e.g. via filesystem shrinking.
106 if (!sb->s_cop->has_stable_inodes ||
107 !sb->s_cop->has_stable_inodes(sb)) {
109 "Can't use %s policy on filesystem '%s' because it doesn't have stable inode numbers",
113 if (sb->s_cop->get_ino_and_lblk_bits)
114 sb->s_cop->get_ino_and_lblk_bits(sb, &ino_bits, &lblk_bits);
115 if (ino_bits > max_ino_bits) {
117 "Can't use %s policy on filesystem '%s' because its inode numbers are too long",
121 if (lblk_bits > max_lblk_bits) {
123 "Can't use %s policy on filesystem '%s' because its block numbers are too long",
130 static bool fscrypt_supported_v1_policy(const struct fscrypt_policy_v1 *policy,
131 const struct inode *inode)
133 if (!fscrypt_valid_enc_modes(policy->contents_encryption_mode,
134 policy->filenames_encryption_mode)) {
136 "Unsupported encryption modes (contents %d, filenames %d)",
137 policy->contents_encryption_mode,
138 policy->filenames_encryption_mode);
142 if (policy->flags & ~(FSCRYPT_POLICY_FLAGS_PAD_MASK |
143 FSCRYPT_POLICY_FLAG_DIRECT_KEY)) {
144 fscrypt_warn(inode, "Unsupported encryption flags (0x%02x)",
149 if ((policy->flags & FSCRYPT_POLICY_FLAG_DIRECT_KEY) &&
150 !supported_direct_key_modes(inode, policy->contents_encryption_mode,
151 policy->filenames_encryption_mode))
154 if (IS_CASEFOLDED(inode)) {
155 /* With v1, there's no way to derive dirhash keys. */
157 "v1 policies can't be used on casefolded directories");
164 static bool fscrypt_supported_v2_policy(const struct fscrypt_policy_v2 *policy,
165 const struct inode *inode)
169 if (!fscrypt_valid_enc_modes(policy->contents_encryption_mode,
170 policy->filenames_encryption_mode)) {
172 "Unsupported encryption modes (contents %d, filenames %d)",
173 policy->contents_encryption_mode,
174 policy->filenames_encryption_mode);
178 if (policy->flags & ~FSCRYPT_POLICY_FLAGS_VALID) {
179 fscrypt_warn(inode, "Unsupported encryption flags (0x%02x)",
184 count += !!(policy->flags & FSCRYPT_POLICY_FLAG_DIRECT_KEY);
185 count += !!(policy->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64);
186 count += !!(policy->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32);
188 fscrypt_warn(inode, "Mutually exclusive encryption flags (0x%02x)",
193 if ((policy->flags & FSCRYPT_POLICY_FLAG_DIRECT_KEY) &&
194 !supported_direct_key_modes(inode, policy->contents_encryption_mode,
195 policy->filenames_encryption_mode))
198 if ((policy->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_64) &&
199 !supported_iv_ino_lblk_policy(policy, inode, "IV_INO_LBLK_64",
204 * IV_INO_LBLK_32 hashes the inode number, so in principle it can
205 * support any ino_bits. However, currently the inode number is gotten
206 * from inode::i_ino which is 'unsigned long'. So for now the
207 * implementation limit is 32 bits.
209 if ((policy->flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32) &&
210 !supported_iv_ino_lblk_policy(policy, inode, "IV_INO_LBLK_32",
214 if (memchr_inv(policy->__reserved, 0, sizeof(policy->__reserved))) {
215 fscrypt_warn(inode, "Reserved bits set in encryption policy");
223 * fscrypt_supported_policy() - check whether an encryption policy is supported
224 * @policy_u: the encryption policy
225 * @inode: the inode on which the policy will be used
227 * Given an encryption policy, check whether all its encryption modes and other
228 * settings are supported by this kernel on the given inode. (But we don't
229 * currently don't check for crypto API support here, so attempting to use an
230 * algorithm not configured into the crypto API will still fail later.)
232 * Return: %true if supported, else %false
234 bool fscrypt_supported_policy(const union fscrypt_policy *policy_u,
235 const struct inode *inode)
237 switch (policy_u->version) {
238 case FSCRYPT_POLICY_V1:
239 return fscrypt_supported_v1_policy(&policy_u->v1, inode);
240 case FSCRYPT_POLICY_V2:
241 return fscrypt_supported_v2_policy(&policy_u->v2, inode);
247 * fscrypt_new_context() - create a new fscrypt_context
248 * @ctx_u: output context
249 * @policy_u: input policy
250 * @nonce: nonce to use
252 * Create an fscrypt_context for an inode that is being assigned the given
253 * encryption policy. @nonce must be a new random nonce.
255 * Return: the size of the new context in bytes.
257 static int fscrypt_new_context(union fscrypt_context *ctx_u,
258 const union fscrypt_policy *policy_u,
259 const u8 nonce[FSCRYPT_FILE_NONCE_SIZE])
261 memset(ctx_u, 0, sizeof(*ctx_u));
263 switch (policy_u->version) {
264 case FSCRYPT_POLICY_V1: {
265 const struct fscrypt_policy_v1 *policy = &policy_u->v1;
266 struct fscrypt_context_v1 *ctx = &ctx_u->v1;
268 ctx->version = FSCRYPT_CONTEXT_V1;
269 ctx->contents_encryption_mode =
270 policy->contents_encryption_mode;
271 ctx->filenames_encryption_mode =
272 policy->filenames_encryption_mode;
273 ctx->flags = policy->flags;
274 memcpy(ctx->master_key_descriptor,
275 policy->master_key_descriptor,
276 sizeof(ctx->master_key_descriptor));
277 memcpy(ctx->nonce, nonce, FSCRYPT_FILE_NONCE_SIZE);
280 case FSCRYPT_POLICY_V2: {
281 const struct fscrypt_policy_v2 *policy = &policy_u->v2;
282 struct fscrypt_context_v2 *ctx = &ctx_u->v2;
284 ctx->version = FSCRYPT_CONTEXT_V2;
285 ctx->contents_encryption_mode =
286 policy->contents_encryption_mode;
287 ctx->filenames_encryption_mode =
288 policy->filenames_encryption_mode;
289 ctx->flags = policy->flags;
290 memcpy(ctx->master_key_identifier,
291 policy->master_key_identifier,
292 sizeof(ctx->master_key_identifier));
293 memcpy(ctx->nonce, nonce, FSCRYPT_FILE_NONCE_SIZE);
301 * fscrypt_policy_from_context() - convert an fscrypt_context to
303 * @policy_u: output policy
304 * @ctx_u: input context
305 * @ctx_size: size of input context in bytes
307 * Given an fscrypt_context, build the corresponding fscrypt_policy.
309 * Return: 0 on success, or -EINVAL if the fscrypt_context has an unrecognized
310 * version number or size.
312 * This does *not* validate the settings within the policy itself, e.g. the
313 * modes, flags, and reserved bits. Use fscrypt_supported_policy() for that.
315 int fscrypt_policy_from_context(union fscrypt_policy *policy_u,
316 const union fscrypt_context *ctx_u,
319 memset(policy_u, 0, sizeof(*policy_u));
321 if (!fscrypt_context_is_valid(ctx_u, ctx_size))
324 switch (ctx_u->version) {
325 case FSCRYPT_CONTEXT_V1: {
326 const struct fscrypt_context_v1 *ctx = &ctx_u->v1;
327 struct fscrypt_policy_v1 *policy = &policy_u->v1;
329 policy->version = FSCRYPT_POLICY_V1;
330 policy->contents_encryption_mode =
331 ctx->contents_encryption_mode;
332 policy->filenames_encryption_mode =
333 ctx->filenames_encryption_mode;
334 policy->flags = ctx->flags;
335 memcpy(policy->master_key_descriptor,
336 ctx->master_key_descriptor,
337 sizeof(policy->master_key_descriptor));
340 case FSCRYPT_CONTEXT_V2: {
341 const struct fscrypt_context_v2 *ctx = &ctx_u->v2;
342 struct fscrypt_policy_v2 *policy = &policy_u->v2;
344 policy->version = FSCRYPT_POLICY_V2;
345 policy->contents_encryption_mode =
346 ctx->contents_encryption_mode;
347 policy->filenames_encryption_mode =
348 ctx->filenames_encryption_mode;
349 policy->flags = ctx->flags;
350 memcpy(policy->__reserved, ctx->__reserved,
351 sizeof(policy->__reserved));
352 memcpy(policy->master_key_identifier,
353 ctx->master_key_identifier,
354 sizeof(policy->master_key_identifier));
362 /* Retrieve an inode's encryption policy */
363 static int fscrypt_get_policy(struct inode *inode, union fscrypt_policy *policy)
365 const struct fscrypt_info *ci;
366 union fscrypt_context ctx;
369 ci = fscrypt_get_info(inode);
371 /* key available, use the cached policy */
372 *policy = ci->ci_policy;
376 if (!IS_ENCRYPTED(inode))
379 ret = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
381 return (ret == -ERANGE) ? -EINVAL : ret;
383 return fscrypt_policy_from_context(policy, &ctx, ret);
386 static int set_encryption_policy(struct inode *inode,
387 const union fscrypt_policy *policy)
389 u8 nonce[FSCRYPT_FILE_NONCE_SIZE];
390 union fscrypt_context ctx;
394 if (!fscrypt_supported_policy(policy, inode))
397 switch (policy->version) {
398 case FSCRYPT_POLICY_V1:
400 * The original encryption policy version provided no way of
401 * verifying that the correct master key was supplied, which was
402 * insecure in scenarios where multiple users have access to the
403 * same encrypted files (even just read-only access). The new
404 * encryption policy version fixes this and also implies use of
405 * an improved key derivation function and allows non-root users
406 * to securely remove keys. So as long as compatibility with
407 * old kernels isn't required, it is recommended to use the new
408 * policy version for all new encrypted directories.
410 pr_warn_once("%s (pid %d) is setting deprecated v1 encryption policy; recommend upgrading to v2.\n",
411 current->comm, current->pid);
413 case FSCRYPT_POLICY_V2:
414 err = fscrypt_verify_key_added(inode->i_sb,
415 policy->v2.master_key_identifier);
418 if (policy->v2.flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32)
419 pr_warn_once("%s (pid %d) is setting an IV_INO_LBLK_32 encryption policy. This should only be used if there are certain hardware limitations.\n",
420 current->comm, current->pid);
427 get_random_bytes(nonce, FSCRYPT_FILE_NONCE_SIZE);
428 ctxsize = fscrypt_new_context(&ctx, policy, nonce);
430 return inode->i_sb->s_cop->set_context(inode, &ctx, ctxsize, NULL);
433 int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg)
435 union fscrypt_policy policy;
436 union fscrypt_policy existing_policy;
437 struct inode *inode = file_inode(filp);
442 if (get_user(policy.version, (const u8 __user *)arg))
445 size = fscrypt_policy_size(&policy);
450 * We should just copy the remaining 'size - 1' bytes here, but a
451 * bizarre bug in gcc 7 and earlier (fixed by gcc r255731) causes gcc to
452 * think that size can be 0 here (despite the check above!) *and* that
453 * it's a compile-time constant. Thus it would think copy_from_user()
454 * is passed compile-time constant ULONG_MAX, causing the compile-time
455 * buffer overflow check to fail, breaking the build. This only occurred
456 * when building an i386 kernel with -Os and branch profiling enabled.
458 * Work around it by just copying the first byte again...
460 version = policy.version;
461 if (copy_from_user(&policy, arg, size))
463 policy.version = version;
465 if (!inode_owner_or_capable(inode))
468 ret = mnt_want_write_file(filp);
474 ret = fscrypt_get_policy(inode, &existing_policy);
475 if (ret == -ENODATA) {
476 if (!S_ISDIR(inode->i_mode))
478 else if (IS_DEADDIR(inode))
480 else if (!inode->i_sb->s_cop->empty_dir(inode))
483 ret = set_encryption_policy(inode, &policy);
484 } else if (ret == -EINVAL ||
485 (ret == 0 && !fscrypt_policies_equal(&policy,
486 &existing_policy))) {
487 /* The file already uses a different encryption policy. */
493 mnt_drop_write_file(filp);
496 EXPORT_SYMBOL(fscrypt_ioctl_set_policy);
498 /* Original ioctl version; can only get the original policy version */
499 int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg)
501 union fscrypt_policy policy;
504 err = fscrypt_get_policy(file_inode(filp), &policy);
508 if (policy.version != FSCRYPT_POLICY_V1)
511 if (copy_to_user(arg, &policy, sizeof(policy.v1)))
515 EXPORT_SYMBOL(fscrypt_ioctl_get_policy);
517 /* Extended ioctl version; can get policies of any version */
518 int fscrypt_ioctl_get_policy_ex(struct file *filp, void __user *uarg)
520 struct fscrypt_get_policy_ex_arg arg;
521 union fscrypt_policy *policy = (union fscrypt_policy *)&arg.policy;
525 /* arg is policy_size, then policy */
526 BUILD_BUG_ON(offsetof(typeof(arg), policy_size) != 0);
527 BUILD_BUG_ON(offsetofend(typeof(arg), policy_size) !=
528 offsetof(typeof(arg), policy));
529 BUILD_BUG_ON(sizeof(arg.policy) != sizeof(*policy));
531 err = fscrypt_get_policy(file_inode(filp), policy);
534 policy_size = fscrypt_policy_size(policy);
536 if (copy_from_user(&arg, uarg, sizeof(arg.policy_size)))
539 if (policy_size > arg.policy_size)
541 arg.policy_size = policy_size;
543 if (copy_to_user(uarg, &arg, sizeof(arg.policy_size) + policy_size))
547 EXPORT_SYMBOL_GPL(fscrypt_ioctl_get_policy_ex);
549 /* FS_IOC_GET_ENCRYPTION_NONCE: retrieve file's encryption nonce for testing */
550 int fscrypt_ioctl_get_nonce(struct file *filp, void __user *arg)
552 struct inode *inode = file_inode(filp);
553 union fscrypt_context ctx;
556 ret = inode->i_sb->s_cop->get_context(inode, &ctx, sizeof(ctx));
559 if (!fscrypt_context_is_valid(&ctx, ret))
561 if (copy_to_user(arg, fscrypt_context_nonce(&ctx),
562 FSCRYPT_FILE_NONCE_SIZE))
566 EXPORT_SYMBOL_GPL(fscrypt_ioctl_get_nonce);
569 * fscrypt_has_permitted_context() - is a file's encryption policy permitted
570 * within its directory?
572 * @parent: inode for parent directory
573 * @child: inode for file being looked up, opened, or linked into @parent
575 * Filesystems must call this before permitting access to an inode in a
576 * situation where the parent directory is encrypted (either before allowing
577 * ->lookup() to succeed, or for a regular file before allowing it to be opened)
578 * and before any operation that involves linking an inode into an encrypted
579 * directory, including link, rename, and cross rename. It enforces the
580 * constraint that within a given encrypted directory tree, all files use the
581 * same encryption policy. The pre-access check is needed to detect potentially
582 * malicious offline violations of this constraint, while the link and rename
583 * checks are needed to prevent online violations of this constraint.
585 * Return: 1 if permitted, 0 if forbidden.
587 int fscrypt_has_permitted_context(struct inode *parent, struct inode *child)
589 union fscrypt_policy parent_policy, child_policy;
592 /* No restrictions on file types which are never encrypted */
593 if (!S_ISREG(child->i_mode) && !S_ISDIR(child->i_mode) &&
594 !S_ISLNK(child->i_mode))
597 /* No restrictions if the parent directory is unencrypted */
598 if (!IS_ENCRYPTED(parent))
601 /* Encrypted directories must not contain unencrypted files */
602 if (!IS_ENCRYPTED(child))
606 * Both parent and child are encrypted, so verify they use the same
607 * encryption policy. Compare the fscrypt_info structs if the keys are
608 * available, otherwise retrieve and compare the fscrypt_contexts.
610 * Note that the fscrypt_context retrieval will be required frequently
611 * when accessing an encrypted directory tree without the key.
612 * Performance-wise this is not a big deal because we already don't
613 * really optimize for file access without the key (to the extent that
614 * such access is even possible), given that any attempted access
615 * already causes a fscrypt_context retrieval and keyring search.
617 * In any case, if an unexpected error occurs, fall back to "forbidden".
620 err = fscrypt_get_encryption_info(parent);
623 err = fscrypt_get_encryption_info(child);
627 err = fscrypt_get_policy(parent, &parent_policy);
631 err = fscrypt_get_policy(child, &child_policy);
635 return fscrypt_policies_equal(&parent_policy, &child_policy);
637 EXPORT_SYMBOL(fscrypt_has_permitted_context);
640 * Return the encryption policy that new files in the directory will inherit, or
641 * NULL if none, or an ERR_PTR() on error. If the directory is encrypted, also
642 * ensure that its key is set up, so that the new filename can be encrypted.
644 const union fscrypt_policy *fscrypt_policy_to_inherit(struct inode *dir)
648 if (IS_ENCRYPTED(dir)) {
649 err = fscrypt_require_key(dir);
652 return &dir->i_crypt_info->ci_policy;
655 return fscrypt_get_dummy_policy(dir->i_sb);
659 * fscrypt_set_context() - Set the fscrypt context of a new inode
660 * @inode: a new inode
661 * @fs_data: private data given by FS and passed to ->set_context()
663 * This should be called after fscrypt_prepare_new_inode(), generally during a
664 * filesystem transaction. Everything here must be %GFP_NOFS-safe.
666 * Return: 0 on success, -errno on failure
668 int fscrypt_set_context(struct inode *inode, void *fs_data)
670 struct fscrypt_info *ci = inode->i_crypt_info;
671 union fscrypt_context ctx;
674 /* fscrypt_prepare_new_inode() should have set up the key already. */
675 if (WARN_ON_ONCE(!ci))
678 BUILD_BUG_ON(sizeof(ctx) != FSCRYPT_SET_CONTEXT_MAX_SIZE);
679 ctxsize = fscrypt_new_context(&ctx, &ci->ci_policy, ci->ci_nonce);
682 * This may be the first time the inode number is available, so do any
683 * delayed key setup that requires the inode number.
685 if (ci->ci_policy.version == FSCRYPT_POLICY_V2 &&
686 (ci->ci_policy.v2.flags & FSCRYPT_POLICY_FLAG_IV_INO_LBLK_32)) {
687 const struct fscrypt_master_key *mk =
688 ci->ci_master_key->payload.data[0];
690 fscrypt_hash_inode_number(ci, mk);
693 return inode->i_sb->s_cop->set_context(inode, &ctx, ctxsize, fs_data);
695 EXPORT_SYMBOL_GPL(fscrypt_set_context);
698 * fscrypt_set_test_dummy_encryption() - handle '-o test_dummy_encryption'
699 * @sb: the filesystem on which test_dummy_encryption is being specified
700 * @arg: the argument to the test_dummy_encryption option. May be NULL.
701 * @dummy_policy: the filesystem's current dummy policy (input/output, see
704 * Handle the test_dummy_encryption mount option by creating a dummy encryption
705 * policy, saving it in @dummy_policy, and adding the corresponding dummy
706 * encryption key to the filesystem. If the @dummy_policy is already set, then
707 * instead validate that it matches @arg. Don't support changing it via
708 * remount, as that is difficult to do safely.
710 * Return: 0 on success (dummy policy set, or the same policy is already set);
711 * -EEXIST if a different dummy policy is already set;
712 * or another -errno value.
714 int fscrypt_set_test_dummy_encryption(struct super_block *sb, const char *arg,
715 struct fscrypt_dummy_policy *dummy_policy)
717 struct fscrypt_key_specifier key_spec = { 0 };
719 union fscrypt_policy *policy = NULL;
725 if (!strcmp(arg, "v1")) {
726 version = FSCRYPT_POLICY_V1;
727 key_spec.type = FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR;
728 memset(key_spec.u.descriptor, 0x42,
729 FSCRYPT_KEY_DESCRIPTOR_SIZE);
730 } else if (!strcmp(arg, "v2")) {
731 version = FSCRYPT_POLICY_V2;
732 key_spec.type = FSCRYPT_KEY_SPEC_TYPE_IDENTIFIER;
733 /* key_spec.u.identifier gets filled in when adding the key */
739 policy = kzalloc(sizeof(*policy), GFP_KERNEL);
745 err = fscrypt_add_test_dummy_key(sb, &key_spec);
749 policy->version = version;
750 switch (policy->version) {
751 case FSCRYPT_POLICY_V1:
752 policy->v1.contents_encryption_mode = FSCRYPT_MODE_AES_256_XTS;
753 policy->v1.filenames_encryption_mode = FSCRYPT_MODE_AES_256_CTS;
754 memcpy(policy->v1.master_key_descriptor, key_spec.u.descriptor,
755 FSCRYPT_KEY_DESCRIPTOR_SIZE);
757 case FSCRYPT_POLICY_V2:
758 policy->v2.contents_encryption_mode = FSCRYPT_MODE_AES_256_XTS;
759 policy->v2.filenames_encryption_mode = FSCRYPT_MODE_AES_256_CTS;
760 memcpy(policy->v2.master_key_identifier, key_spec.u.identifier,
761 FSCRYPT_KEY_IDENTIFIER_SIZE);
769 if (dummy_policy->policy) {
770 if (fscrypt_policies_equal(policy, dummy_policy->policy))
776 dummy_policy->policy = policy;
783 EXPORT_SYMBOL_GPL(fscrypt_set_test_dummy_encryption);
786 * fscrypt_show_test_dummy_encryption() - show '-o test_dummy_encryption'
787 * @seq: the seq_file to print the option to
788 * @sep: the separator character to use
789 * @sb: the filesystem whose options are being shown
791 * Show the test_dummy_encryption mount option, if it was specified.
792 * This is mainly used for /proc/mounts.
794 void fscrypt_show_test_dummy_encryption(struct seq_file *seq, char sep,
795 struct super_block *sb)
797 const union fscrypt_policy *policy = fscrypt_get_dummy_policy(sb);
803 vers = policy->version;
804 if (vers == FSCRYPT_POLICY_V1) /* Handle numbering quirk */
807 seq_printf(seq, "%ctest_dummy_encryption=v%d", sep, vers);
809 EXPORT_SYMBOL_GPL(fscrypt_show_test_dummy_encryption);