fscrypt: make fscrypt_set_test_dummy_encryption() take a 'const char *'
fscrypt_set_test_dummy_encryption() requires that the optional argument to the test_dummy_encryption mount option be specified as a substring_t. That doesn't work well with filesystems that use the new mount API, since the new way of parsing mount options doesn't use substring_t. Make it take the argument as a 'const char *' instead. Instead of moving the match_strdup() into the callers in ext4 and f2fs, make them just use arg->from directly. Since the pattern is "test_dummy_encryption=%s", the argument will be null-terminated. Acked-by: Jeff Layton <jlayton@kernel.org> Link: https://lore.kernel.org/r/20200917041136.178600-14-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@google.com>
This commit is contained in:
parent
ac4acb1f4b
commit
c8c868abc9
@ -697,8 +697,7 @@ EXPORT_SYMBOL_GPL(fscrypt_set_context);
|
|||||||
/**
|
/**
|
||||||
* fscrypt_set_test_dummy_encryption() - handle '-o test_dummy_encryption'
|
* fscrypt_set_test_dummy_encryption() - handle '-o test_dummy_encryption'
|
||||||
* @sb: the filesystem on which test_dummy_encryption is being specified
|
* @sb: the filesystem on which test_dummy_encryption is being specified
|
||||||
* @arg: the argument to the test_dummy_encryption option.
|
* @arg: the argument to the test_dummy_encryption option. May be NULL.
|
||||||
* If no argument was specified, then @arg->from == NULL.
|
|
||||||
* @dummy_policy: the filesystem's current dummy policy (input/output, see
|
* @dummy_policy: the filesystem's current dummy policy (input/output, see
|
||||||
* below)
|
* below)
|
||||||
*
|
*
|
||||||
@ -712,29 +711,23 @@ EXPORT_SYMBOL_GPL(fscrypt_set_context);
|
|||||||
* -EEXIST if a different dummy policy is already set;
|
* -EEXIST if a different dummy policy is already set;
|
||||||
* or another -errno value.
|
* or another -errno value.
|
||||||
*/
|
*/
|
||||||
int fscrypt_set_test_dummy_encryption(struct super_block *sb,
|
int fscrypt_set_test_dummy_encryption(struct super_block *sb, const char *arg,
|
||||||
const substring_t *arg,
|
|
||||||
struct fscrypt_dummy_policy *dummy_policy)
|
struct fscrypt_dummy_policy *dummy_policy)
|
||||||
{
|
{
|
||||||
const char *argstr = "v2";
|
|
||||||
const char *argstr_to_free = NULL;
|
|
||||||
struct fscrypt_key_specifier key_spec = { 0 };
|
struct fscrypt_key_specifier key_spec = { 0 };
|
||||||
int version;
|
int version;
|
||||||
union fscrypt_policy *policy = NULL;
|
union fscrypt_policy *policy = NULL;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (arg->from) {
|
if (!arg)
|
||||||
argstr = argstr_to_free = match_strdup(arg);
|
arg = "v2";
|
||||||
if (!argstr)
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!strcmp(argstr, "v1")) {
|
if (!strcmp(arg, "v1")) {
|
||||||
version = FSCRYPT_POLICY_V1;
|
version = FSCRYPT_POLICY_V1;
|
||||||
key_spec.type = FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR;
|
key_spec.type = FSCRYPT_KEY_SPEC_TYPE_DESCRIPTOR;
|
||||||
memset(key_spec.u.descriptor, 0x42,
|
memset(key_spec.u.descriptor, 0x42,
|
||||||
FSCRYPT_KEY_DESCRIPTOR_SIZE);
|
FSCRYPT_KEY_DESCRIPTOR_SIZE);
|
||||||
} else if (!strcmp(argstr, "v2")) {
|
} else if (!strcmp(arg, "v2")) {
|
||||||
version = FSCRYPT_POLICY_V2;
|
version = FSCRYPT_POLICY_V2;
|
||||||
key_spec.type = FSCRYPT_KEY_SPEC_TYPE_IDENTIFIER;
|
key_spec.type = FSCRYPT_KEY_SPEC_TYPE_IDENTIFIER;
|
||||||
/* key_spec.u.identifier gets filled in when adding the key */
|
/* key_spec.u.identifier gets filled in when adding the key */
|
||||||
@ -785,7 +778,6 @@ int fscrypt_set_test_dummy_encryption(struct super_block *sb,
|
|||||||
err = 0;
|
err = 0;
|
||||||
out:
|
out:
|
||||||
kfree(policy);
|
kfree(policy);
|
||||||
kfree(argstr_to_free);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(fscrypt_set_test_dummy_encryption);
|
EXPORT_SYMBOL_GPL(fscrypt_set_test_dummy_encryption);
|
||||||
|
@ -1892,7 +1892,7 @@ static int ext4_set_test_dummy_encryption(struct super_block *sb,
|
|||||||
"Can't set test_dummy_encryption on remount");
|
"Can't set test_dummy_encryption on remount");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
err = fscrypt_set_test_dummy_encryption(sb, arg,
|
err = fscrypt_set_test_dummy_encryption(sb, arg->from,
|
||||||
&sbi->s_dummy_enc_policy);
|
&sbi->s_dummy_enc_policy);
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err == -EEXIST)
|
if (err == -EEXIST)
|
||||||
|
@ -438,7 +438,7 @@ static int f2fs_set_test_dummy_encryption(struct super_block *sb,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
err = fscrypt_set_test_dummy_encryption(
|
err = fscrypt_set_test_dummy_encryption(
|
||||||
sb, arg, &F2FS_OPTION(sbi).dummy_enc_policy);
|
sb, arg->from, &F2FS_OPTION(sbi).dummy_enc_policy);
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err == -EEXIST)
|
if (err == -EEXIST)
|
||||||
f2fs_warn(sbi,
|
f2fs_warn(sbi,
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#include <linux/fs.h>
|
#include <linux/fs.h>
|
||||||
#include <linux/mm.h>
|
#include <linux/mm.h>
|
||||||
#include <linux/parser.h>
|
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
#include <uapi/linux/fscrypt.h>
|
#include <uapi/linux/fscrypt.h>
|
||||||
|
|
||||||
@ -153,9 +152,7 @@ struct fscrypt_dummy_policy {
|
|||||||
const union fscrypt_policy *policy;
|
const union fscrypt_policy *policy;
|
||||||
};
|
};
|
||||||
|
|
||||||
int fscrypt_set_test_dummy_encryption(
|
int fscrypt_set_test_dummy_encryption(struct super_block *sb, const char *arg,
|
||||||
struct super_block *sb,
|
|
||||||
const substring_t *arg,
|
|
||||||
struct fscrypt_dummy_policy *dummy_policy);
|
struct fscrypt_dummy_policy *dummy_policy);
|
||||||
void fscrypt_show_test_dummy_encryption(struct seq_file *seq, char sep,
|
void fscrypt_show_test_dummy_encryption(struct seq_file *seq, char sep,
|
||||||
struct super_block *sb);
|
struct super_block *sb);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user