Skip to contentSkip to conversation

eCryptfs: Versioning fixes

PATCH New Michael Halcrow 1 participant 1 message Sep 13, 2006 Ecrypt file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eCryptfs: Versioning fixes

eCryptfs userspace utilities need to be able to detect what is and is not supported by the kernel module. This patch cleans up the auth_tok data structure that is shared between kernel and userspace via the kernel keyring, reserving some space for future struct components that will be needed as eCryptfs gains more features. It also introduces some sysfs handles that the userspace utilities query to determine how the tools should behave. These changes will help ensure that, from this point forward, any version of the kernel module will properly work with any version of the userspace tools without any need to recompile code.

All userspace utility packages (available from the SourceForge site as detailed in Documents/ecryptfs.txt) before ecryptfs-util-1.tar.bz2 are incompatible with the changes made in this patch. Future versions of the userspace utilities will no longer reference kernel version numbers, but they will rather detect capabilities supported based on the sysfs version handle.

---

 fs/ecryptfs/debug.c           |    7 --
 fs/ecryptfs/ecryptfs_kernel.h |   26 ++++--
 fs/ecryptfs/keystore.c        |    9 +-
 fs/ecryptfs/main.c            |  172 ++++++++++++++++++++++++++++++++++++++---
 4 files changed, 178 insertions(+), 36 deletions(-)

8bcdd6b086d025a86ef5573bb8ceaa6f12c8ad95

fs/ecryptfs/debug.c +0 -7
index 2261945..61f8e89 100644
@@ -55,13 +55,6 @@ void ecryptfs_dump_auth_tok(struct ecryp
 		sig[ECRYPTFS_SIG_SIZE_HEX] = '\0';
 		ecryptfs_printk(KERN_DEBUG, " * signature = [%s]\n", sig);
 	}
-	if (ECRYPTFS_CHECK_FLAG(auth_tok->flags, ECRYPTFS_CONTAINS_SECRET)) {
-		ecryptfs_printk(KERN_DEBUG, " * contains secret value\n");
-	} else {
-		ecryptfs_printk(KERN_DEBUG, " * lacks secret value\n");
-	}
-	if (ECRYPTFS_CHECK_FLAG(auth_tok->flags, ECRYPTFS_EXPIRED))
-		ecryptfs_printk(KERN_DEBUG, " * expired\n");
 	ecryptfs_printk(KERN_DEBUG, " * session_key.flags = [0x%x]\n",
 			auth_tok->session_key.flags);
 	if (auth_tok->session_key.flags
fs/ecryptfs/ecryptfs_kernel.h +16 -10
index 2b7ae27..4cfba7d 100644
@@ -32,8 +32,17 @@ #include <linux/scatterlist.h>
 
 /* Version verification for shared data structures w/ userspace */
 #define ECRYPTFS_VERSION_MAJOR 0x00
-#define ECRYPTFS_VERSION_MINOR 0x02
+#define ECRYPTFS_VERSION_MINOR 0x04
 #define ECRYPTFS_SUPPORTED_FILE_VERSION 0x01
+/* These flags indicate which features are supported by the kernel
+ * module; userspace tools such as the mount helper read
+ * ECRYPTFS_VERSIONING_MASK from a sysfs handle in order to determine
+ * how to behave. */
+#define ECRYPTFS_VERSIONING_PASSPHRASE 0x00000001
+#define ECRYPTFS_VERSIONING_PUBKEY 0x00000002
+#define ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH 0x00000004
+#define ECRYPTFS_VERSIONING_POLICY 0x00000008
+#define ECRYPTFS_VERSIONING_MASK (ECRYPTFS_VERSIONING_PASSPHRASE)
 
 #define ECRYPTFS_MAX_PASSWORD_LENGTH 64
 #define ECRYPTFS_MAX_PASSPHRASE_BYTES ECRYPTFS_MAX_PASSWORD_LENGTH
@@ -100,23 +109,20 @@ #define ECRYPTFS_SESSION_KEY_ENCRYPTION_
 	u8 salt[ECRYPTFS_SALT_SIZE];
 };
 
+enum ecryptfs_token_types {ECRYPTFS_PASSWORD, ECRYPTFS_PRIVATE_KEY};
+
 /* May be a password or a private key */
 struct ecryptfs_auth_tok {
 	u16 version; /* 8-bit major and 8-bit minor */
-#define ECRYPTFS_PASSWORD         0x00000001
-#define ECRYPTFS_PRIVATE_KEY      0x00000002
-#define ECRYPTFS_CONTAINS_SECRET  0x00000004
-#define ECRYPTFS_EXPIRED          0x00000008
+	u16 token_type;
 	u32 flags;
-	uid_t uid;
-	u64 creation_time;
-	u64 expiration_time;
+	struct ecryptfs_session_key session_key;
+	u8 reserved[32];
 	union {
 		struct ecryptfs_password password;
 		/* Private key is in future eCryptfs releases */
 	} token;
-	struct ecryptfs_session_key session_key;
-};
+} __attribute__ ((packed));
 
 void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok);
 extern void ecryptfs_to_hex(char *dst, char *src, size_t src_size);
fs/ecryptfs/keystore.c +3 -6
index 35ba927..ba45478 100644
@@ -318,9 +318,7 @@ parse_tag_3_packet(struct ecryptfs_crypt
 		rc = -ENOSYS;
 		goto out_free;
 	}
-	/* TODO: Use the keyring */
-	(*new_auth_tok)->uid = current->uid;
-	ECRYPTFS_SET_FLAG((*new_auth_tok)->flags, ECRYPTFS_PASSWORD);
+	(*new_auth_tok)->token_type = ECRYPTFS_PASSWORD;
 	/* TODO: Parametarize; we might actually want userspace to
 	 * decrypt the session key. */
 	ECRYPTFS_CLEAR_FLAG((*new_auth_tok)->session_key.flags,
@@ -688,8 +686,7 @@ int ecryptfs_parse_packet_set(struct ecr
 			ecryptfs_dump_auth_tok(candidate_auth_tok);
 		}
 		/* TODO: Replace ECRYPTFS_SIG_SIZE_HEX w/ dynamic value */
-		if ((ECRYPTFS_CHECK_FLAG(candidate_auth_tok->flags,
-					 ECRYPTFS_PASSWORD))
+		if (candidate_auth_tok->token_type == ECRYPTFS_PASSWORD
 		    && !strncmp(candidate_auth_tok->token.password.signature,
 				sig, ECRYPTFS_SIG_SIZE_HEX)) {
 			found_auth_tok = 1;
@@ -1013,7 +1010,7 @@ ecryptfs_generate_key_packet_set(char *d
 	(*len) = 0;
 	if (mount_crypt_stat->global_auth_tok) {
 		auth_tok = mount_crypt_stat->global_auth_tok;
-		if (ECRYPTFS_CHECK_FLAG(auth_tok->flags, ECRYPTFS_PASSWORD)) {
+		if (auth_tok->token_type == ECRYPTFS_PASSWORD) {
 			rc = write_tag_3_packet((dest_base + (*len)),
 						max, auth_tok,
 						crypt_stat, &key_rec,
fs/ecryptfs/main.c +159 -13

219 lines not on this page · raw message

Signature · 1 line
1.3.3