| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 1 | /** | 
|  | 2 | * eCryptfs: Linux filesystem encryption layer | 
|  | 3 | * | 
|  | 4 | * Copyright (C) 1997-2003 Erez Zadok | 
|  | 5 | * Copyright (C) 2001-2003 Stony Brook University | 
| Michael Halcrow | dd2a3b7 | 2007-02-12 00:53:46 -0800 | [diff] [blame] | 6 | * Copyright (C) 2004-2007 International Business Machines Corp. | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 7 | *   Author(s): Michael A. Halcrow <mahalcro@us.ibm.com> | 
|  | 8 | *              Michael C. Thompson <mcthomps@us.ibm.com> | 
| Michael Halcrow | dddfa46 | 2007-02-12 00:53:44 -0800 | [diff] [blame] | 9 | *              Tyler Hicks <tyhicks@ou.edu> | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 10 | * | 
|  | 11 | * This program is free software; you can redistribute it and/or | 
|  | 12 | * modify it under the terms of the GNU General Public License as | 
|  | 13 | * published by the Free Software Foundation; either version 2 of the | 
|  | 14 | * License, or (at your option) any later version. | 
|  | 15 | * | 
|  | 16 | * This program is distributed in the hope that it will be useful, but | 
|  | 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|  | 19 | * General Public License for more details. | 
|  | 20 | * | 
|  | 21 | * You should have received a copy of the GNU General Public License | 
|  | 22 | * along with this program; if not, write to the Free Software | 
|  | 23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 
|  | 24 | * 02111-1307, USA. | 
|  | 25 | */ | 
|  | 26 |  | 
|  | 27 | #include <linux/dcache.h> | 
|  | 28 | #include <linux/file.h> | 
|  | 29 | #include <linux/module.h> | 
|  | 30 | #include <linux/namei.h> | 
|  | 31 | #include <linux/skbuff.h> | 
|  | 32 | #include <linux/crypto.h> | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 33 | #include <linux/mount.h> | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 34 | #include <linux/pagemap.h> | 
|  | 35 | #include <linux/key.h> | 
|  | 36 | #include <linux/parser.h> | 
| Josef "Jeff" Sipek | 0cc72dc | 2006-12-08 02:36:31 -0800 | [diff] [blame] | 37 | #include <linux/fs_stack.h> | 
| Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 38 | #include <linux/slab.h> | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 39 | #include "ecryptfs_kernel.h" | 
|  | 40 |  | 
|  | 41 | /** | 
|  | 42 | * Module parameter that defines the ecryptfs_verbosity level. | 
|  | 43 | */ | 
|  | 44 | int ecryptfs_verbosity = 0; | 
|  | 45 |  | 
|  | 46 | module_param(ecryptfs_verbosity, int, 0); | 
|  | 47 | MODULE_PARM_DESC(ecryptfs_verbosity, | 
|  | 48 | "Initial verbosity level (0 or 1; defaults to " | 
|  | 49 | "0, which is Quiet)"); | 
|  | 50 |  | 
| Michael Halcrow | dddfa46 | 2007-02-12 00:53:44 -0800 | [diff] [blame] | 51 | /** | 
| Tyler Hicks | 624ae52 | 2008-10-15 22:02:51 -0700 | [diff] [blame] | 52 | * Module parameter that defines the number of message buffer elements | 
| Michael Halcrow | dddfa46 | 2007-02-12 00:53:44 -0800 | [diff] [blame] | 53 | */ | 
|  | 54 | unsigned int ecryptfs_message_buf_len = ECRYPTFS_DEFAULT_MSG_CTX_ELEMS; | 
|  | 55 |  | 
|  | 56 | module_param(ecryptfs_message_buf_len, uint, 0); | 
|  | 57 | MODULE_PARM_DESC(ecryptfs_message_buf_len, | 
|  | 58 | "Number of message buffer elements"); | 
|  | 59 |  | 
|  | 60 | /** | 
|  | 61 | * Module parameter that defines the maximum guaranteed amount of time to wait | 
| Tyler Hicks | 624ae52 | 2008-10-15 22:02:51 -0700 | [diff] [blame] | 62 | * for a response from ecryptfsd.  The actual sleep time will be, more than | 
| Michael Halcrow | dddfa46 | 2007-02-12 00:53:44 -0800 | [diff] [blame] | 63 | * likely, a small amount greater than this specified value, but only less if | 
| Tyler Hicks | 624ae52 | 2008-10-15 22:02:51 -0700 | [diff] [blame] | 64 | * the message successfully arrives. | 
| Michael Halcrow | dddfa46 | 2007-02-12 00:53:44 -0800 | [diff] [blame] | 65 | */ | 
|  | 66 | signed long ecryptfs_message_wait_timeout = ECRYPTFS_MAX_MSG_CTX_TTL / HZ; | 
|  | 67 |  | 
|  | 68 | module_param(ecryptfs_message_wait_timeout, long, 0); | 
|  | 69 | MODULE_PARM_DESC(ecryptfs_message_wait_timeout, | 
|  | 70 | "Maximum number of seconds that an operation will " | 
|  | 71 | "sleep while waiting for a message response from " | 
|  | 72 | "userspace"); | 
|  | 73 |  | 
|  | 74 | /** | 
|  | 75 | * Module parameter that is an estimate of the maximum number of users | 
|  | 76 | * that will be concurrently using eCryptfs. Set this to the right | 
|  | 77 | * value to balance performance and memory use. | 
|  | 78 | */ | 
|  | 79 | unsigned int ecryptfs_number_of_users = ECRYPTFS_DEFAULT_NUM_USERS; | 
|  | 80 |  | 
|  | 81 | module_param(ecryptfs_number_of_users, uint, 0); | 
|  | 82 | MODULE_PARM_DESC(ecryptfs_number_of_users, "An estimate of the number of " | 
|  | 83 | "concurrent users of eCryptfs"); | 
|  | 84 |  | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 85 | void __ecryptfs_printk(const char *fmt, ...) | 
|  | 86 | { | 
|  | 87 | va_list args; | 
|  | 88 | va_start(args, fmt); | 
|  | 89 | if (fmt[1] == '7') { /* KERN_DEBUG */ | 
|  | 90 | if (ecryptfs_verbosity >= 1) | 
|  | 91 | vprintk(fmt, args); | 
|  | 92 | } else | 
|  | 93 | vprintk(fmt, args); | 
|  | 94 | va_end(args); | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 | /** | 
| Michael Halcrow | 4981e08 | 2007-10-16 01:28:09 -0700 | [diff] [blame] | 98 | * ecryptfs_init_persistent_file | 
|  | 99 | * @ecryptfs_dentry: Fully initialized eCryptfs dentry object, with | 
|  | 100 | *                   the lower dentry and the lower mount set | 
|  | 101 | * | 
|  | 102 | * eCryptfs only ever keeps a single open file for every lower | 
|  | 103 | * inode. All I/O operations to the lower inode occur through that | 
|  | 104 | * file. When the first eCryptfs dentry that interposes with the first | 
|  | 105 | * lower dentry for that inode is created, this function creates the | 
|  | 106 | * persistent file struct and associates it with the eCryptfs | 
|  | 107 | * inode. When the eCryptfs inode is destroyed, the file is closed. | 
|  | 108 | * | 
|  | 109 | * The persistent file will be opened with read/write permissions, if | 
|  | 110 | * possible. Otherwise, it is opened read-only. | 
|  | 111 | * | 
|  | 112 | * This function does nothing if a lower persistent file is already | 
|  | 113 | * associated with the eCryptfs inode. | 
|  | 114 | * | 
|  | 115 | * Returns zero on success; non-zero otherwise | 
|  | 116 | */ | 
| Michael Halcrow | 72b55ff | 2008-07-23 21:30:07 -0700 | [diff] [blame] | 117 | int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry) | 
| Michael Halcrow | 4981e08 | 2007-10-16 01:28:09 -0700 | [diff] [blame] | 118 | { | 
| David Howells | 745ca24 | 2008-11-14 10:39:22 +1100 | [diff] [blame] | 119 | const struct cred *cred = current_cred(); | 
| Michael Halcrow | 4981e08 | 2007-10-16 01:28:09 -0700 | [diff] [blame] | 120 | struct ecryptfs_inode_info *inode_info = | 
|  | 121 | ecryptfs_inode_to_private(ecryptfs_dentry->d_inode); | 
|  | 122 | int rc = 0; | 
|  | 123 |  | 
|  | 124 | mutex_lock(&inode_info->lower_file_mutex); | 
|  | 125 | if (!inode_info->lower_file) { | 
|  | 126 | struct dentry *lower_dentry; | 
|  | 127 | struct vfsmount *lower_mnt = | 
|  | 128 | ecryptfs_dentry_to_lower_mnt(ecryptfs_dentry); | 
|  | 129 |  | 
|  | 130 | lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry); | 
| Michael Halcrow | 746f1e5 | 2008-07-23 21:30:02 -0700 | [diff] [blame] | 131 | rc = ecryptfs_privileged_open(&inode_info->lower_file, | 
| David Howells | 745ca24 | 2008-11-14 10:39:22 +1100 | [diff] [blame] | 132 | lower_dentry, lower_mnt, cred); | 
| Tyler Hicks | ac22ba2 | 2009-08-12 01:06:54 -0500 | [diff] [blame] | 133 | if (rc) { | 
| Michael Halcrow | 4981e08 | 2007-10-16 01:28:09 -0700 | [diff] [blame] | 134 | printk(KERN_ERR "Error opening lower persistent file " | 
| Michael Halcrow | 746f1e5 | 2008-07-23 21:30:02 -0700 | [diff] [blame] | 135 | "for lower_dentry [0x%p] and lower_mnt [0x%p]; " | 
|  | 136 | "rc = [%d]\n", lower_dentry, lower_mnt, rc); | 
| Michael Halcrow | 4981e08 | 2007-10-16 01:28:09 -0700 | [diff] [blame] | 137 | inode_info->lower_file = NULL; | 
| Al Viro | b65a9cf | 2009-12-16 06:27:40 -0500 | [diff] [blame] | 138 | } | 
| Michael Halcrow | 4981e08 | 2007-10-16 01:28:09 -0700 | [diff] [blame] | 139 | } | 
|  | 140 | mutex_unlock(&inode_info->lower_file_mutex); | 
|  | 141 | return rc; | 
|  | 142 | } | 
|  | 143 |  | 
|  | 144 | /** | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 145 | * ecryptfs_interpose | 
|  | 146 | * @lower_dentry: Existing dentry in the lower filesystem | 
|  | 147 | * @dentry: ecryptfs' dentry | 
|  | 148 | * @sb: ecryptfs's super_block | 
| Michael Halcrow | 72b55ff | 2008-07-23 21:30:07 -0700 | [diff] [blame] | 149 | * @flags: flags to govern behavior of interpose procedure | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 150 | * | 
|  | 151 | * Interposes upper and lower dentries. | 
|  | 152 | * | 
|  | 153 | * Returns zero on success; non-zero otherwise | 
|  | 154 | */ | 
|  | 155 | int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry, | 
| Michael Halcrow | 72b55ff | 2008-07-23 21:30:07 -0700 | [diff] [blame] | 156 | struct super_block *sb, u32 flags) | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 157 | { | 
|  | 158 | struct inode *lower_inode; | 
|  | 159 | struct inode *inode; | 
|  | 160 | int rc = 0; | 
|  | 161 |  | 
|  | 162 | lower_inode = lower_dentry->d_inode; | 
|  | 163 | if (lower_inode->i_sb != ecryptfs_superblock_to_lower(sb)) { | 
|  | 164 | rc = -EXDEV; | 
|  | 165 | goto out; | 
|  | 166 | } | 
|  | 167 | if (!igrab(lower_inode)) { | 
|  | 168 | rc = -ESTALE; | 
|  | 169 | goto out; | 
|  | 170 | } | 
|  | 171 | inode = iget5_locked(sb, (unsigned long)lower_inode, | 
|  | 172 | ecryptfs_inode_test, ecryptfs_inode_set, | 
|  | 173 | lower_inode); | 
|  | 174 | if (!inode) { | 
|  | 175 | rc = -EACCES; | 
|  | 176 | iput(lower_inode); | 
|  | 177 | goto out; | 
|  | 178 | } | 
|  | 179 | if (inode->i_state & I_NEW) | 
|  | 180 | unlock_new_inode(inode); | 
|  | 181 | else | 
|  | 182 | iput(lower_inode); | 
|  | 183 | if (S_ISLNK(lower_inode->i_mode)) | 
|  | 184 | inode->i_op = &ecryptfs_symlink_iops; | 
|  | 185 | else if (S_ISDIR(lower_inode->i_mode)) | 
|  | 186 | inode->i_op = &ecryptfs_dir_iops; | 
|  | 187 | if (S_ISDIR(lower_inode->i_mode)) | 
|  | 188 | inode->i_fop = &ecryptfs_dir_fops; | 
| Pekka Enberg | 26da820 | 2006-10-19 23:28:14 -0700 | [diff] [blame] | 189 | if (special_file(lower_inode->i_mode)) | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 190 | init_special_inode(inode, lower_inode->i_mode, | 
|  | 191 | lower_inode->i_rdev); | 
|  | 192 | dentry->d_op = &ecryptfs_dops; | 
| Erez Zadok | 9afa2fb | 2009-12-02 19:51:54 -0500 | [diff] [blame] | 193 | fsstack_copy_attr_all(inode, lower_inode); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 194 | /* This size will be overwritten for real files w/ headers and | 
|  | 195 | * other metadata */ | 
| Josef "Jeff" Sipek | 0cc72dc | 2006-12-08 02:36:31 -0800 | [diff] [blame] | 196 | fsstack_copy_inode_size(inode, lower_inode); | 
| Tyler Hicks | ae6e845 | 2009-03-12 00:19:46 -0500 | [diff] [blame] | 197 | if (flags & ECRYPTFS_INTERPOSE_FLAG_D_ADD) | 
|  | 198 | d_add(dentry, inode); | 
|  | 199 | else | 
|  | 200 | d_instantiate(dentry, inode); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 201 | out: | 
|  | 202 | return rc; | 
|  | 203 | } | 
|  | 204 |  | 
| Eric Sandeen | 2830bfd | 2008-02-06 01:38:34 -0800 | [diff] [blame] | 205 | enum { ecryptfs_opt_sig, ecryptfs_opt_ecryptfs_sig, | 
|  | 206 | ecryptfs_opt_cipher, ecryptfs_opt_ecryptfs_cipher, | 
|  | 207 | ecryptfs_opt_ecryptfs_key_bytes, | 
| Michael Halcrow | 1739895 | 2007-02-12 00:53:45 -0800 | [diff] [blame] | 208 | ecryptfs_opt_passthrough, ecryptfs_opt_xattr_metadata, | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 209 | ecryptfs_opt_encrypted_view, ecryptfs_opt_fnek_sig, | 
|  | 210 | ecryptfs_opt_fn_cipher, ecryptfs_opt_fn_cipher_key_bytes, | 
| Roberto Sassu | f16feb5 | 2010-10-06 18:31:32 +0200 | [diff] [blame] | 211 | ecryptfs_opt_unlink_sigs, ecryptfs_opt_mount_auth_tok_only, | 
|  | 212 | ecryptfs_opt_err }; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 213 |  | 
| Steven Whitehouse | a447c09 | 2008-10-13 10:46:57 +0100 | [diff] [blame] | 214 | static const match_table_t tokens = { | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 215 | {ecryptfs_opt_sig, "sig=%s"}, | 
|  | 216 | {ecryptfs_opt_ecryptfs_sig, "ecryptfs_sig=%s"}, | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 217 | {ecryptfs_opt_cipher, "cipher=%s"}, | 
|  | 218 | {ecryptfs_opt_ecryptfs_cipher, "ecryptfs_cipher=%s"}, | 
|  | 219 | {ecryptfs_opt_ecryptfs_key_bytes, "ecryptfs_key_bytes=%u"}, | 
|  | 220 | {ecryptfs_opt_passthrough, "ecryptfs_passthrough"}, | 
| Michael Halcrow | 1739895 | 2007-02-12 00:53:45 -0800 | [diff] [blame] | 221 | {ecryptfs_opt_xattr_metadata, "ecryptfs_xattr_metadata"}, | 
|  | 222 | {ecryptfs_opt_encrypted_view, "ecryptfs_encrypted_view"}, | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 223 | {ecryptfs_opt_fnek_sig, "ecryptfs_fnek_sig=%s"}, | 
|  | 224 | {ecryptfs_opt_fn_cipher, "ecryptfs_fn_cipher=%s"}, | 
|  | 225 | {ecryptfs_opt_fn_cipher_key_bytes, "ecryptfs_fn_key_bytes=%u"}, | 
| Tyler Hicks | e77cc8d | 2009-04-22 04:08:46 -0500 | [diff] [blame] | 226 | {ecryptfs_opt_unlink_sigs, "ecryptfs_unlink_sigs"}, | 
| Roberto Sassu | f16feb5 | 2010-10-06 18:31:32 +0200 | [diff] [blame] | 227 | {ecryptfs_opt_mount_auth_tok_only, "ecryptfs_mount_auth_tok_only"}, | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 228 | {ecryptfs_opt_err, NULL} | 
|  | 229 | }; | 
|  | 230 |  | 
| Michael Halcrow | f4aad16 | 2007-10-16 01:27:53 -0700 | [diff] [blame] | 231 | static int ecryptfs_init_global_auth_toks( | 
|  | 232 | struct ecryptfs_mount_crypt_stat *mount_crypt_stat) | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 233 | { | 
| Michael Halcrow | f4aad16 | 2007-10-16 01:27:53 -0700 | [diff] [blame] | 234 | struct ecryptfs_global_auth_tok *global_auth_tok; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 235 | int rc = 0; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 236 |  | 
| Michael Halcrow | f4aad16 | 2007-10-16 01:27:53 -0700 | [diff] [blame] | 237 | list_for_each_entry(global_auth_tok, | 
|  | 238 | &mount_crypt_stat->global_auth_tok_list, | 
|  | 239 | mount_crypt_stat_list) { | 
| Michael Halcrow | 5dda699 | 2007-10-16 01:28:06 -0700 | [diff] [blame] | 240 | rc = ecryptfs_keyring_auth_tok_for_sig( | 
|  | 241 | &global_auth_tok->global_auth_tok_key, | 
|  | 242 | &global_auth_tok->global_auth_tok, | 
|  | 243 | global_auth_tok->sig); | 
|  | 244 | if (rc) { | 
| Michael Halcrow | f4aad16 | 2007-10-16 01:27:53 -0700 | [diff] [blame] | 245 | printk(KERN_ERR "Could not find valid key in user " | 
|  | 246 | "session keyring for sig specified in mount " | 
|  | 247 | "option: [%s]\n", global_auth_tok->sig); | 
|  | 248 | global_auth_tok->flags |= ECRYPTFS_AUTH_TOK_INVALID; | 
| Eric Sandeen | 982363c | 2008-07-23 21:30:04 -0700 | [diff] [blame] | 249 | goto out; | 
| Michael Halcrow | f4aad16 | 2007-10-16 01:27:53 -0700 | [diff] [blame] | 250 | } else | 
|  | 251 | global_auth_tok->flags &= ~ECRYPTFS_AUTH_TOK_INVALID; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 252 | } | 
| Eric Sandeen | 982363c | 2008-07-23 21:30:04 -0700 | [diff] [blame] | 253 | out: | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 254 | return rc; | 
|  | 255 | } | 
|  | 256 |  | 
| Michael Halcrow | f4aad16 | 2007-10-16 01:27:53 -0700 | [diff] [blame] | 257 | static void ecryptfs_init_mount_crypt_stat( | 
|  | 258 | struct ecryptfs_mount_crypt_stat *mount_crypt_stat) | 
|  | 259 | { | 
|  | 260 | memset((void *)mount_crypt_stat, 0, | 
|  | 261 | sizeof(struct ecryptfs_mount_crypt_stat)); | 
|  | 262 | INIT_LIST_HEAD(&mount_crypt_stat->global_auth_tok_list); | 
|  | 263 | mutex_init(&mount_crypt_stat->global_auth_tok_list_mutex); | 
|  | 264 | mount_crypt_stat->flags |= ECRYPTFS_MOUNT_CRYPT_STAT_INITIALIZED; | 
|  | 265 | } | 
|  | 266 |  | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 267 | /** | 
|  | 268 | * ecryptfs_parse_options | 
|  | 269 | * @sb: The ecryptfs super block | 
|  | 270 | * @options: The options pased to the kernel | 
|  | 271 | * | 
|  | 272 | * Parse mount options: | 
|  | 273 | * debug=N 	   - ecryptfs_verbosity level for debug output | 
|  | 274 | * sig=XXX	   - description(signature) of the key to use | 
|  | 275 | * | 
|  | 276 | * Returns the dentry object of the lower-level (lower/interposed) | 
|  | 277 | * directory; We want to mount our stackable file system on top of | 
|  | 278 | * that lower directory. | 
|  | 279 | * | 
|  | 280 | * The signature of the key to use must be the description of a key | 
|  | 281 | * already in the keyring. Mounting will fail if the key can not be | 
|  | 282 | * found. | 
|  | 283 | * | 
|  | 284 | * Returns zero on success; non-zero on error | 
|  | 285 | */ | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 286 | static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options) | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 287 | { | 
|  | 288 | char *p; | 
|  | 289 | int rc = 0; | 
|  | 290 | int sig_set = 0; | 
|  | 291 | int cipher_name_set = 0; | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 292 | int fn_cipher_name_set = 0; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 293 | int cipher_key_bytes; | 
|  | 294 | int cipher_key_bytes_set = 0; | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 295 | int fn_cipher_key_bytes; | 
|  | 296 | int fn_cipher_key_bytes_set = 0; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 297 | struct ecryptfs_mount_crypt_stat *mount_crypt_stat = | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 298 | &sbi->mount_crypt_stat; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 299 | substring_t args[MAX_OPT_ARGS]; | 
|  | 300 | int token; | 
|  | 301 | char *sig_src; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 302 | char *cipher_name_dst; | 
|  | 303 | char *cipher_name_src; | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 304 | char *fn_cipher_name_dst; | 
|  | 305 | char *fn_cipher_name_src; | 
|  | 306 | char *fnek_dst; | 
|  | 307 | char *fnek_src; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 308 | char *cipher_key_bytes_src; | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 309 | char *fn_cipher_key_bytes_src; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 310 |  | 
|  | 311 | if (!options) { | 
|  | 312 | rc = -EINVAL; | 
|  | 313 | goto out; | 
|  | 314 | } | 
| Michael Halcrow | 956159c | 2007-10-16 01:27:55 -0700 | [diff] [blame] | 315 | ecryptfs_init_mount_crypt_stat(mount_crypt_stat); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 316 | while ((p = strsep(&options, ",")) != NULL) { | 
|  | 317 | if (!*p) | 
|  | 318 | continue; | 
|  | 319 | token = match_token(p, tokens, args); | 
|  | 320 | switch (token) { | 
|  | 321 | case ecryptfs_opt_sig: | 
|  | 322 | case ecryptfs_opt_ecryptfs_sig: | 
|  | 323 | sig_src = args[0].from; | 
| Michael Halcrow | f4aad16 | 2007-10-16 01:27:53 -0700 | [diff] [blame] | 324 | rc = ecryptfs_add_global_auth_tok(mount_crypt_stat, | 
| Tyler Hicks | 84814d6 | 2009-03-13 13:51:59 -0700 | [diff] [blame] | 325 | sig_src, 0); | 
| Michael Halcrow | f4aad16 | 2007-10-16 01:27:53 -0700 | [diff] [blame] | 326 | if (rc) { | 
|  | 327 | printk(KERN_ERR "Error attempting to register " | 
|  | 328 | "global sig; rc = [%d]\n", rc); | 
|  | 329 | goto out; | 
|  | 330 | } | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 331 | sig_set = 1; | 
|  | 332 | break; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 333 | case ecryptfs_opt_cipher: | 
|  | 334 | case ecryptfs_opt_ecryptfs_cipher: | 
|  | 335 | cipher_name_src = args[0].from; | 
|  | 336 | cipher_name_dst = | 
|  | 337 | mount_crypt_stat-> | 
|  | 338 | global_default_cipher_name; | 
|  | 339 | strncpy(cipher_name_dst, cipher_name_src, | 
|  | 340 | ECRYPTFS_MAX_CIPHER_NAME_SIZE); | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 341 | cipher_name_dst[ECRYPTFS_MAX_CIPHER_NAME_SIZE] = '\0'; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 342 | cipher_name_set = 1; | 
|  | 343 | break; | 
|  | 344 | case ecryptfs_opt_ecryptfs_key_bytes: | 
|  | 345 | cipher_key_bytes_src = args[0].from; | 
|  | 346 | cipher_key_bytes = | 
|  | 347 | (int)simple_strtol(cipher_key_bytes_src, | 
|  | 348 | &cipher_key_bytes_src, 0); | 
|  | 349 | mount_crypt_stat->global_default_cipher_key_size = | 
|  | 350 | cipher_key_bytes; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 351 | cipher_key_bytes_set = 1; | 
|  | 352 | break; | 
|  | 353 | case ecryptfs_opt_passthrough: | 
|  | 354 | mount_crypt_stat->flags |= | 
|  | 355 | ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED; | 
|  | 356 | break; | 
| Michael Halcrow | 1739895 | 2007-02-12 00:53:45 -0800 | [diff] [blame] | 357 | case ecryptfs_opt_xattr_metadata: | 
|  | 358 | mount_crypt_stat->flags |= | 
|  | 359 | ECRYPTFS_XATTR_METADATA_ENABLED; | 
|  | 360 | break; | 
|  | 361 | case ecryptfs_opt_encrypted_view: | 
|  | 362 | mount_crypt_stat->flags |= | 
|  | 363 | ECRYPTFS_XATTR_METADATA_ENABLED; | 
|  | 364 | mount_crypt_stat->flags |= | 
|  | 365 | ECRYPTFS_ENCRYPTED_VIEW_ENABLED; | 
|  | 366 | break; | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 367 | case ecryptfs_opt_fnek_sig: | 
|  | 368 | fnek_src = args[0].from; | 
|  | 369 | fnek_dst = | 
|  | 370 | mount_crypt_stat->global_default_fnek_sig; | 
|  | 371 | strncpy(fnek_dst, fnek_src, ECRYPTFS_SIG_SIZE_HEX); | 
|  | 372 | mount_crypt_stat->global_default_fnek_sig[ | 
|  | 373 | ECRYPTFS_SIG_SIZE_HEX] = '\0'; | 
|  | 374 | rc = ecryptfs_add_global_auth_tok( | 
|  | 375 | mount_crypt_stat, | 
| Tyler Hicks | 84814d6 | 2009-03-13 13:51:59 -0700 | [diff] [blame] | 376 | mount_crypt_stat->global_default_fnek_sig, | 
|  | 377 | ECRYPTFS_AUTH_TOK_FNEK); | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 378 | if (rc) { | 
|  | 379 | printk(KERN_ERR "Error attempting to register " | 
|  | 380 | "global fnek sig [%s]; rc = [%d]\n", | 
|  | 381 | mount_crypt_stat->global_default_fnek_sig, | 
|  | 382 | rc); | 
|  | 383 | goto out; | 
|  | 384 | } | 
|  | 385 | mount_crypt_stat->flags |= | 
|  | 386 | (ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES | 
|  | 387 | | ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK); | 
|  | 388 | break; | 
|  | 389 | case ecryptfs_opt_fn_cipher: | 
|  | 390 | fn_cipher_name_src = args[0].from; | 
|  | 391 | fn_cipher_name_dst = | 
|  | 392 | mount_crypt_stat->global_default_fn_cipher_name; | 
|  | 393 | strncpy(fn_cipher_name_dst, fn_cipher_name_src, | 
|  | 394 | ECRYPTFS_MAX_CIPHER_NAME_SIZE); | 
|  | 395 | mount_crypt_stat->global_default_fn_cipher_name[ | 
|  | 396 | ECRYPTFS_MAX_CIPHER_NAME_SIZE] = '\0'; | 
|  | 397 | fn_cipher_name_set = 1; | 
|  | 398 | break; | 
|  | 399 | case ecryptfs_opt_fn_cipher_key_bytes: | 
|  | 400 | fn_cipher_key_bytes_src = args[0].from; | 
|  | 401 | fn_cipher_key_bytes = | 
|  | 402 | (int)simple_strtol(fn_cipher_key_bytes_src, | 
|  | 403 | &fn_cipher_key_bytes_src, 0); | 
|  | 404 | mount_crypt_stat->global_default_fn_cipher_key_bytes = | 
|  | 405 | fn_cipher_key_bytes; | 
|  | 406 | fn_cipher_key_bytes_set = 1; | 
|  | 407 | break; | 
| Tyler Hicks | e77cc8d | 2009-04-22 04:08:46 -0500 | [diff] [blame] | 408 | case ecryptfs_opt_unlink_sigs: | 
|  | 409 | mount_crypt_stat->flags |= ECRYPTFS_UNLINK_SIGS; | 
|  | 410 | break; | 
| Roberto Sassu | f16feb5 | 2010-10-06 18:31:32 +0200 | [diff] [blame] | 411 | case ecryptfs_opt_mount_auth_tok_only: | 
|  | 412 | mount_crypt_stat->flags |= | 
|  | 413 | ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY; | 
|  | 414 | break; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 415 | case ecryptfs_opt_err: | 
|  | 416 | default: | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 417 | printk(KERN_WARNING | 
|  | 418 | "%s: eCryptfs: unrecognized option [%s]\n", | 
|  | 419 | __func__, p); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 420 | } | 
|  | 421 | } | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 422 | if (!sig_set) { | 
|  | 423 | rc = -EINVAL; | 
| Michael Halcrow | 956159c | 2007-10-16 01:27:55 -0700 | [diff] [blame] | 424 | ecryptfs_printk(KERN_ERR, "You must supply at least one valid " | 
|  | 425 | "auth tok signature as a mount " | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 426 | "parameter; see the eCryptfs README\n"); | 
|  | 427 | goto out; | 
|  | 428 | } | 
|  | 429 | if (!cipher_name_set) { | 
| Miklos Szeredi | 8f23680 | 2008-07-23 21:30:05 -0700 | [diff] [blame] | 430 | int cipher_name_len = strlen(ECRYPTFS_DEFAULT_CIPHER); | 
|  | 431 |  | 
|  | 432 | BUG_ON(cipher_name_len >= ECRYPTFS_MAX_CIPHER_NAME_SIZE); | 
| Miklos Szeredi | 8f23680 | 2008-07-23 21:30:05 -0700 | [diff] [blame] | 433 | strcpy(mount_crypt_stat->global_default_cipher_name, | 
|  | 434 | ECRYPTFS_DEFAULT_CIPHER); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 435 | } | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 436 | if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) | 
|  | 437 | && !fn_cipher_name_set) | 
|  | 438 | strcpy(mount_crypt_stat->global_default_fn_cipher_name, | 
|  | 439 | mount_crypt_stat->global_default_cipher_name); | 
|  | 440 | if (!cipher_key_bytes_set) | 
| Michael Halcrow | e5d9cbd | 2006-10-30 22:07:16 -0800 | [diff] [blame] | 441 | mount_crypt_stat->global_default_cipher_key_size = 0; | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 442 | if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) | 
|  | 443 | && !fn_cipher_key_bytes_set) | 
|  | 444 | mount_crypt_stat->global_default_fn_cipher_key_bytes = | 
|  | 445 | mount_crypt_stat->global_default_cipher_key_size; | 
| Eric Sandeen | af440f5 | 2008-02-06 01:38:37 -0800 | [diff] [blame] | 446 | mutex_lock(&key_tfm_list_mutex); | 
|  | 447 | if (!ecryptfs_tfm_exists(mount_crypt_stat->global_default_cipher_name, | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 448 | NULL)) { | 
| Eric Sandeen | af440f5 | 2008-02-06 01:38:37 -0800 | [diff] [blame] | 449 | rc = ecryptfs_add_new_key_tfm( | 
|  | 450 | NULL, mount_crypt_stat->global_default_cipher_name, | 
|  | 451 | mount_crypt_stat->global_default_cipher_key_size); | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 452 | if (rc) { | 
|  | 453 | printk(KERN_ERR "Error attempting to initialize " | 
|  | 454 | "cipher with name = [%s] and key size = [%td]; " | 
|  | 455 | "rc = [%d]\n", | 
|  | 456 | mount_crypt_stat->global_default_cipher_name, | 
|  | 457 | mount_crypt_stat->global_default_cipher_key_size, | 
|  | 458 | rc); | 
|  | 459 | rc = -EINVAL; | 
|  | 460 | mutex_unlock(&key_tfm_list_mutex); | 
|  | 461 | goto out; | 
|  | 462 | } | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 463 | } | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 464 | if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) | 
|  | 465 | && !ecryptfs_tfm_exists( | 
|  | 466 | mount_crypt_stat->global_default_fn_cipher_name, NULL)) { | 
|  | 467 | rc = ecryptfs_add_new_key_tfm( | 
|  | 468 | NULL, mount_crypt_stat->global_default_fn_cipher_name, | 
|  | 469 | mount_crypt_stat->global_default_fn_cipher_key_bytes); | 
|  | 470 | if (rc) { | 
|  | 471 | printk(KERN_ERR "Error attempting to initialize " | 
|  | 472 | "cipher with name = [%s] and key size = [%td]; " | 
|  | 473 | "rc = [%d]\n", | 
|  | 474 | mount_crypt_stat->global_default_fn_cipher_name, | 
|  | 475 | mount_crypt_stat->global_default_fn_cipher_key_bytes, | 
|  | 476 | rc); | 
|  | 477 | rc = -EINVAL; | 
|  | 478 | mutex_unlock(&key_tfm_list_mutex); | 
|  | 479 | goto out; | 
|  | 480 | } | 
|  | 481 | } | 
|  | 482 | mutex_unlock(&key_tfm_list_mutex); | 
| Michael Halcrow | 5dda699 | 2007-10-16 01:28:06 -0700 | [diff] [blame] | 483 | rc = ecryptfs_init_global_auth_toks(mount_crypt_stat); | 
| Michael Halcrow | 87c94c4 | 2009-01-06 14:42:01 -0800 | [diff] [blame] | 484 | if (rc) | 
| Michael Halcrow | f4aad16 | 2007-10-16 01:27:53 -0700 | [diff] [blame] | 485 | printk(KERN_WARNING "One or more global auth toks could not " | 
|  | 486 | "properly register; rc = [%d]\n", rc); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 487 | out: | 
|  | 488 | return rc; | 
|  | 489 | } | 
|  | 490 |  | 
|  | 491 | struct kmem_cache *ecryptfs_sb_info_cache; | 
| Al Viro | 4403158 | 2010-05-17 00:59:46 -0400 | [diff] [blame] | 492 | static struct file_system_type ecryptfs_fs_type; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 493 |  | 
|  | 494 | /** | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 495 | * ecryptfs_read_super | 
|  | 496 | * @sb: The ecryptfs super block | 
|  | 497 | * @dev_name: The path to mount over | 
|  | 498 | * | 
|  | 499 | * Read the super block of the lower filesystem, and use | 
|  | 500 | * ecryptfs_interpose to create our initial inode and super block | 
|  | 501 | * struct. | 
|  | 502 | */ | 
|  | 503 | static int ecryptfs_read_super(struct super_block *sb, const char *dev_name) | 
|  | 504 | { | 
| Al Viro | 421748e | 2008-08-02 01:04:36 -0400 | [diff] [blame] | 505 | struct path path; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 506 | int rc; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 507 |  | 
| Al Viro | 421748e | 2008-08-02 01:04:36 -0400 | [diff] [blame] | 508 | rc = kern_path(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 509 | if (rc) { | 
|  | 510 | ecryptfs_printk(KERN_WARNING, "path_lookup() failed\n"); | 
| Michael Halcrow | 65dc814 | 2007-02-28 20:12:57 -0800 | [diff] [blame] | 511 | goto out; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 512 | } | 
| Al Viro | 4403158 | 2010-05-17 00:59:46 -0400 | [diff] [blame] | 513 | if (path.dentry->d_sb->s_type == &ecryptfs_fs_type) { | 
|  | 514 | rc = -EINVAL; | 
|  | 515 | printk(KERN_ERR "Mount on filesystem of type " | 
|  | 516 | "eCryptfs explicitly disallowed due to " | 
|  | 517 | "known incompatibilities\n"); | 
|  | 518 | goto out_free; | 
|  | 519 | } | 
| Al Viro | 421748e | 2008-08-02 01:04:36 -0400 | [diff] [blame] | 520 | ecryptfs_set_superblock_lower(sb, path.dentry->d_sb); | 
|  | 521 | sb->s_maxbytes = path.dentry->d_sb->s_maxbytes; | 
|  | 522 | sb->s_blocksize = path.dentry->d_sb->s_blocksize; | 
|  | 523 | ecryptfs_set_dentry_lower(sb->s_root, path.dentry); | 
|  | 524 | ecryptfs_set_dentry_lower_mnt(sb->s_root, path.mnt); | 
|  | 525 | rc = ecryptfs_interpose(path.dentry, sb->s_root, sb, 0); | 
| Michael Halcrow | 5dda699 | 2007-10-16 01:28:06 -0700 | [diff] [blame] | 526 | if (rc) | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 527 | goto out_free; | 
|  | 528 | rc = 0; | 
|  | 529 | goto out; | 
|  | 530 | out_free: | 
| Al Viro | 421748e | 2008-08-02 01:04:36 -0400 | [diff] [blame] | 531 | path_put(&path); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 532 | out: | 
|  | 533 | return rc; | 
|  | 534 | } | 
|  | 535 |  | 
|  | 536 | /** | 
|  | 537 | * ecryptfs_get_sb | 
|  | 538 | * @fs_type | 
|  | 539 | * @flags | 
|  | 540 | * @dev_name: The path to mount over | 
|  | 541 | * @raw_data: The options passed into the kernel | 
|  | 542 | * | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 543 | * The whole ecryptfs_get_sb process is broken into 3 functions: | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 544 | * ecryptfs_parse_options(): handle options passed to ecryptfs, if any | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 545 | * ecryptfs_read_super(): this accesses the lower filesystem and uses | 
| Erez Zadok | fe0fc01 | 2010-01-04 18:17:02 -0500 | [diff] [blame] | 546 | *                        ecryptfs_interpose to perform most of the linking | 
|  | 547 | * ecryptfs_interpose(): links the lower filesystem into ecryptfs (inode.c) | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 548 | */ | 
| Al Viro | 4d143be | 2010-07-26 13:33:36 +0400 | [diff] [blame] | 549 | static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags, | 
|  | 550 | const char *dev_name, void *raw_data) | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 551 | { | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 552 | struct super_block *s; | 
|  | 553 | struct ecryptfs_sb_info *sbi; | 
|  | 554 | struct ecryptfs_dentry_info *root_info; | 
|  | 555 | const char *err = "Getting sb failed"; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 556 | int rc; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 557 |  | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 558 | sbi = kmem_cache_zalloc(ecryptfs_sb_info_cache, GFP_KERNEL); | 
|  | 559 | if (!sbi) { | 
|  | 560 | rc = -ENOMEM; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 561 | goto out; | 
|  | 562 | } | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 563 |  | 
|  | 564 | rc = ecryptfs_parse_options(sbi, raw_data); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 565 | if (rc) { | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 566 | err = "Error parsing options"; | 
|  | 567 | goto out; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 568 | } | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 569 |  | 
|  | 570 | s = sget(fs_type, NULL, set_anon_super, NULL); | 
|  | 571 | if (IS_ERR(s)) { | 
|  | 572 | rc = PTR_ERR(s); | 
|  | 573 | goto out; | 
|  | 574 | } | 
|  | 575 |  | 
|  | 576 | s->s_flags = flags; | 
|  | 577 | rc = bdi_setup_and_register(&sbi->bdi, "ecryptfs", BDI_CAP_MAP_COPY); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 578 | if (rc) { | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 579 | deactivate_locked_super(s); | 
|  | 580 | goto out; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 581 | } | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 582 |  | 
|  | 583 | ecryptfs_set_superblock_private(s, sbi); | 
|  | 584 | s->s_bdi = &sbi->bdi; | 
|  | 585 |  | 
|  | 586 | /* ->kill_sb() will take care of sbi after that point */ | 
|  | 587 | sbi = NULL; | 
|  | 588 | s->s_op = &ecryptfs_sops; | 
|  | 589 |  | 
|  | 590 | rc = -ENOMEM; | 
|  | 591 | s->s_root = d_alloc(NULL, &(const struct qstr) { | 
|  | 592 | .hash = 0,.name = "/",.len = 1}); | 
|  | 593 | if (!s->s_root) { | 
|  | 594 | deactivate_locked_super(s); | 
|  | 595 | goto out; | 
|  | 596 | } | 
|  | 597 | s->s_root->d_op = &ecryptfs_dops; | 
|  | 598 | s->s_root->d_sb = s; | 
|  | 599 | s->s_root->d_parent = s->s_root; | 
|  | 600 |  | 
|  | 601 | root_info = kmem_cache_zalloc(ecryptfs_dentry_info_cache, GFP_KERNEL); | 
|  | 602 | if (!root_info) { | 
|  | 603 | deactivate_locked_super(s); | 
|  | 604 | goto out; | 
|  | 605 | } | 
|  | 606 | /* ->kill_sb() will take care of root_info */ | 
|  | 607 | ecryptfs_set_dentry_private(s->s_root, root_info); | 
|  | 608 | s->s_flags |= MS_ACTIVE; | 
|  | 609 | rc = ecryptfs_read_super(s, dev_name); | 
|  | 610 | if (rc) { | 
|  | 611 | deactivate_locked_super(s); | 
|  | 612 | err = "Reading sb failed"; | 
|  | 613 | goto out; | 
|  | 614 | } | 
| Al Viro | 4d143be | 2010-07-26 13:33:36 +0400 | [diff] [blame] | 615 | return dget(s->s_root); | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 616 |  | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 617 | out: | 
| Al Viro | 2ccde7c | 2010-03-21 12:24:29 -0400 | [diff] [blame] | 618 | if (sbi) { | 
|  | 619 | ecryptfs_destroy_mount_crypt_stat(&sbi->mount_crypt_stat); | 
|  | 620 | kmem_cache_free(ecryptfs_sb_info_cache, sbi); | 
|  | 621 | } | 
|  | 622 | printk(KERN_ERR "%s; rc = [%d]\n", err, rc); | 
| Al Viro | 4d143be | 2010-07-26 13:33:36 +0400 | [diff] [blame] | 623 | return ERR_PTR(rc); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 624 | } | 
|  | 625 |  | 
|  | 626 | /** | 
|  | 627 | * ecryptfs_kill_block_super | 
|  | 628 | * @sb: The ecryptfs super block | 
|  | 629 | * | 
|  | 630 | * Used to bring the superblock down and free the private data. | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 631 | */ | 
|  | 632 | static void ecryptfs_kill_block_super(struct super_block *sb) | 
|  | 633 | { | 
| Al Viro | decabd6 | 2010-03-20 22:32:26 -0400 | [diff] [blame] | 634 | struct ecryptfs_sb_info *sb_info = ecryptfs_superblock_to_private(sb); | 
|  | 635 | kill_anon_super(sb); | 
|  | 636 | if (!sb_info) | 
|  | 637 | return; | 
|  | 638 | ecryptfs_destroy_mount_crypt_stat(&sb_info->mount_crypt_stat); | 
|  | 639 | bdi_destroy(&sb_info->bdi); | 
|  | 640 | kmem_cache_free(ecryptfs_sb_info_cache, sb_info); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 641 | } | 
|  | 642 |  | 
|  | 643 | static struct file_system_type ecryptfs_fs_type = { | 
|  | 644 | .owner = THIS_MODULE, | 
|  | 645 | .name = "ecryptfs", | 
| Al Viro | 4d143be | 2010-07-26 13:33:36 +0400 | [diff] [blame] | 646 | .mount = ecryptfs_mount, | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 647 | .kill_sb = ecryptfs_kill_block_super, | 
|  | 648 | .fs_flags = 0 | 
|  | 649 | }; | 
|  | 650 |  | 
|  | 651 | /** | 
|  | 652 | * inode_info_init_once | 
|  | 653 | * | 
|  | 654 | * Initializes the ecryptfs_inode_info_cache when it is created | 
|  | 655 | */ | 
|  | 656 | static void | 
| Alexey Dobriyan | 51cc506 | 2008-07-25 19:45:34 -0700 | [diff] [blame] | 657 | inode_info_init_once(void *vptr) | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 658 | { | 
|  | 659 | struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr; | 
|  | 660 |  | 
| Christoph Lameter | a35afb8 | 2007-05-16 22:10:57 -0700 | [diff] [blame] | 661 | inode_init_once(&ei->vfs_inode); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 662 | } | 
|  | 663 |  | 
|  | 664 | static struct ecryptfs_cache_info { | 
| Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 665 | struct kmem_cache **cache; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 666 | const char *name; | 
|  | 667 | size_t size; | 
| Alexey Dobriyan | 51cc506 | 2008-07-25 19:45:34 -0700 | [diff] [blame] | 668 | void (*ctor)(void *obj); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 669 | } ecryptfs_cache_infos[] = { | 
|  | 670 | { | 
|  | 671 | .cache = &ecryptfs_auth_tok_list_item_cache, | 
|  | 672 | .name = "ecryptfs_auth_tok_list_item", | 
|  | 673 | .size = sizeof(struct ecryptfs_auth_tok_list_item), | 
|  | 674 | }, | 
|  | 675 | { | 
|  | 676 | .cache = &ecryptfs_file_info_cache, | 
|  | 677 | .name = "ecryptfs_file_cache", | 
|  | 678 | .size = sizeof(struct ecryptfs_file_info), | 
|  | 679 | }, | 
|  | 680 | { | 
|  | 681 | .cache = &ecryptfs_dentry_info_cache, | 
|  | 682 | .name = "ecryptfs_dentry_info_cache", | 
|  | 683 | .size = sizeof(struct ecryptfs_dentry_info), | 
|  | 684 | }, | 
|  | 685 | { | 
|  | 686 | .cache = &ecryptfs_inode_info_cache, | 
|  | 687 | .name = "ecryptfs_inode_cache", | 
|  | 688 | .size = sizeof(struct ecryptfs_inode_info), | 
|  | 689 | .ctor = inode_info_init_once, | 
|  | 690 | }, | 
|  | 691 | { | 
|  | 692 | .cache = &ecryptfs_sb_info_cache, | 
|  | 693 | .name = "ecryptfs_sb_cache", | 
|  | 694 | .size = sizeof(struct ecryptfs_sb_info), | 
|  | 695 | }, | 
|  | 696 | { | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 697 | .cache = &ecryptfs_header_cache_1, | 
|  | 698 | .name = "ecryptfs_headers_1", | 
|  | 699 | .size = PAGE_CACHE_SIZE, | 
|  | 700 | }, | 
|  | 701 | { | 
|  | 702 | .cache = &ecryptfs_header_cache_2, | 
|  | 703 | .name = "ecryptfs_headers_2", | 
|  | 704 | .size = PAGE_CACHE_SIZE, | 
|  | 705 | }, | 
|  | 706 | { | 
| Michael Halcrow | dd2a3b7 | 2007-02-12 00:53:46 -0800 | [diff] [blame] | 707 | .cache = &ecryptfs_xattr_cache, | 
|  | 708 | .name = "ecryptfs_xattr_cache", | 
|  | 709 | .size = PAGE_CACHE_SIZE, | 
|  | 710 | }, | 
|  | 711 | { | 
| Michael Halcrow | eb95e7f | 2007-02-16 01:28:40 -0800 | [diff] [blame] | 712 | .cache = &ecryptfs_key_record_cache, | 
|  | 713 | .name = "ecryptfs_key_record_cache", | 
|  | 714 | .size = sizeof(struct ecryptfs_key_record), | 
|  | 715 | }, | 
| Michael Halcrow | 956159c | 2007-10-16 01:27:55 -0700 | [diff] [blame] | 716 | { | 
|  | 717 | .cache = &ecryptfs_key_sig_cache, | 
|  | 718 | .name = "ecryptfs_key_sig_cache", | 
|  | 719 | .size = sizeof(struct ecryptfs_key_sig), | 
|  | 720 | }, | 
|  | 721 | { | 
|  | 722 | .cache = &ecryptfs_global_auth_tok_cache, | 
|  | 723 | .name = "ecryptfs_global_auth_tok_cache", | 
|  | 724 | .size = sizeof(struct ecryptfs_global_auth_tok), | 
|  | 725 | }, | 
|  | 726 | { | 
|  | 727 | .cache = &ecryptfs_key_tfm_cache, | 
|  | 728 | .name = "ecryptfs_key_tfm_cache", | 
|  | 729 | .size = sizeof(struct ecryptfs_key_tfm), | 
|  | 730 | }, | 
| Michael Halcrow | 746f1e5 | 2008-07-23 21:30:02 -0700 | [diff] [blame] | 731 | { | 
|  | 732 | .cache = &ecryptfs_open_req_cache, | 
|  | 733 | .name = "ecryptfs_open_req_cache", | 
|  | 734 | .size = sizeof(struct ecryptfs_open_req), | 
|  | 735 | }, | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 736 | }; | 
|  | 737 |  | 
|  | 738 | static void ecryptfs_free_kmem_caches(void) | 
|  | 739 | { | 
|  | 740 | int i; | 
|  | 741 |  | 
|  | 742 | for (i = 0; i < ARRAY_SIZE(ecryptfs_cache_infos); i++) { | 
|  | 743 | struct ecryptfs_cache_info *info; | 
|  | 744 |  | 
|  | 745 | info = &ecryptfs_cache_infos[i]; | 
|  | 746 | if (*(info->cache)) | 
|  | 747 | kmem_cache_destroy(*(info->cache)); | 
|  | 748 | } | 
|  | 749 | } | 
|  | 750 |  | 
|  | 751 | /** | 
|  | 752 | * ecryptfs_init_kmem_caches | 
|  | 753 | * | 
|  | 754 | * Returns zero on success; non-zero otherwise | 
|  | 755 | */ | 
|  | 756 | static int ecryptfs_init_kmem_caches(void) | 
|  | 757 | { | 
|  | 758 | int i; | 
|  | 759 |  | 
|  | 760 | for (i = 0; i < ARRAY_SIZE(ecryptfs_cache_infos); i++) { | 
|  | 761 | struct ecryptfs_cache_info *info; | 
|  | 762 |  | 
|  | 763 | info = &ecryptfs_cache_infos[i]; | 
|  | 764 | *(info->cache) = kmem_cache_create(info->name, info->size, | 
| Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 765 | 0, SLAB_HWCACHE_ALIGN, info->ctor); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 766 | if (!*(info->cache)) { | 
|  | 767 | ecryptfs_free_kmem_caches(); | 
|  | 768 | ecryptfs_printk(KERN_WARNING, "%s: " | 
|  | 769 | "kmem_cache_create failed\n", | 
|  | 770 | info->name); | 
|  | 771 | return -ENOMEM; | 
|  | 772 | } | 
|  | 773 | } | 
|  | 774 | return 0; | 
|  | 775 | } | 
|  | 776 |  | 
| Greg Kroah-Hartman | 6e90aa9 | 2007-11-06 15:08:08 -0800 | [diff] [blame] | 777 | static struct kobject *ecryptfs_kobj; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 778 |  | 
| Kay Sievers | 386f275 | 2007-11-02 13:47:53 +0100 | [diff] [blame] | 779 | static ssize_t version_show(struct kobject *kobj, | 
|  | 780 | struct kobj_attribute *attr, char *buff) | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 781 | { | 
|  | 782 | return snprintf(buff, PAGE_SIZE, "%d\n", ECRYPTFS_VERSIONING_MASK); | 
|  | 783 | } | 
|  | 784 |  | 
| Kay Sievers | 386f275 | 2007-11-02 13:47:53 +0100 | [diff] [blame] | 785 | static struct kobj_attribute version_attr = __ATTR_RO(version); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 786 |  | 
| Greg Kroah-Hartman | 30a468b | 2007-10-15 15:01:24 -0700 | [diff] [blame] | 787 | static struct attribute *attributes[] = { | 
|  | 788 | &version_attr.attr, | 
| Greg Kroah-Hartman | 30a468b | 2007-10-15 15:01:24 -0700 | [diff] [blame] | 789 | NULL, | 
|  | 790 | }; | 
|  | 791 |  | 
|  | 792 | static struct attribute_group attr_group = { | 
|  | 793 | .attrs = attributes, | 
|  | 794 | }; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 795 |  | 
|  | 796 | static int do_sysfs_registration(void) | 
|  | 797 | { | 
|  | 798 | int rc; | 
|  | 799 |  | 
| Greg Kroah-Hartman | 6e90aa9 | 2007-11-06 15:08:08 -0800 | [diff] [blame] | 800 | ecryptfs_kobj = kobject_create_and_add("ecryptfs", fs_kobj); | 
|  | 801 | if (!ecryptfs_kobj) { | 
| Greg Kroah-Hartman | 917e865 | 2007-10-29 20:13:17 +0100 | [diff] [blame] | 802 | printk(KERN_ERR "Unable to create ecryptfs kset\n"); | 
|  | 803 | rc = -ENOMEM; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 804 | goto out; | 
|  | 805 | } | 
| Greg Kroah-Hartman | 6e90aa9 | 2007-11-06 15:08:08 -0800 | [diff] [blame] | 806 | rc = sysfs_create_group(ecryptfs_kobj, &attr_group); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 807 | if (rc) { | 
|  | 808 | printk(KERN_ERR | 
| Greg Kroah-Hartman | 30a468b | 2007-10-15 15:01:24 -0700 | [diff] [blame] | 809 | "Unable to create ecryptfs version attributes\n"); | 
| Greg Kroah-Hartman | 197b12d | 2007-12-20 08:13:05 -0800 | [diff] [blame] | 810 | kobject_put(ecryptfs_kobj); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 811 | } | 
|  | 812 | out: | 
|  | 813 | return rc; | 
|  | 814 | } | 
|  | 815 |  | 
| Ryusuke Konishi | a75de1b | 2007-08-10 13:00:56 -0700 | [diff] [blame] | 816 | static void do_sysfs_unregistration(void) | 
|  | 817 | { | 
| Greg Kroah-Hartman | 6e90aa9 | 2007-11-06 15:08:08 -0800 | [diff] [blame] | 818 | sysfs_remove_group(ecryptfs_kobj, &attr_group); | 
| Greg Kroah-Hartman | 197b12d | 2007-12-20 08:13:05 -0800 | [diff] [blame] | 819 | kobject_put(ecryptfs_kobj); | 
| Ryusuke Konishi | a75de1b | 2007-08-10 13:00:56 -0700 | [diff] [blame] | 820 | } | 
|  | 821 |  | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 822 | static int __init ecryptfs_init(void) | 
|  | 823 | { | 
|  | 824 | int rc; | 
|  | 825 |  | 
|  | 826 | if (ECRYPTFS_DEFAULT_EXTENT_SIZE > PAGE_CACHE_SIZE) { | 
|  | 827 | rc = -EINVAL; | 
|  | 828 | ecryptfs_printk(KERN_ERR, "The eCryptfs extent size is " | 
|  | 829 | "larger than the host's page size, and so " | 
|  | 830 | "eCryptfs cannot run on this system. The " | 
|  | 831 | "default eCryptfs extent size is [%d] bytes; " | 
|  | 832 | "the page size is [%d] bytes.\n", | 
|  | 833 | ECRYPTFS_DEFAULT_EXTENT_SIZE, PAGE_CACHE_SIZE); | 
|  | 834 | goto out; | 
|  | 835 | } | 
|  | 836 | rc = ecryptfs_init_kmem_caches(); | 
|  | 837 | if (rc) { | 
|  | 838 | printk(KERN_ERR | 
|  | 839 | "Failed to allocate one or more kmem_cache objects\n"); | 
|  | 840 | goto out; | 
|  | 841 | } | 
|  | 842 | rc = register_filesystem(&ecryptfs_fs_type); | 
|  | 843 | if (rc) { | 
|  | 844 | printk(KERN_ERR "Failed to register filesystem\n"); | 
| Michael Halcrow | cf81f89 | 2007-10-16 01:28:07 -0700 | [diff] [blame] | 845 | goto out_free_kmem_caches; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 846 | } | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 847 | rc = do_sysfs_registration(); | 
|  | 848 | if (rc) { | 
|  | 849 | printk(KERN_ERR "sysfs registration failed\n"); | 
| Michael Halcrow | cf81f89 | 2007-10-16 01:28:07 -0700 | [diff] [blame] | 850 | goto out_unregister_filesystem; | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 851 | } | 
| Michael Halcrow | 746f1e5 | 2008-07-23 21:30:02 -0700 | [diff] [blame] | 852 | rc = ecryptfs_init_kthread(); | 
|  | 853 | if (rc) { | 
|  | 854 | printk(KERN_ERR "%s: kthread initialization failed; " | 
|  | 855 | "rc = [%d]\n", __func__, rc); | 
|  | 856 | goto out_do_sysfs_unregistration; | 
|  | 857 | } | 
| Tyler Hicks | 624ae52 | 2008-10-15 22:02:51 -0700 | [diff] [blame] | 858 | rc = ecryptfs_init_messaging(); | 
| Michael Halcrow | dddfa46 | 2007-02-12 00:53:44 -0800 | [diff] [blame] | 859 | if (rc) { | 
| Michael Halcrow | 746f1e5 | 2008-07-23 21:30:02 -0700 | [diff] [blame] | 860 | printk(KERN_ERR "Failure occured while attempting to " | 
| Tyler Hicks | 624ae52 | 2008-10-15 22:02:51 -0700 | [diff] [blame] | 861 | "initialize the communications channel to " | 
|  | 862 | "ecryptfsd\n"); | 
| Michael Halcrow | 746f1e5 | 2008-07-23 21:30:02 -0700 | [diff] [blame] | 863 | goto out_destroy_kthread; | 
| Michael Halcrow | 956159c | 2007-10-16 01:27:55 -0700 | [diff] [blame] | 864 | } | 
|  | 865 | rc = ecryptfs_init_crypto(); | 
|  | 866 | if (rc) { | 
|  | 867 | printk(KERN_ERR "Failure whilst attempting to init crypto; " | 
|  | 868 | "rc = [%d]\n", rc); | 
| Michael Halcrow | cf81f89 | 2007-10-16 01:28:07 -0700 | [diff] [blame] | 869 | goto out_release_messaging; | 
| Michael Halcrow | dddfa46 | 2007-02-12 00:53:44 -0800 | [diff] [blame] | 870 | } | 
| Eric Sandeen | 2830bfd | 2008-02-06 01:38:34 -0800 | [diff] [blame] | 871 | if (ecryptfs_verbosity > 0) | 
|  | 872 | printk(KERN_CRIT "eCryptfs verbosity set to %d. Secret values " | 
|  | 873 | "will be written to the syslog!\n", ecryptfs_verbosity); | 
|  | 874 |  | 
| Michael Halcrow | cf81f89 | 2007-10-16 01:28:07 -0700 | [diff] [blame] | 875 | goto out; | 
|  | 876 | out_release_messaging: | 
| Tyler Hicks | 624ae52 | 2008-10-15 22:02:51 -0700 | [diff] [blame] | 877 | ecryptfs_release_messaging(); | 
| Michael Halcrow | 746f1e5 | 2008-07-23 21:30:02 -0700 | [diff] [blame] | 878 | out_destroy_kthread: | 
|  | 879 | ecryptfs_destroy_kthread(); | 
| Michael Halcrow | cf81f89 | 2007-10-16 01:28:07 -0700 | [diff] [blame] | 880 | out_do_sysfs_unregistration: | 
|  | 881 | do_sysfs_unregistration(); | 
|  | 882 | out_unregister_filesystem: | 
|  | 883 | unregister_filesystem(&ecryptfs_fs_type); | 
|  | 884 | out_free_kmem_caches: | 
|  | 885 | ecryptfs_free_kmem_caches(); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 886 | out: | 
|  | 887 | return rc; | 
|  | 888 | } | 
|  | 889 |  | 
|  | 890 | static void __exit ecryptfs_exit(void) | 
|  | 891 | { | 
| Michael Halcrow | cf81f89 | 2007-10-16 01:28:07 -0700 | [diff] [blame] | 892 | int rc; | 
|  | 893 |  | 
|  | 894 | rc = ecryptfs_destroy_crypto(); | 
|  | 895 | if (rc) | 
|  | 896 | printk(KERN_ERR "Failure whilst attempting to destroy crypto; " | 
|  | 897 | "rc = [%d]\n", rc); | 
| Tyler Hicks | 624ae52 | 2008-10-15 22:02:51 -0700 | [diff] [blame] | 898 | ecryptfs_release_messaging(); | 
| Michael Halcrow | 746f1e5 | 2008-07-23 21:30:02 -0700 | [diff] [blame] | 899 | ecryptfs_destroy_kthread(); | 
| Michael Halcrow | cf81f89 | 2007-10-16 01:28:07 -0700 | [diff] [blame] | 900 | do_sysfs_unregistration(); | 
| Michael Halcrow | 237fead | 2006-10-04 02:16:22 -0700 | [diff] [blame] | 901 | unregister_filesystem(&ecryptfs_fs_type); | 
|  | 902 | ecryptfs_free_kmem_caches(); | 
|  | 903 | } | 
|  | 904 |  | 
|  | 905 | MODULE_AUTHOR("Michael A. Halcrow <mhalcrow@us.ibm.com>"); | 
|  | 906 | MODULE_DESCRIPTION("eCryptfs"); | 
|  | 907 |  | 
|  | 908 | MODULE_LICENSE("GPL"); | 
|  | 909 |  | 
|  | 910 | module_init(ecryptfs_init) | 
|  | 911 | module_exit(ecryptfs_exit) |