Skip to content

Commit f16feb5

Browse files
Roberto SassuTyler Hicks
authored andcommitted
ecryptfs: added ecryptfs_mount_auth_tok_only mount parameter
This patch adds a new mount parameter 'ecryptfs_mount_auth_tok_only' to force ecryptfs to use only authentication tokens which signature has been specified at mount time with parameters 'ecryptfs_sig' and 'ecryptfs_fnek_sig'. In this way, after disabling the passthrough and the encrypted view modes, it's possible to make available to users only files encrypted with the specified authentication token. Signed-off-by: Roberto Sassu <roberto.sassu@polito.it> Cc: Dustin Kirkland <kirkland@canonical.com> Cc: James Morris <jmorris@namei.org> [Tyler: Clean up coding style errors found by checkpatch] Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
1 parent 39fac85 commit f16feb5

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎fs/ecryptfs/ecryptfs_kernel.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ struct ecryptfs_mount_crypt_stat {
377377
#define ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES 0x00000010
378378
#define ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK 0x00000020
379379
#define ECRYPTFS_GLOBAL_ENCFN_USE_FEK 0x00000040
380+
#define ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY 0x00000080
380381
u32 flags;
381382
struct list_head global_auth_tok_list;
382383
struct mutex global_auth_tok_list_mutex;

‎fs/ecryptfs/keystore.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,15 @@ ecryptfs_find_auth_tok_for_sig(
459459
if (ecryptfs_find_global_auth_tok_for_sig(&global_auth_tok,
460460
mount_crypt_stat, sig)) {
461461

462+
/* if the flag ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY is set in the
463+
* mount_crypt_stat structure, we prevent to use auth toks that
464+
* are not inserted through the ecryptfs_add_global_auth_tok
465+
* function.
466+
*/
467+
if (mount_crypt_stat->flags
468+
& ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY)
469+
return -EINVAL;
470+
462471
rc = ecryptfs_keyring_auth_tok_for_sig(auth_tok_key, auth_tok,
463472
sig);
464473
} else

‎fs/ecryptfs/main.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ enum { ecryptfs_opt_sig, ecryptfs_opt_ecryptfs_sig,
208208
ecryptfs_opt_passthrough, ecryptfs_opt_xattr_metadata,
209209
ecryptfs_opt_encrypted_view, ecryptfs_opt_fnek_sig,
210210
ecryptfs_opt_fn_cipher, ecryptfs_opt_fn_cipher_key_bytes,
211-
ecryptfs_opt_unlink_sigs, ecryptfs_opt_err };
211+
ecryptfs_opt_unlink_sigs, ecryptfs_opt_mount_auth_tok_only,
212+
ecryptfs_opt_err };
212213

213214
static const match_table_t tokens = {
214215
{ecryptfs_opt_sig, "sig=%s"},
@@ -223,6 +224,7 @@ static const match_table_t tokens = {
223224
{ecryptfs_opt_fn_cipher, "ecryptfs_fn_cipher=%s"},
224225
{ecryptfs_opt_fn_cipher_key_bytes, "ecryptfs_fn_key_bytes=%u"},
225226
{ecryptfs_opt_unlink_sigs, "ecryptfs_unlink_sigs"},
227+
{ecryptfs_opt_mount_auth_tok_only, "ecryptfs_mount_auth_tok_only"},
226228
{ecryptfs_opt_err, NULL}
227229
};
228230

@@ -406,6 +408,10 @@ static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options)
406408
case ecryptfs_opt_unlink_sigs:
407409
mount_crypt_stat->flags |= ECRYPTFS_UNLINK_SIGS;
408410
break;
411+
case ecryptfs_opt_mount_auth_tok_only:
412+
mount_crypt_stat->flags |=
413+
ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY;
414+
break;
409415
case ecryptfs_opt_err:
410416
default:
411417
printk(KERN_WARNING

0 commit comments

Comments
 (0)