[RFC][PATCH 3/4] eCryptfs: override prepared credentials
From: Roberto Sassu
Date: Fri Apr 29 2011 - 09:44:55 EST
The new mount parameter 'ecryptfs_security_ctx' allows to override the
security label of the filesystem's credentials. This feature can be used to
identify or restrict actions performed by a specific eCryptfs filesystem.
Signed-off-by: Roberto Sassu <roberto.sassu@xxxxxxxxx>
---
fs/ecryptfs/main.c | 16 +++++++++++++++-
1 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c
index d53f834..075634b 100644
--- a/fs/ecryptfs/main.c
+++ b/fs/ecryptfs/main.c
@@ -254,7 +254,7 @@ enum { ecryptfs_opt_sig, ecryptfs_opt_ecryptfs_sig,
ecryptfs_opt_encrypted_view, ecryptfs_opt_fnek_sig,
ecryptfs_opt_fn_cipher, ecryptfs_opt_fn_cipher_key_bytes,
ecryptfs_opt_unlink_sigs, ecryptfs_opt_mount_auth_tok_only,
- ecryptfs_opt_err };
+ ecryptfs_opt_security_ctx, ecryptfs_opt_err };
static const match_table_t tokens = {
{ecryptfs_opt_sig, "sig=%s"},
@@ -270,6 +270,7 @@ static const match_table_t tokens = {
{ecryptfs_opt_fn_cipher_key_bytes, "ecryptfs_fn_key_bytes=%u"},
{ecryptfs_opt_unlink_sigs, "ecryptfs_unlink_sigs"},
{ecryptfs_opt_mount_auth_tok_only, "ecryptfs_mount_auth_tok_only"},
+ {ecryptfs_opt_security_ctx, "ecryptfs_security_ctx=%s"},
{ecryptfs_opt_err, NULL}
};
@@ -365,6 +366,7 @@ static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options)
char *fnek_src;
char *cipher_key_bytes_src;
char *fn_cipher_key_bytes_src;
+ char *security_ctx = NULL;
if (!options) {
rc = -EINVAL;
@@ -474,6 +476,9 @@ static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options)
mount_crypt_stat->flags |=
ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY;
break;
+ case ecryptfs_opt_security_ctx:
+ security_ctx = args[0].from;
+ break;
case ecryptfs_opt_err:
default:
printk(KERN_WARNING
@@ -505,6 +510,15 @@ static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options)
&& !fn_cipher_key_bytes_set)
mount_crypt_stat->global_default_fn_cipher_key_bytes =
mount_crypt_stat->global_default_cipher_key_size;
+ if (security_ctx) {
+ rc = set_security_override_from_ctx(
+ mount_crypt_stat->subject_cred, security_ctx);
+ if (rc) {
+ printk(KERN_ERR "%s: set_security_override_from_ctx "
+ "failed: rc = [%d]\n", __func__, rc);
+ goto out;
+ }
+ }
mutex_lock(&key_tfm_list_mutex);
if (!ecryptfs_tfm_exists(mount_crypt_stat->global_default_cipher_name,
NULL)) {
--
1.7.4.4
Attachment:
smime.p7s
Description: S/MIME cryptographic signature