aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/ecryptfs_kernel.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ecryptfs/ecryptfs_kernel.h')
-rw-r--r--fs/ecryptfs/ecryptfs_kernel.h79
1 files changed, 61 insertions, 18 deletions
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h
index 342e8d37b421..72e117706a68 100644
--- a/fs/ecryptfs/ecryptfs_kernel.h
+++ b/fs/ecryptfs/ecryptfs_kernel.h
@@ -4,7 +4,7 @@
4 * 4 *
5 * Copyright (C) 1997-2003 Erez Zadok 5 * Copyright (C) 1997-2003 Erez Zadok
6 * Copyright (C) 2001-2003 Stony Brook University 6 * Copyright (C) 2001-2003 Stony Brook University
7 * Copyright (C) 2004-2007 International Business Machines Corp. 7 * Copyright (C) 2004-2008 International Business Machines Corp.
8 * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com> 8 * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com>
9 * Trevor S. Highland <trevor.highland@gmail.com> 9 * Trevor S. Highland <trevor.highland@gmail.com>
10 * Tyler Hicks <tyhicks@ou.edu> 10 * Tyler Hicks <tyhicks@ou.edu>
@@ -49,11 +49,13 @@
49#define ECRYPTFS_VERSIONING_POLICY 0x00000008 49#define ECRYPTFS_VERSIONING_POLICY 0x00000008
50#define ECRYPTFS_VERSIONING_XATTR 0x00000010 50#define ECRYPTFS_VERSIONING_XATTR 0x00000010
51#define ECRYPTFS_VERSIONING_MULTKEY 0x00000020 51#define ECRYPTFS_VERSIONING_MULTKEY 0x00000020
52#define ECRYPTFS_VERSIONING_DEVMISC 0x00000040
52#define ECRYPTFS_VERSIONING_MASK (ECRYPTFS_VERSIONING_PASSPHRASE \ 53#define ECRYPTFS_VERSIONING_MASK (ECRYPTFS_VERSIONING_PASSPHRASE \
53 | ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH \ 54 | ECRYPTFS_VERSIONING_PLAINTEXT_PASSTHROUGH \
54 | ECRYPTFS_VERSIONING_PUBKEY \ 55 | ECRYPTFS_VERSIONING_PUBKEY \
55 | ECRYPTFS_VERSIONING_XATTR \ 56 | ECRYPTFS_VERSIONING_XATTR \
56 | ECRYPTFS_VERSIONING_MULTKEY) 57 | ECRYPTFS_VERSIONING_MULTKEY \
58 | ECRYPTFS_VERSIONING_DEVMISC)
57#define ECRYPTFS_MAX_PASSWORD_LENGTH 64 59#define ECRYPTFS_MAX_PASSWORD_LENGTH 64
58#define ECRYPTFS_MAX_PASSPHRASE_BYTES ECRYPTFS_MAX_PASSWORD_LENGTH 60#define ECRYPTFS_MAX_PASSPHRASE_BYTES ECRYPTFS_MAX_PASSWORD_LENGTH
59#define ECRYPTFS_SALT_SIZE 8 61#define ECRYPTFS_SALT_SIZE 8
@@ -73,17 +75,14 @@
73#define ECRYPTFS_DEFAULT_MSG_CTX_ELEMS 32 75#define ECRYPTFS_DEFAULT_MSG_CTX_ELEMS 32
74#define ECRYPTFS_DEFAULT_SEND_TIMEOUT HZ 76#define ECRYPTFS_DEFAULT_SEND_TIMEOUT HZ
75#define ECRYPTFS_MAX_MSG_CTX_TTL (HZ*3) 77#define ECRYPTFS_MAX_MSG_CTX_TTL (HZ*3)
76#define ECRYPTFS_NLMSG_HELO 100
77#define ECRYPTFS_NLMSG_QUIT 101
78#define ECRYPTFS_NLMSG_REQUEST 102
79#define ECRYPTFS_NLMSG_RESPONSE 103
80#define ECRYPTFS_MAX_PKI_NAME_BYTES 16 78#define ECRYPTFS_MAX_PKI_NAME_BYTES 16
81#define ECRYPTFS_DEFAULT_NUM_USERS 4 79#define ECRYPTFS_DEFAULT_NUM_USERS 4
82#define ECRYPTFS_MAX_NUM_USERS 32768 80#define ECRYPTFS_MAX_NUM_USERS 32768
83#define ECRYPTFS_TRANSPORT_NETLINK 0 81#define ECRYPTFS_TRANSPORT_NETLINK 0
84#define ECRYPTFS_TRANSPORT_CONNECTOR 1 82#define ECRYPTFS_TRANSPORT_CONNECTOR 1
85#define ECRYPTFS_TRANSPORT_RELAYFS 2 83#define ECRYPTFS_TRANSPORT_RELAYFS 2
86#define ECRYPTFS_DEFAULT_TRANSPORT ECRYPTFS_TRANSPORT_NETLINK 84#define ECRYPTFS_TRANSPORT_MISCDEV 3
85#define ECRYPTFS_DEFAULT_TRANSPORT ECRYPTFS_TRANSPORT_MISCDEV
87#define ECRYPTFS_XATTR_NAME "user.ecryptfs" 86#define ECRYPTFS_XATTR_NAME "user.ecryptfs"
88 87
89#define RFC2440_CIPHER_DES3_EDE 0x02 88#define RFC2440_CIPHER_DES3_EDE 0x02
@@ -366,32 +365,62 @@ struct ecryptfs_auth_tok_list_item {
366}; 365};
367 366
368struct ecryptfs_message { 367struct ecryptfs_message {
368 /* Can never be greater than ecryptfs_message_buf_len */
369 /* Used to find the parent msg_ctx */
370 /* Inherits from msg_ctx->index */
369 u32 index; 371 u32 index;
370 u32 data_len; 372 u32 data_len;
371 u8 data[]; 373 u8 data[];
372}; 374};
373 375
374struct ecryptfs_msg_ctx { 376struct ecryptfs_msg_ctx {
375#define ECRYPTFS_MSG_CTX_STATE_FREE 0x0001 377#define ECRYPTFS_MSG_CTX_STATE_FREE 0x01
376#define ECRYPTFS_MSG_CTX_STATE_PENDING 0x0002 378#define ECRYPTFS_MSG_CTX_STATE_PENDING 0x02
377#define ECRYPTFS_MSG_CTX_STATE_DONE 0x0003 379#define ECRYPTFS_MSG_CTX_STATE_DONE 0x03
378 u32 state; 380#define ECRYPTFS_MSG_CTX_STATE_NO_REPLY 0x04
379 unsigned int index; 381 u8 state;
380 unsigned int counter; 382#define ECRYPTFS_MSG_HELO 100
383#define ECRYPTFS_MSG_QUIT 101
384#define ECRYPTFS_MSG_REQUEST 102
385#define ECRYPTFS_MSG_RESPONSE 103
386 u8 type;
387 u32 index;
388 /* Counter converts to a sequence number. Each message sent
389 * out for which we expect a response has an associated
390 * sequence number. The response must have the same sequence
391 * number as the counter for the msg_stc for the message to be
392 * valid. */
393 u32 counter;
394 size_t msg_size;
381 struct ecryptfs_message *msg; 395 struct ecryptfs_message *msg;
382 struct task_struct *task; 396 struct task_struct *task;
383 struct list_head node; 397 struct list_head node;
398 struct list_head daemon_out_list;
384 struct mutex mux; 399 struct mutex mux;
385}; 400};
386 401
387extern unsigned int ecryptfs_transport; 402extern unsigned int ecryptfs_transport;
388 403
389struct ecryptfs_daemon_id { 404struct ecryptfs_daemon;
405
406struct ecryptfs_daemon {
407#define ECRYPTFS_DAEMON_IN_READ 0x00000001
408#define ECRYPTFS_DAEMON_IN_POLL 0x00000002
409#define ECRYPTFS_DAEMON_ZOMBIE 0x00000004
410#define ECRYPTFS_DAEMON_MISCDEV_OPEN 0x00000008
411 u32 flags;
412 u32 num_queued_msg_ctx;
390 pid_t pid; 413 pid_t pid;
391 uid_t uid; 414 uid_t euid;
392 struct hlist_node id_chain; 415 struct task_struct *task;
416 struct mutex mux;
417 struct list_head msg_ctx_out_queue;
418 wait_queue_head_t wait;
419 struct hlist_node euid_chain;
393}; 420};
394 421
422extern struct mutex ecryptfs_daemon_hash_mux;
423
395static inline struct ecryptfs_file_info * 424static inline struct ecryptfs_file_info *
396ecryptfs_file_to_private(struct file *file) 425ecryptfs_file_to_private(struct file *file)
397{ 426{
@@ -593,13 +622,13 @@ int ecryptfs_init_messaging(unsigned int transport);
593void ecryptfs_release_messaging(unsigned int transport); 622void ecryptfs_release_messaging(unsigned int transport);
594 623
595int ecryptfs_send_netlink(char *data, int data_len, 624int ecryptfs_send_netlink(char *data, int data_len,
596 struct ecryptfs_msg_ctx *msg_ctx, u16 msg_type, 625 struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type,
597 u16 msg_flags, pid_t daemon_pid); 626 u16 msg_flags, pid_t daemon_pid);
598int ecryptfs_init_netlink(void); 627int ecryptfs_init_netlink(void);
599void ecryptfs_release_netlink(void); 628void ecryptfs_release_netlink(void);
600 629
601int ecryptfs_send_connector(char *data, int data_len, 630int ecryptfs_send_connector(char *data, int data_len,
602 struct ecryptfs_msg_ctx *msg_ctx, u16 msg_type, 631 struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type,
603 u16 msg_flags, pid_t daemon_pid); 632 u16 msg_flags, pid_t daemon_pid);
604int ecryptfs_init_connector(void); 633int ecryptfs_init_connector(void);
605void ecryptfs_release_connector(void); 634void ecryptfs_release_connector(void);
@@ -642,5 +671,19 @@ int ecryptfs_read_lower_page_segment(struct page *page_for_ecryptfs,
642 size_t offset_in_page, size_t size, 671 size_t offset_in_page, size_t size,
643 struct inode *ecryptfs_inode); 672 struct inode *ecryptfs_inode);
644struct page *ecryptfs_get_locked_page(struct file *file, loff_t index); 673struct page *ecryptfs_get_locked_page(struct file *file, loff_t index);
674int ecryptfs_exorcise_daemon(struct ecryptfs_daemon *daemon);
675int ecryptfs_find_daemon_by_euid(struct ecryptfs_daemon **daemon, uid_t euid);
676int ecryptfs_parse_packet_length(unsigned char *data, size_t *size,
677 size_t *length_size);
678int ecryptfs_write_packet_length(char *dest, size_t size,
679 size_t *packet_size_length);
680int ecryptfs_init_ecryptfs_miscdev(void);
681void ecryptfs_destroy_ecryptfs_miscdev(void);
682int ecryptfs_send_miscdev(char *data, size_t data_size,
683 struct ecryptfs_msg_ctx *msg_ctx, u8 msg_type,
684 u16 msg_flags, struct ecryptfs_daemon *daemon);
685void ecryptfs_msg_ctx_alloc_to_free(struct ecryptfs_msg_ctx *msg_ctx);
686int
687ecryptfs_spawn_daemon(struct ecryptfs_daemon **daemon, uid_t euid, pid_t pid);
645 688
646#endif /* #ifndef ECRYPTFS_KERNEL_H */ 689#endif /* #ifndef ECRYPTFS_KERNEL_H */