diff options
author | Kees Cook <keescook@chromium.org> | 2013-02-28 03:39:37 -0500 |
---|---|---|
committer | Tyler Hicks <tyhicks@canonical.com> | 2013-03-04 02:59:59 -0500 |
commit | 290502bee239062499297916bb7d21d205e99d62 (patch) | |
tree | a9ec1729138c7f71c1c4e3e09ce12cf40db767e3 | |
parent | 1111eae90fb64a9d9ed133e410712f1e34fdce4a (diff) |
eCryptfs: allow userspace messaging to be disabled
When the userspace messaging (for the less common case of userspace key
wrap/unwrap via ecryptfsd) is not needed, allow eCryptfs to build with
it removed. This saves on kernel code size and reduces potential attack
surface by removing the /dev/ecryptfs node.
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
-rw-r--r-- | fs/ecryptfs/Kconfig | 8 | ||||
-rw-r--r-- | fs/ecryptfs/Makefile | 7 | ||||
-rw-r--r-- | fs/ecryptfs/ecryptfs_kernel.h | 40 | ||||
-rw-r--r-- | fs/ecryptfs/keystore.c | 4 | ||||
-rw-r--r-- | include/linux/ecryptfs.h | 12 |
5 files changed, 55 insertions, 16 deletions
diff --git a/fs/ecryptfs/Kconfig b/fs/ecryptfs/Kconfig index cc16562654de..1f63120b669a 100644 --- a/fs/ecryptfs/Kconfig +++ b/fs/ecryptfs/Kconfig | |||
@@ -12,3 +12,11 @@ config ECRYPT_FS | |||
12 | 12 | ||
13 | To compile this file system support as a module, choose M here: the | 13 | To compile this file system support as a module, choose M here: the |
14 | module will be called ecryptfs. | 14 | module will be called ecryptfs. |
15 | |||
16 | config ECRYPT_FS_MESSAGING | ||
17 | bool "Enable notifications for userspace key wrap/unwrap" | ||
18 | depends on ECRYPT_FS | ||
19 | help | ||
20 | Enables the /dev/ecryptfs entry for use by ecryptfsd. This allows | ||
21 | for userspace to wrap/unwrap file encryption keys by other | ||
22 | backends, like OpenSSL. | ||
diff --git a/fs/ecryptfs/Makefile b/fs/ecryptfs/Makefile index 2cc9ee4ad2eb..49678a69947d 100644 --- a/fs/ecryptfs/Makefile +++ b/fs/ecryptfs/Makefile | |||
@@ -1,7 +1,10 @@ | |||
1 | # | 1 | # |
2 | # Makefile for the Linux 2.6 eCryptfs | 2 | # Makefile for the Linux eCryptfs |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-$(CONFIG_ECRYPT_FS) += ecryptfs.o | 5 | obj-$(CONFIG_ECRYPT_FS) += ecryptfs.o |
6 | 6 | ||
7 | ecryptfs-objs := dentry.o file.o inode.o main.o super.o mmap.o read_write.o crypto.o keystore.o messaging.o miscdev.o kthread.o debug.o | 7 | ecryptfs-y := dentry.o file.o inode.o main.o super.o mmap.o read_write.o \ |
8 | crypto.o keystore.o kthread.o debug.o | ||
9 | |||
10 | ecryptfs-$(CONFIG_ECRYPT_FS_MESSAGING) += messaging.o miscdev.o | ||
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index cfb4b9fed520..a9df69efadc2 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
@@ -172,6 +172,19 @@ ecryptfs_get_key_payload_data(struct key *key) | |||
172 | #define ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE 24 | 172 | #define ECRYPTFS_FNEK_ENCRYPTED_FILENAME_PREFIX_SIZE 24 |
173 | #define ECRYPTFS_ENCRYPTED_DENTRY_NAME_LEN (18 + 1 + 4 + 1 + 32) | 173 | #define ECRYPTFS_ENCRYPTED_DENTRY_NAME_LEN (18 + 1 + 4 + 1 + 32) |
174 | 174 | ||
175 | #ifdef CONFIG_ECRYPT_FS_MESSAGING | ||
176 | # define ECRYPTFS_VERSIONING_MASK_MESSAGING (ECRYPTFS_VERSIONING_DEVMISC \ | ||
177 | | ECRYPTFS_VERSIONING_PUBKEY) | ||
178 | #else | ||
179 | # define ECRYPTFS_VERSIONING_MASK_MESSAGING 0 | ||
180 | #endif | ||
181 | |||
182 | #define ECRYPTFS_VERSIONING_MASK (ECRYPTFS_VERSIONING_PASSPHRASE \ | ||
183 | | ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH \ | ||
184 | | ECRYPTFS_VERSIONING_XATTR \ | ||
185 | | ECRYPTFS_VERSIONING_MULTKEY \ | ||
186 | | ECRYPTFS_VERSIONING_MASK_MESSAGING \ | ||
187 | | ECRYPTFS_VERSIONING_FILENAME_ENCRYPTION) | ||
175 | struct ecryptfs_key_sig { | 188 | struct ecryptfs_key_sig { |
176 | struct list_head crypt_stat_list; | 189 | struct list_head crypt_stat_list; |
177 | char keysig[ECRYPTFS_SIG_SIZE_HEX + 1]; | 190 | char keysig[ECRYPTFS_SIG_SIZE_HEX + 1]; |
@@ -399,7 +412,9 @@ struct ecryptfs_daemon { | |||
399 | struct hlist_node euid_chain; | 412 | struct hlist_node euid_chain; |
400 | }; | 413 | }; |
401 | 414 | ||
415 | #ifdef CONFIG_ECRYPT_FS_MESSAGING | ||
402 | extern struct mutex ecryptfs_daemon_hash_mux; | 416 | extern struct mutex ecryptfs_daemon_hash_mux; |
417 | #endif | ||
403 | 418 | ||
404 | static inline size_t | 419 | static inline size_t |
405 | ecryptfs_lower_header_size(struct ecryptfs_crypt_stat *crypt_stat) | 420 | ecryptfs_lower_header_size(struct ecryptfs_crypt_stat *crypt_stat) |
@@ -604,6 +619,7 @@ int | |||
604 | ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, | 619 | ecryptfs_setxattr(struct dentry *dentry, const char *name, const void *value, |
605 | size_t size, int flags); | 620 | size_t size, int flags); |
606 | int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode); | 621 | int ecryptfs_read_xattr_region(char *page_virt, struct inode *ecryptfs_inode); |
622 | #ifdef CONFIG_ECRYPT_FS_MESSAGING | ||
607 | int ecryptfs_process_response(struct ecryptfs_daemon *daemon, | 623 | int ecryptfs_process_response(struct ecryptfs_daemon *daemon, |
608 | struct ecryptfs_message *msg, u32 seq); | 624 | struct ecryptfs_message *msg, u32 seq); |
609 | int ecryptfs_send_message(char *data, int data_len, | 625 | int ecryptfs_send_message(char *data, int data_len, |
@@ -612,6 +628,24 @@ int ecryptfs_wait_for_response(struct ecryptfs_msg_ctx *msg_ctx, | |||
612 | struct ecryptfs_message **emsg); | 628 | struct ecryptfs_message **emsg); |
613 | int ecryptfs_init_messaging(void); | 629 | int ecryptfs_init_messaging(void); |
614 | void ecryptfs_release_messaging(void); | 630 | void ecryptfs_release_messaging(void); |
631 | #else | ||
632 | static inline int ecryptfs_init_messaging(void) | ||
633 | { | ||
634 | return 0; | ||
635 | } | ||
636 | static inline void ecryptfs_release_messaging(void) | ||
637 | { } | ||
638 | static inline int ecryptfs_send_message(char *data, int data_len, | ||
639 | struct ecryptfs_msg_ctx **msg_ctx) | ||
640 | { | ||
641 | return -ENOTCONN; | ||
642 | } | ||
643 | static inline int ecryptfs_wait_for_response(struct ecryptfs_msg_ctx *msg_ctx, | ||
644 | struct ecryptfs_message **emsg) | ||
645 | { | ||
646 | return -ENOMSG; | ||
647 | } | ||
648 | #endif | ||
615 | 649 | ||
616 | void | 650 | void |
617 | ecryptfs_write_header_metadata(char *virt, | 651 | ecryptfs_write_header_metadata(char *virt, |
@@ -649,12 +683,11 @@ int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs, | |||
649 | size_t offset_in_page, size_t size, | 683 | size_t offset_in_page, size_t size, |
650 | struct inode *ecryptfs_inode); | 684 | struct inode *ecryptfs_inode); |
651 | struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index); | 685 | struct page *ecryptfs_get_locked_page(struct inode *inode, loff_t index); |
652 | int ecryptfs_exorcise_daemon(struct ecryptfs_daemon *daemon); | ||
653 | int ecryptfs_find_daemon_by_euid(struct ecryptfs_daemon **daemon); | ||
654 | int ecryptfs_parse_packet_length(unsigned char *data, size_t *size, | 686 | int ecryptfs_parse_packet_length(unsigned char *data, size_t *size, |
655 | size_t *length_size); | 687 | size_t *length_size); |
656 | int ecryptfs_write_packet_length(char *dest, size_t size, | 688 | int ecryptfs_write_packet_length(char *dest, size_t size, |
657 | size_t *packet_size_length); | 689 | size_t *packet_size_length); |
690 | #ifdef CONFIG_ECRYPT_FS_MESSAGING | ||
658 | int ecryptfs_init_ecryptfs_miscdev(void); | 691 | int ecryptfs_init_ecryptfs_miscdev(void); |
659 | void ecryptfs_destroy_ecryptfs_miscdev(void); | 692 | void ecryptfs_destroy_ecryptfs_miscdev(void); |
660 | int ecryptfs_send_miscdev(char *data, size_t data_size, | 693 | int ecryptfs_send_miscdev(char *data, size_t data_size, |
@@ -663,6 +696,9 @@ int ecryptfs_send_miscdev(char *data, size_t data_size, | |||
663 | void ecryptfs_msg_ctx_alloc_to_free(struct ecryptfs_msg_ctx *msg_ctx); | 696 | void ecryptfs_msg_ctx_alloc_to_free(struct ecryptfs_msg_ctx *msg_ctx); |
664 | int | 697 | int |
665 | ecryptfs_spawn_daemon(struct ecryptfs_daemon **daemon, struct file *file); | 698 | ecryptfs_spawn_daemon(struct ecryptfs_daemon **daemon, struct file *file); |
699 | int ecryptfs_exorcise_daemon(struct ecryptfs_daemon *daemon); | ||
700 | int ecryptfs_find_daemon_by_euid(struct ecryptfs_daemon **daemon); | ||
701 | #endif | ||
666 | int ecryptfs_init_kthread(void); | 702 | int ecryptfs_init_kthread(void); |
667 | void ecryptfs_destroy_kthread(void); | 703 | void ecryptfs_destroy_kthread(void); |
668 | int ecryptfs_privileged_open(struct file **lower_file, | 704 | int ecryptfs_privileged_open(struct file **lower_file, |
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c index 5aceff202dc0..7d52806c2119 100644 --- a/fs/ecryptfs/keystore.c +++ b/fs/ecryptfs/keystore.c | |||
@@ -1168,7 +1168,7 @@ decrypt_pki_encrypted_session_key(struct ecryptfs_auth_tok *auth_tok, | |||
1168 | rc = ecryptfs_send_message(payload, payload_len, &msg_ctx); | 1168 | rc = ecryptfs_send_message(payload, payload_len, &msg_ctx); |
1169 | if (rc) { | 1169 | if (rc) { |
1170 | ecryptfs_printk(KERN_ERR, "Error sending message to " | 1170 | ecryptfs_printk(KERN_ERR, "Error sending message to " |
1171 | "ecryptfsd\n"); | 1171 | "ecryptfsd: %d\n", rc); |
1172 | goto out; | 1172 | goto out; |
1173 | } | 1173 | } |
1174 | rc = ecryptfs_wait_for_response(msg_ctx, &msg); | 1174 | rc = ecryptfs_wait_for_response(msg_ctx, &msg); |
@@ -1988,7 +1988,7 @@ pki_encrypt_session_key(struct key *auth_tok_key, | |||
1988 | rc = ecryptfs_send_message(payload, payload_len, &msg_ctx); | 1988 | rc = ecryptfs_send_message(payload, payload_len, &msg_ctx); |
1989 | if (rc) { | 1989 | if (rc) { |
1990 | ecryptfs_printk(KERN_ERR, "Error sending message to " | 1990 | ecryptfs_printk(KERN_ERR, "Error sending message to " |
1991 | "ecryptfsd\n"); | 1991 | "ecryptfsd: %d\n", rc); |
1992 | goto out; | 1992 | goto out; |
1993 | } | 1993 | } |
1994 | rc = ecryptfs_wait_for_response(msg_ctx, &msg); | 1994 | rc = ecryptfs_wait_for_response(msg_ctx, &msg); |
diff --git a/include/linux/ecryptfs.h b/include/linux/ecryptfs.h index 2224a8c0cb64..8d5ab998a222 100644 --- a/include/linux/ecryptfs.h +++ b/include/linux/ecryptfs.h | |||
@@ -6,9 +6,8 @@ | |||
6 | #define ECRYPTFS_VERSION_MINOR 0x04 | 6 | #define ECRYPTFS_VERSION_MINOR 0x04 |
7 | #define ECRYPTFS_SUPPORTED_FILE_VERSION 0x03 | 7 | #define ECRYPTFS_SUPPORTED_FILE_VERSION 0x03 |
8 | /* These flags indicate which features are supported by the kernel | 8 | /* These flags indicate which features are supported by the kernel |
9 | * module; userspace tools such as the mount helper read | 9 | * module; userspace tools such as the mount helper read the feature |
10 | * ECRYPTFS_VERSIONING_MASK from a sysfs handle in order to determine | 10 | * bits from a sysfs handle in order to determine how to behave. */ |
11 | * how to behave. */ | ||
12 | #define ECRYPTFS_VERSIONING_PASSPHRASE 0x00000001 | 11 | #define ECRYPTFS_VERSIONING_PASSPHRASE 0x00000001 |
13 | #define ECRYPTFS_VERSIONING_PUBKEY 0x00000002 | 12 | #define ECRYPTFS_VERSIONING_PUBKEY 0x00000002 |
14 | #define ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH 0x00000004 | 13 | #define ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH 0x00000004 |
@@ -19,13 +18,6 @@ | |||
19 | #define ECRYPTFS_VERSIONING_HMAC 0x00000080 | 18 | #define ECRYPTFS_VERSIONING_HMAC 0x00000080 |
20 | #define ECRYPTFS_VERSIONING_FILENAME_ENCRYPTION 0x00000100 | 19 | #define ECRYPTFS_VERSIONING_FILENAME_ENCRYPTION 0x00000100 |
21 | #define ECRYPTFS_VERSIONING_GCM 0x00000200 | 20 | #define ECRYPTFS_VERSIONING_GCM 0x00000200 |
22 | #define ECRYPTFS_VERSIONING_MASK (ECRYPTFS_VERSIONING_PASSPHRASE \ | ||
23 | | ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH \ | ||
24 | | ECRYPTFS_VERSIONING_PUBKEY \ | ||
25 | | ECRYPTFS_VERSIONING_XATTR \ | ||
26 | | ECRYPTFS_VERSIONING_MULTKEY \ | ||
27 | | ECRYPTFS_VERSIONING_DEVMISC \ | ||
28 | | ECRYPTFS_VERSIONING_FILENAME_ENCRYPTION) | ||
29 | #define ECRYPTFS_MAX_PASSWORD_LENGTH 64 | 21 | #define ECRYPTFS_MAX_PASSWORD_LENGTH 64 |
30 | #define ECRYPTFS_MAX_PASSPHRASE_BYTES ECRYPTFS_MAX_PASSWORD_LENGTH | 22 | #define ECRYPTFS_MAX_PASSPHRASE_BYTES ECRYPTFS_MAX_PASSWORD_LENGTH |
31 | #define ECRYPTFS_SALT_SIZE 8 | 23 | #define ECRYPTFS_SALT_SIZE 8 |