blob: 9ed4769063273a2287937a78b6d14d053784ba6c [file] [log] [blame]
Michael Halcrow237fead2006-10-04 02:16:22 -07001/**
2 * eCryptfs: Linux filesystem encryption layer
3 *
4 * Copyright (C) 1997-2003 Erez Zadok
5 * Copyright (C) 2001-2003 Stony Brook University
Michael Halcrowdd2a3b72007-02-12 00:53:46 -08006 * Copyright (C) 2004-2007 International Business Machines Corp.
Michael Halcrow237fead2006-10-04 02:16:22 -07007 * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com>
8 * Michael C. Thompson <mcthomps@us.ibm.com>
Michael Halcrowdddfa462007-02-12 00:53:44 -08009 * Tyler Hicks <tyhicks@ou.edu>
Michael Halcrow237fead2006-10-04 02:16:22 -070010 *
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 Halcrow237fead2006-10-04 02:16:22 -070033#include <linux/mount.h>
Michael Halcrow237fead2006-10-04 02:16:22 -070034#include <linux/pagemap.h>
35#include <linux/key.h>
36#include <linux/parser.h>
Josef "Jeff" Sipek0cc72dc2006-12-08 02:36:31 -080037#include <linux/fs_stack.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090038#include <linux/slab.h>
Michael Halcrow237fead2006-10-04 02:16:22 -070039#include "ecryptfs_kernel.h"
40
41/**
42 * Module parameter that defines the ecryptfs_verbosity level.
43 */
44int ecryptfs_verbosity = 0;
45
46module_param(ecryptfs_verbosity, int, 0);
47MODULE_PARM_DESC(ecryptfs_verbosity,
48 "Initial verbosity level (0 or 1; defaults to "
49 "0, which is Quiet)");
50
Michael Halcrowdddfa462007-02-12 00:53:44 -080051/**
Tyler Hicks624ae522008-10-15 22:02:51 -070052 * Module parameter that defines the number of message buffer elements
Michael Halcrowdddfa462007-02-12 00:53:44 -080053 */
54unsigned int ecryptfs_message_buf_len = ECRYPTFS_DEFAULT_MSG_CTX_ELEMS;
55
56module_param(ecryptfs_message_buf_len, uint, 0);
57MODULE_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 Hicks624ae522008-10-15 22:02:51 -070062 * for a response from ecryptfsd. The actual sleep time will be, more than
Michael Halcrowdddfa462007-02-12 00:53:44 -080063 * likely, a small amount greater than this specified value, but only less if
Tyler Hicks624ae522008-10-15 22:02:51 -070064 * the message successfully arrives.
Michael Halcrowdddfa462007-02-12 00:53:44 -080065 */
66signed long ecryptfs_message_wait_timeout = ECRYPTFS_MAX_MSG_CTX_TTL / HZ;
67
68module_param(ecryptfs_message_wait_timeout, long, 0);
69MODULE_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 */
79unsigned int ecryptfs_number_of_users = ECRYPTFS_DEFAULT_NUM_USERS;
80
81module_param(ecryptfs_number_of_users, uint, 0);
82MODULE_PARM_DESC(ecryptfs_number_of_users, "An estimate of the number of "
83 "concurrent users of eCryptfs");
84
Michael Halcrow237fead2006-10-04 02:16:22 -070085void __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 Halcrow4981e082007-10-16 01:28:09 -070098 * 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 Halcrow72b55ff2008-07-23 21:30:07 -0700117int ecryptfs_init_persistent_file(struct dentry *ecryptfs_dentry)
Michael Halcrow4981e082007-10-16 01:28:09 -0700118{
David Howells745ca242008-11-14 10:39:22 +1100119 const struct cred *cred = current_cred();
Michael Halcrow4981e082007-10-16 01:28:09 -0700120 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 Halcrow746f1e52008-07-23 21:30:02 -0700131 rc = ecryptfs_privileged_open(&inode_info->lower_file,
David Howells745ca242008-11-14 10:39:22 +1100132 lower_dentry, lower_mnt, cred);
Tyler Hicksac22ba22009-08-12 01:06:54 -0500133 if (rc) {
Michael Halcrow4981e082007-10-16 01:28:09 -0700134 printk(KERN_ERR "Error opening lower persistent file "
Michael Halcrow746f1e52008-07-23 21:30:02 -0700135 "for lower_dentry [0x%p] and lower_mnt [0x%p]; "
136 "rc = [%d]\n", lower_dentry, lower_mnt, rc);
Michael Halcrow4981e082007-10-16 01:28:09 -0700137 inode_info->lower_file = NULL;
Al Virob65a9cf2009-12-16 06:27:40 -0500138 }
Michael Halcrow4981e082007-10-16 01:28:09 -0700139 }
140 mutex_unlock(&inode_info->lower_file_mutex);
141 return rc;
142}
143
Al Viro66cb7662011-01-12 20:04:37 -0500144static inode *ecryptfs_get_inode(struct inode *lower_inode,
145 struct super_block *sb)
Michael Halcrow237fead2006-10-04 02:16:22 -0700146{
Michael Halcrow237fead2006-10-04 02:16:22 -0700147 struct inode *inode;
148 int rc = 0;
149
150 lower_inode = lower_dentry->d_inode;
151 if (lower_inode->i_sb != ecryptfs_superblock_to_lower(sb)) {
152 rc = -EXDEV;
153 goto out;
154 }
155 if (!igrab(lower_inode)) {
156 rc = -ESTALE;
157 goto out;
158 }
159 inode = iget5_locked(sb, (unsigned long)lower_inode,
160 ecryptfs_inode_test, ecryptfs_inode_set,
161 lower_inode);
162 if (!inode) {
163 rc = -EACCES;
164 iput(lower_inode);
165 goto out;
166 }
167 if (inode->i_state & I_NEW)
168 unlock_new_inode(inode);
169 else
170 iput(lower_inode);
171 if (S_ISLNK(lower_inode->i_mode))
172 inode->i_op = &ecryptfs_symlink_iops;
173 else if (S_ISDIR(lower_inode->i_mode))
174 inode->i_op = &ecryptfs_dir_iops;
175 if (S_ISDIR(lower_inode->i_mode))
176 inode->i_fop = &ecryptfs_dir_fops;
Pekka Enberg26da8202006-10-19 23:28:14 -0700177 if (special_file(lower_inode->i_mode))
Michael Halcrow237fead2006-10-04 02:16:22 -0700178 init_special_inode(inode, lower_inode->i_mode,
179 lower_inode->i_rdev);
Erez Zadok9afa2fb2009-12-02 19:51:54 -0500180 fsstack_copy_attr_all(inode, lower_inode);
Michael Halcrow237fead2006-10-04 02:16:22 -0700181 /* This size will be overwritten for real files w/ headers and
182 * other metadata */
Josef "Jeff" Sipek0cc72dc2006-12-08 02:36:31 -0800183 fsstack_copy_inode_size(inode, lower_inode);
Al Viro66cb7662011-01-12 20:04:37 -0500184 return inode;
185out:
186 return ERR_PTR(rc);
187}
188
189/**
190 * ecryptfs_interpose
191 * @lower_dentry: Existing dentry in the lower filesystem
192 * @dentry: ecryptfs' dentry
193 * @sb: ecryptfs's super_block
194 * @flags: flags to govern behavior of interpose procedure
195 *
196 * Interposes upper and lower dentries.
197 *
198 * Returns zero on success; non-zero otherwise
199 */
200int ecryptfs_interpose(struct dentry *lower_dentry, struct dentry *dentry,
201 struct super_block *sb, u32 flags)
202{
203 struct inode *lower_inode = lower_dentry->d_inode;
204 struct inode *inode = ecryptfs_get_inode(lower_inode, sb);
205 if (IS_ERR(inode)
206 return PTR_ERR(inode);
Tyler Hicksae6e8452009-03-12 00:19:46 -0500207 if (flags & ECRYPTFS_INTERPOSE_FLAG_D_ADD)
208 d_add(dentry, inode);
209 else
210 d_instantiate(dentry, inode);
Al Viro66cb7662011-01-12 20:04:37 -0500211 return 0;
Michael Halcrow237fead2006-10-04 02:16:22 -0700212}
213
Eric Sandeen2830bfd2008-02-06 01:38:34 -0800214enum { ecryptfs_opt_sig, ecryptfs_opt_ecryptfs_sig,
215 ecryptfs_opt_cipher, ecryptfs_opt_ecryptfs_cipher,
216 ecryptfs_opt_ecryptfs_key_bytes,
Michael Halcrow17398952007-02-12 00:53:45 -0800217 ecryptfs_opt_passthrough, ecryptfs_opt_xattr_metadata,
Michael Halcrow87c94c42009-01-06 14:42:01 -0800218 ecryptfs_opt_encrypted_view, ecryptfs_opt_fnek_sig,
219 ecryptfs_opt_fn_cipher, ecryptfs_opt_fn_cipher_key_bytes,
Roberto Sassuf16feb52010-10-06 18:31:32 +0200220 ecryptfs_opt_unlink_sigs, ecryptfs_opt_mount_auth_tok_only,
221 ecryptfs_opt_err };
Michael Halcrow237fead2006-10-04 02:16:22 -0700222
Steven Whitehousea447c092008-10-13 10:46:57 +0100223static const match_table_t tokens = {
Michael Halcrow237fead2006-10-04 02:16:22 -0700224 {ecryptfs_opt_sig, "sig=%s"},
225 {ecryptfs_opt_ecryptfs_sig, "ecryptfs_sig=%s"},
Michael Halcrow237fead2006-10-04 02:16:22 -0700226 {ecryptfs_opt_cipher, "cipher=%s"},
227 {ecryptfs_opt_ecryptfs_cipher, "ecryptfs_cipher=%s"},
228 {ecryptfs_opt_ecryptfs_key_bytes, "ecryptfs_key_bytes=%u"},
229 {ecryptfs_opt_passthrough, "ecryptfs_passthrough"},
Michael Halcrow17398952007-02-12 00:53:45 -0800230 {ecryptfs_opt_xattr_metadata, "ecryptfs_xattr_metadata"},
231 {ecryptfs_opt_encrypted_view, "ecryptfs_encrypted_view"},
Michael Halcrow87c94c42009-01-06 14:42:01 -0800232 {ecryptfs_opt_fnek_sig, "ecryptfs_fnek_sig=%s"},
233 {ecryptfs_opt_fn_cipher, "ecryptfs_fn_cipher=%s"},
234 {ecryptfs_opt_fn_cipher_key_bytes, "ecryptfs_fn_key_bytes=%u"},
Tyler Hickse77cc8d2009-04-22 04:08:46 -0500235 {ecryptfs_opt_unlink_sigs, "ecryptfs_unlink_sigs"},
Roberto Sassuf16feb52010-10-06 18:31:32 +0200236 {ecryptfs_opt_mount_auth_tok_only, "ecryptfs_mount_auth_tok_only"},
Michael Halcrow237fead2006-10-04 02:16:22 -0700237 {ecryptfs_opt_err, NULL}
238};
239
Michael Halcrowf4aad162007-10-16 01:27:53 -0700240static int ecryptfs_init_global_auth_toks(
241 struct ecryptfs_mount_crypt_stat *mount_crypt_stat)
Michael Halcrow237fead2006-10-04 02:16:22 -0700242{
Michael Halcrowf4aad162007-10-16 01:27:53 -0700243 struct ecryptfs_global_auth_tok *global_auth_tok;
Michael Halcrow237fead2006-10-04 02:16:22 -0700244 int rc = 0;
Michael Halcrow237fead2006-10-04 02:16:22 -0700245
Michael Halcrowf4aad162007-10-16 01:27:53 -0700246 list_for_each_entry(global_auth_tok,
247 &mount_crypt_stat->global_auth_tok_list,
248 mount_crypt_stat_list) {
Michael Halcrow5dda6992007-10-16 01:28:06 -0700249 rc = ecryptfs_keyring_auth_tok_for_sig(
250 &global_auth_tok->global_auth_tok_key,
251 &global_auth_tok->global_auth_tok,
252 global_auth_tok->sig);
253 if (rc) {
Michael Halcrowf4aad162007-10-16 01:27:53 -0700254 printk(KERN_ERR "Could not find valid key in user "
255 "session keyring for sig specified in mount "
256 "option: [%s]\n", global_auth_tok->sig);
257 global_auth_tok->flags |= ECRYPTFS_AUTH_TOK_INVALID;
Eric Sandeen982363c2008-07-23 21:30:04 -0700258 goto out;
Michael Halcrowf4aad162007-10-16 01:27:53 -0700259 } else
260 global_auth_tok->flags &= ~ECRYPTFS_AUTH_TOK_INVALID;
Michael Halcrow237fead2006-10-04 02:16:22 -0700261 }
Eric Sandeen982363c2008-07-23 21:30:04 -0700262out:
Michael Halcrow237fead2006-10-04 02:16:22 -0700263 return rc;
264}
265
Michael Halcrowf4aad162007-10-16 01:27:53 -0700266static void ecryptfs_init_mount_crypt_stat(
267 struct ecryptfs_mount_crypt_stat *mount_crypt_stat)
268{
269 memset((void *)mount_crypt_stat, 0,
270 sizeof(struct ecryptfs_mount_crypt_stat));
271 INIT_LIST_HEAD(&mount_crypt_stat->global_auth_tok_list);
272 mutex_init(&mount_crypt_stat->global_auth_tok_list_mutex);
273 mount_crypt_stat->flags |= ECRYPTFS_MOUNT_CRYPT_STAT_INITIALIZED;
274}
275
Michael Halcrow237fead2006-10-04 02:16:22 -0700276/**
277 * ecryptfs_parse_options
278 * @sb: The ecryptfs super block
279 * @options: The options pased to the kernel
280 *
281 * Parse mount options:
282 * debug=N - ecryptfs_verbosity level for debug output
283 * sig=XXX - description(signature) of the key to use
284 *
285 * Returns the dentry object of the lower-level (lower/interposed)
286 * directory; We want to mount our stackable file system on top of
287 * that lower directory.
288 *
289 * The signature of the key to use must be the description of a key
290 * already in the keyring. Mounting will fail if the key can not be
291 * found.
292 *
293 * Returns zero on success; non-zero on error
294 */
Al Viro2ccde7c2010-03-21 12:24:29 -0400295static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options)
Michael Halcrow237fead2006-10-04 02:16:22 -0700296{
297 char *p;
298 int rc = 0;
299 int sig_set = 0;
300 int cipher_name_set = 0;
Michael Halcrow87c94c42009-01-06 14:42:01 -0800301 int fn_cipher_name_set = 0;
Michael Halcrow237fead2006-10-04 02:16:22 -0700302 int cipher_key_bytes;
303 int cipher_key_bytes_set = 0;
Michael Halcrow87c94c42009-01-06 14:42:01 -0800304 int fn_cipher_key_bytes;
305 int fn_cipher_key_bytes_set = 0;
Michael Halcrow237fead2006-10-04 02:16:22 -0700306 struct ecryptfs_mount_crypt_stat *mount_crypt_stat =
Al Viro2ccde7c2010-03-21 12:24:29 -0400307 &sbi->mount_crypt_stat;
Michael Halcrow237fead2006-10-04 02:16:22 -0700308 substring_t args[MAX_OPT_ARGS];
309 int token;
310 char *sig_src;
Michael Halcrow237fead2006-10-04 02:16:22 -0700311 char *cipher_name_dst;
312 char *cipher_name_src;
Michael Halcrow87c94c42009-01-06 14:42:01 -0800313 char *fn_cipher_name_dst;
314 char *fn_cipher_name_src;
315 char *fnek_dst;
316 char *fnek_src;
Michael Halcrow237fead2006-10-04 02:16:22 -0700317 char *cipher_key_bytes_src;
Michael Halcrow87c94c42009-01-06 14:42:01 -0800318 char *fn_cipher_key_bytes_src;
Michael Halcrow237fead2006-10-04 02:16:22 -0700319
320 if (!options) {
321 rc = -EINVAL;
322 goto out;
323 }
Michael Halcrow956159c2007-10-16 01:27:55 -0700324 ecryptfs_init_mount_crypt_stat(mount_crypt_stat);
Michael Halcrow237fead2006-10-04 02:16:22 -0700325 while ((p = strsep(&options, ",")) != NULL) {
326 if (!*p)
327 continue;
328 token = match_token(p, tokens, args);
329 switch (token) {
330 case ecryptfs_opt_sig:
331 case ecryptfs_opt_ecryptfs_sig:
332 sig_src = args[0].from;
Michael Halcrowf4aad162007-10-16 01:27:53 -0700333 rc = ecryptfs_add_global_auth_tok(mount_crypt_stat,
Tyler Hicks84814d62009-03-13 13:51:59 -0700334 sig_src, 0);
Michael Halcrowf4aad162007-10-16 01:27:53 -0700335 if (rc) {
336 printk(KERN_ERR "Error attempting to register "
337 "global sig; rc = [%d]\n", rc);
338 goto out;
339 }
Michael Halcrow237fead2006-10-04 02:16:22 -0700340 sig_set = 1;
341 break;
Michael Halcrow237fead2006-10-04 02:16:22 -0700342 case ecryptfs_opt_cipher:
343 case ecryptfs_opt_ecryptfs_cipher:
344 cipher_name_src = args[0].from;
345 cipher_name_dst =
346 mount_crypt_stat->
347 global_default_cipher_name;
348 strncpy(cipher_name_dst, cipher_name_src,
349 ECRYPTFS_MAX_CIPHER_NAME_SIZE);
Michael Halcrow87c94c42009-01-06 14:42:01 -0800350 cipher_name_dst[ECRYPTFS_MAX_CIPHER_NAME_SIZE] = '\0';
Michael Halcrow237fead2006-10-04 02:16:22 -0700351 cipher_name_set = 1;
352 break;
353 case ecryptfs_opt_ecryptfs_key_bytes:
354 cipher_key_bytes_src = args[0].from;
355 cipher_key_bytes =
356 (int)simple_strtol(cipher_key_bytes_src,
357 &cipher_key_bytes_src, 0);
358 mount_crypt_stat->global_default_cipher_key_size =
359 cipher_key_bytes;
Michael Halcrow237fead2006-10-04 02:16:22 -0700360 cipher_key_bytes_set = 1;
361 break;
362 case ecryptfs_opt_passthrough:
363 mount_crypt_stat->flags |=
364 ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED;
365 break;
Michael Halcrow17398952007-02-12 00:53:45 -0800366 case ecryptfs_opt_xattr_metadata:
367 mount_crypt_stat->flags |=
368 ECRYPTFS_XATTR_METADATA_ENABLED;
369 break;
370 case ecryptfs_opt_encrypted_view:
371 mount_crypt_stat->flags |=
372 ECRYPTFS_XATTR_METADATA_ENABLED;
373 mount_crypt_stat->flags |=
374 ECRYPTFS_ENCRYPTED_VIEW_ENABLED;
375 break;
Michael Halcrow87c94c42009-01-06 14:42:01 -0800376 case ecryptfs_opt_fnek_sig:
377 fnek_src = args[0].from;
378 fnek_dst =
379 mount_crypt_stat->global_default_fnek_sig;
380 strncpy(fnek_dst, fnek_src, ECRYPTFS_SIG_SIZE_HEX);
381 mount_crypt_stat->global_default_fnek_sig[
382 ECRYPTFS_SIG_SIZE_HEX] = '\0';
383 rc = ecryptfs_add_global_auth_tok(
384 mount_crypt_stat,
Tyler Hicks84814d62009-03-13 13:51:59 -0700385 mount_crypt_stat->global_default_fnek_sig,
386 ECRYPTFS_AUTH_TOK_FNEK);
Michael Halcrow87c94c42009-01-06 14:42:01 -0800387 if (rc) {
388 printk(KERN_ERR "Error attempting to register "
389 "global fnek sig [%s]; rc = [%d]\n",
390 mount_crypt_stat->global_default_fnek_sig,
391 rc);
392 goto out;
393 }
394 mount_crypt_stat->flags |=
395 (ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES
396 | ECRYPTFS_GLOBAL_ENCFN_USE_MOUNT_FNEK);
397 break;
398 case ecryptfs_opt_fn_cipher:
399 fn_cipher_name_src = args[0].from;
400 fn_cipher_name_dst =
401 mount_crypt_stat->global_default_fn_cipher_name;
402 strncpy(fn_cipher_name_dst, fn_cipher_name_src,
403 ECRYPTFS_MAX_CIPHER_NAME_SIZE);
404 mount_crypt_stat->global_default_fn_cipher_name[
405 ECRYPTFS_MAX_CIPHER_NAME_SIZE] = '\0';
406 fn_cipher_name_set = 1;
407 break;
408 case ecryptfs_opt_fn_cipher_key_bytes:
409 fn_cipher_key_bytes_src = args[0].from;
410 fn_cipher_key_bytes =
411 (int)simple_strtol(fn_cipher_key_bytes_src,
412 &fn_cipher_key_bytes_src, 0);
413 mount_crypt_stat->global_default_fn_cipher_key_bytes =
414 fn_cipher_key_bytes;
415 fn_cipher_key_bytes_set = 1;
416 break;
Tyler Hickse77cc8d2009-04-22 04:08:46 -0500417 case ecryptfs_opt_unlink_sigs:
418 mount_crypt_stat->flags |= ECRYPTFS_UNLINK_SIGS;
419 break;
Roberto Sassuf16feb52010-10-06 18:31:32 +0200420 case ecryptfs_opt_mount_auth_tok_only:
421 mount_crypt_stat->flags |=
422 ECRYPTFS_GLOBAL_MOUNT_AUTH_TOK_ONLY;
423 break;
Michael Halcrow237fead2006-10-04 02:16:22 -0700424 case ecryptfs_opt_err:
425 default:
Michael Halcrow87c94c42009-01-06 14:42:01 -0800426 printk(KERN_WARNING
427 "%s: eCryptfs: unrecognized option [%s]\n",
428 __func__, p);
Michael Halcrow237fead2006-10-04 02:16:22 -0700429 }
430 }
Michael Halcrow237fead2006-10-04 02:16:22 -0700431 if (!sig_set) {
432 rc = -EINVAL;
Michael Halcrow956159c2007-10-16 01:27:55 -0700433 ecryptfs_printk(KERN_ERR, "You must supply at least one valid "
434 "auth tok signature as a mount "
Michael Halcrow237fead2006-10-04 02:16:22 -0700435 "parameter; see the eCryptfs README\n");
436 goto out;
437 }
438 if (!cipher_name_set) {
Miklos Szeredi8f236802008-07-23 21:30:05 -0700439 int cipher_name_len = strlen(ECRYPTFS_DEFAULT_CIPHER);
440
441 BUG_ON(cipher_name_len >= ECRYPTFS_MAX_CIPHER_NAME_SIZE);
Miklos Szeredi8f236802008-07-23 21:30:05 -0700442 strcpy(mount_crypt_stat->global_default_cipher_name,
443 ECRYPTFS_DEFAULT_CIPHER);
Michael Halcrow237fead2006-10-04 02:16:22 -0700444 }
Michael Halcrow87c94c42009-01-06 14:42:01 -0800445 if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)
446 && !fn_cipher_name_set)
447 strcpy(mount_crypt_stat->global_default_fn_cipher_name,
448 mount_crypt_stat->global_default_cipher_name);
449 if (!cipher_key_bytes_set)
Michael Halcrowe5d9cbd2006-10-30 22:07:16 -0800450 mount_crypt_stat->global_default_cipher_key_size = 0;
Michael Halcrow87c94c42009-01-06 14:42:01 -0800451 if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)
452 && !fn_cipher_key_bytes_set)
453 mount_crypt_stat->global_default_fn_cipher_key_bytes =
454 mount_crypt_stat->global_default_cipher_key_size;
Eric Sandeenaf440f52008-02-06 01:38:37 -0800455 mutex_lock(&key_tfm_list_mutex);
456 if (!ecryptfs_tfm_exists(mount_crypt_stat->global_default_cipher_name,
Michael Halcrow87c94c42009-01-06 14:42:01 -0800457 NULL)) {
Eric Sandeenaf440f52008-02-06 01:38:37 -0800458 rc = ecryptfs_add_new_key_tfm(
459 NULL, mount_crypt_stat->global_default_cipher_name,
460 mount_crypt_stat->global_default_cipher_key_size);
Michael Halcrow87c94c42009-01-06 14:42:01 -0800461 if (rc) {
462 printk(KERN_ERR "Error attempting to initialize "
463 "cipher with name = [%s] and key size = [%td]; "
464 "rc = [%d]\n",
465 mount_crypt_stat->global_default_cipher_name,
466 mount_crypt_stat->global_default_cipher_key_size,
467 rc);
468 rc = -EINVAL;
469 mutex_unlock(&key_tfm_list_mutex);
470 goto out;
471 }
Michael Halcrow237fead2006-10-04 02:16:22 -0700472 }
Michael Halcrow87c94c42009-01-06 14:42:01 -0800473 if ((mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES)
474 && !ecryptfs_tfm_exists(
475 mount_crypt_stat->global_default_fn_cipher_name, NULL)) {
476 rc = ecryptfs_add_new_key_tfm(
477 NULL, mount_crypt_stat->global_default_fn_cipher_name,
478 mount_crypt_stat->global_default_fn_cipher_key_bytes);
479 if (rc) {
480 printk(KERN_ERR "Error attempting to initialize "
481 "cipher with name = [%s] and key size = [%td]; "
482 "rc = [%d]\n",
483 mount_crypt_stat->global_default_fn_cipher_name,
484 mount_crypt_stat->global_default_fn_cipher_key_bytes,
485 rc);
486 rc = -EINVAL;
487 mutex_unlock(&key_tfm_list_mutex);
488 goto out;
489 }
490 }
491 mutex_unlock(&key_tfm_list_mutex);
Michael Halcrow5dda6992007-10-16 01:28:06 -0700492 rc = ecryptfs_init_global_auth_toks(mount_crypt_stat);
Michael Halcrow87c94c42009-01-06 14:42:01 -0800493 if (rc)
Michael Halcrowf4aad162007-10-16 01:27:53 -0700494 printk(KERN_WARNING "One or more global auth toks could not "
495 "properly register; rc = [%d]\n", rc);
Michael Halcrow237fead2006-10-04 02:16:22 -0700496out:
497 return rc;
498}
499
500struct kmem_cache *ecryptfs_sb_info_cache;
Al Viro44031582010-05-17 00:59:46 -0400501static struct file_system_type ecryptfs_fs_type;
Michael Halcrow237fead2006-10-04 02:16:22 -0700502
503/**
Michael Halcrow237fead2006-10-04 02:16:22 -0700504 * ecryptfs_get_sb
505 * @fs_type
506 * @flags
507 * @dev_name: The path to mount over
508 * @raw_data: The options passed into the kernel
Michael Halcrow237fead2006-10-04 02:16:22 -0700509 */
Al Viro4d143be2010-07-26 13:33:36 +0400510static struct dentry *ecryptfs_mount(struct file_system_type *fs_type, int flags,
511 const char *dev_name, void *raw_data)
Michael Halcrow237fead2006-10-04 02:16:22 -0700512{
Al Viro2ccde7c2010-03-21 12:24:29 -0400513 struct super_block *s;
514 struct ecryptfs_sb_info *sbi;
515 struct ecryptfs_dentry_info *root_info;
516 const char *err = "Getting sb failed";
Al Viro66cb7662011-01-12 20:04:37 -0500517 struct inode *inode;
518 struct path path;
Michael Halcrow237fead2006-10-04 02:16:22 -0700519 int rc;
Michael Halcrow237fead2006-10-04 02:16:22 -0700520
Al Viro2ccde7c2010-03-21 12:24:29 -0400521 sbi = kmem_cache_zalloc(ecryptfs_sb_info_cache, GFP_KERNEL);
522 if (!sbi) {
523 rc = -ENOMEM;
Michael Halcrow237fead2006-10-04 02:16:22 -0700524 goto out;
525 }
Al Viro2ccde7c2010-03-21 12:24:29 -0400526
527 rc = ecryptfs_parse_options(sbi, raw_data);
Michael Halcrow237fead2006-10-04 02:16:22 -0700528 if (rc) {
Al Viro2ccde7c2010-03-21 12:24:29 -0400529 err = "Error parsing options";
530 goto out;
Michael Halcrow237fead2006-10-04 02:16:22 -0700531 }
Al Viro2ccde7c2010-03-21 12:24:29 -0400532
533 s = sget(fs_type, NULL, set_anon_super, NULL);
534 if (IS_ERR(s)) {
535 rc = PTR_ERR(s);
536 goto out;
537 }
538
539 s->s_flags = flags;
540 rc = bdi_setup_and_register(&sbi->bdi, "ecryptfs", BDI_CAP_MAP_COPY);
Al Viro66cb7662011-01-12 20:04:37 -0500541 if (rc)
542 goto out1;
Al Viro2ccde7c2010-03-21 12:24:29 -0400543
544 ecryptfs_set_superblock_private(s, sbi);
545 s->s_bdi = &sbi->bdi;
546
547 /* ->kill_sb() will take care of sbi after that point */
548 sbi = NULL;
549 s->s_op = &ecryptfs_sops;
Al Viro66cb7662011-01-12 20:04:37 -0500550 s->s_d_op = &ecryptfs_dops;
551
552 err = "Reading sb failed";
553 rc = kern_path(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &path);
554 if (rc) {
555 ecryptfs_printk(KERN_WARNING, "kern_path() failed\n");
556 goto out1;
557 }
558 if (path.dentry->d_sb->s_type == &ecryptfs_fs_type) {
559 rc = -EINVAL;
560 printk(KERN_ERR "Mount on filesystem of type "
561 "eCryptfs explicitly disallowed due to "
562 "known incompatibilities\n");
563 goto out_free;
564 }
565 ecryptfs_set_superblock_lower(s, path.dentry->d_sb);
566 s->s_maxbytes = path.dentry->d_sb->s_maxbytes;
567 s->s_blocksize = path.dentry->d_sb->s_blocksize;
568
569 inode = ecryptfs_get_inode(path.dentry->d_inode, s);
570 rc = PTR_ERR(inode);
571 if (IS_ERR(inode))
572 goto out_free;
573
574 s->s_root = d_alloc_root(inode);
575 if (!s->s_root) {
576 iput(inode);
577 rc = -ENOMEM;
578 goto out_free;
579 }
Al Viro2ccde7c2010-03-21 12:24:29 -0400580
581 rc = -ENOMEM;
Al Viro2ccde7c2010-03-21 12:24:29 -0400582 root_info = kmem_cache_zalloc(ecryptfs_dentry_info_cache, GFP_KERNEL);
Al Viro66cb7662011-01-12 20:04:37 -0500583 if (!root_info)
584 goto out_free;
585
Al Viro2ccde7c2010-03-21 12:24:29 -0400586 /* ->kill_sb() will take care of root_info */
587 ecryptfs_set_dentry_private(s->s_root, root_info);
Al Viro66cb7662011-01-12 20:04:37 -0500588 ecryptfs_set_dentry_lower(s->s_root, path.dentry);
589 ecryptfs_set_dentry_lower_mnt(s->s_root, path.mnt);
590
Al Viro2ccde7c2010-03-21 12:24:29 -0400591 s->s_flags |= MS_ACTIVE;
Al Viro4d143be2010-07-26 13:33:36 +0400592 return dget(s->s_root);
Al Viro2ccde7c2010-03-21 12:24:29 -0400593
Al Viro66cb7662011-01-12 20:04:37 -0500594out_free:
595 path_put(&path);
596out1:
597 deactivate_locked_super(s);
Michael Halcrow237fead2006-10-04 02:16:22 -0700598out:
Al Viro2ccde7c2010-03-21 12:24:29 -0400599 if (sbi) {
600 ecryptfs_destroy_mount_crypt_stat(&sbi->mount_crypt_stat);
601 kmem_cache_free(ecryptfs_sb_info_cache, sbi);
602 }
603 printk(KERN_ERR "%s; rc = [%d]\n", err, rc);
Al Viro4d143be2010-07-26 13:33:36 +0400604 return ERR_PTR(rc);
Michael Halcrow237fead2006-10-04 02:16:22 -0700605}
606
607/**
608 * ecryptfs_kill_block_super
609 * @sb: The ecryptfs super block
610 *
611 * Used to bring the superblock down and free the private data.
Michael Halcrow237fead2006-10-04 02:16:22 -0700612 */
613static void ecryptfs_kill_block_super(struct super_block *sb)
614{
Al Virodecabd62010-03-20 22:32:26 -0400615 struct ecryptfs_sb_info *sb_info = ecryptfs_superblock_to_private(sb);
616 kill_anon_super(sb);
617 if (!sb_info)
618 return;
619 ecryptfs_destroy_mount_crypt_stat(&sb_info->mount_crypt_stat);
620 bdi_destroy(&sb_info->bdi);
621 kmem_cache_free(ecryptfs_sb_info_cache, sb_info);
Michael Halcrow237fead2006-10-04 02:16:22 -0700622}
623
624static struct file_system_type ecryptfs_fs_type = {
625 .owner = THIS_MODULE,
626 .name = "ecryptfs",
Al Viro4d143be2010-07-26 13:33:36 +0400627 .mount = ecryptfs_mount,
Michael Halcrow237fead2006-10-04 02:16:22 -0700628 .kill_sb = ecryptfs_kill_block_super,
629 .fs_flags = 0
630};
631
632/**
633 * inode_info_init_once
634 *
635 * Initializes the ecryptfs_inode_info_cache when it is created
636 */
637static void
Alexey Dobriyan51cc5062008-07-25 19:45:34 -0700638inode_info_init_once(void *vptr)
Michael Halcrow237fead2006-10-04 02:16:22 -0700639{
640 struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr;
641
Christoph Lametera35afb82007-05-16 22:10:57 -0700642 inode_init_once(&ei->vfs_inode);
Michael Halcrow237fead2006-10-04 02:16:22 -0700643}
644
645static struct ecryptfs_cache_info {
Christoph Lametere18b8902006-12-06 20:33:20 -0800646 struct kmem_cache **cache;
Michael Halcrow237fead2006-10-04 02:16:22 -0700647 const char *name;
648 size_t size;
Alexey Dobriyan51cc5062008-07-25 19:45:34 -0700649 void (*ctor)(void *obj);
Michael Halcrow237fead2006-10-04 02:16:22 -0700650} ecryptfs_cache_infos[] = {
651 {
652 .cache = &ecryptfs_auth_tok_list_item_cache,
653 .name = "ecryptfs_auth_tok_list_item",
654 .size = sizeof(struct ecryptfs_auth_tok_list_item),
655 },
656 {
657 .cache = &ecryptfs_file_info_cache,
658 .name = "ecryptfs_file_cache",
659 .size = sizeof(struct ecryptfs_file_info),
660 },
661 {
662 .cache = &ecryptfs_dentry_info_cache,
663 .name = "ecryptfs_dentry_info_cache",
664 .size = sizeof(struct ecryptfs_dentry_info),
665 },
666 {
667 .cache = &ecryptfs_inode_info_cache,
668 .name = "ecryptfs_inode_cache",
669 .size = sizeof(struct ecryptfs_inode_info),
670 .ctor = inode_info_init_once,
671 },
672 {
673 .cache = &ecryptfs_sb_info_cache,
674 .name = "ecryptfs_sb_cache",
675 .size = sizeof(struct ecryptfs_sb_info),
676 },
677 {
Michael Halcrow237fead2006-10-04 02:16:22 -0700678 .cache = &ecryptfs_header_cache_1,
679 .name = "ecryptfs_headers_1",
680 .size = PAGE_CACHE_SIZE,
681 },
682 {
683 .cache = &ecryptfs_header_cache_2,
684 .name = "ecryptfs_headers_2",
685 .size = PAGE_CACHE_SIZE,
686 },
687 {
Michael Halcrowdd2a3b72007-02-12 00:53:46 -0800688 .cache = &ecryptfs_xattr_cache,
689 .name = "ecryptfs_xattr_cache",
690 .size = PAGE_CACHE_SIZE,
691 },
692 {
Michael Halcroweb95e7f2007-02-16 01:28:40 -0800693 .cache = &ecryptfs_key_record_cache,
694 .name = "ecryptfs_key_record_cache",
695 .size = sizeof(struct ecryptfs_key_record),
696 },
Michael Halcrow956159c2007-10-16 01:27:55 -0700697 {
698 .cache = &ecryptfs_key_sig_cache,
699 .name = "ecryptfs_key_sig_cache",
700 .size = sizeof(struct ecryptfs_key_sig),
701 },
702 {
703 .cache = &ecryptfs_global_auth_tok_cache,
704 .name = "ecryptfs_global_auth_tok_cache",
705 .size = sizeof(struct ecryptfs_global_auth_tok),
706 },
707 {
708 .cache = &ecryptfs_key_tfm_cache,
709 .name = "ecryptfs_key_tfm_cache",
710 .size = sizeof(struct ecryptfs_key_tfm),
711 },
Michael Halcrow746f1e52008-07-23 21:30:02 -0700712 {
713 .cache = &ecryptfs_open_req_cache,
714 .name = "ecryptfs_open_req_cache",
715 .size = sizeof(struct ecryptfs_open_req),
716 },
Michael Halcrow237fead2006-10-04 02:16:22 -0700717};
718
719static void ecryptfs_free_kmem_caches(void)
720{
721 int i;
722
723 for (i = 0; i < ARRAY_SIZE(ecryptfs_cache_infos); i++) {
724 struct ecryptfs_cache_info *info;
725
726 info = &ecryptfs_cache_infos[i];
727 if (*(info->cache))
728 kmem_cache_destroy(*(info->cache));
729 }
730}
731
732/**
733 * ecryptfs_init_kmem_caches
734 *
735 * Returns zero on success; non-zero otherwise
736 */
737static int ecryptfs_init_kmem_caches(void)
738{
739 int i;
740
741 for (i = 0; i < ARRAY_SIZE(ecryptfs_cache_infos); i++) {
742 struct ecryptfs_cache_info *info;
743
744 info = &ecryptfs_cache_infos[i];
745 *(info->cache) = kmem_cache_create(info->name, info->size,
Paul Mundt20c2df82007-07-20 10:11:58 +0900746 0, SLAB_HWCACHE_ALIGN, info->ctor);
Michael Halcrow237fead2006-10-04 02:16:22 -0700747 if (!*(info->cache)) {
748 ecryptfs_free_kmem_caches();
749 ecryptfs_printk(KERN_WARNING, "%s: "
750 "kmem_cache_create failed\n",
751 info->name);
752 return -ENOMEM;
753 }
754 }
755 return 0;
756}
757
Greg Kroah-Hartman6e90aa92007-11-06 15:08:08 -0800758static struct kobject *ecryptfs_kobj;
Michael Halcrow237fead2006-10-04 02:16:22 -0700759
Kay Sievers386f2752007-11-02 13:47:53 +0100760static ssize_t version_show(struct kobject *kobj,
761 struct kobj_attribute *attr, char *buff)
Michael Halcrow237fead2006-10-04 02:16:22 -0700762{
763 return snprintf(buff, PAGE_SIZE, "%d\n", ECRYPTFS_VERSIONING_MASK);
764}
765
Kay Sievers386f2752007-11-02 13:47:53 +0100766static struct kobj_attribute version_attr = __ATTR_RO(version);
Michael Halcrow237fead2006-10-04 02:16:22 -0700767
Greg Kroah-Hartman30a468b2007-10-15 15:01:24 -0700768static struct attribute *attributes[] = {
769 &version_attr.attr,
Greg Kroah-Hartman30a468b2007-10-15 15:01:24 -0700770 NULL,
771};
772
773static struct attribute_group attr_group = {
774 .attrs = attributes,
775};
Michael Halcrow237fead2006-10-04 02:16:22 -0700776
777static int do_sysfs_registration(void)
778{
779 int rc;
780
Greg Kroah-Hartman6e90aa92007-11-06 15:08:08 -0800781 ecryptfs_kobj = kobject_create_and_add("ecryptfs", fs_kobj);
782 if (!ecryptfs_kobj) {
Greg Kroah-Hartman917e8652007-10-29 20:13:17 +0100783 printk(KERN_ERR "Unable to create ecryptfs kset\n");
784 rc = -ENOMEM;
Michael Halcrow237fead2006-10-04 02:16:22 -0700785 goto out;
786 }
Greg Kroah-Hartman6e90aa92007-11-06 15:08:08 -0800787 rc = sysfs_create_group(ecryptfs_kobj, &attr_group);
Michael Halcrow237fead2006-10-04 02:16:22 -0700788 if (rc) {
789 printk(KERN_ERR
Greg Kroah-Hartman30a468b2007-10-15 15:01:24 -0700790 "Unable to create ecryptfs version attributes\n");
Greg Kroah-Hartman197b12d2007-12-20 08:13:05 -0800791 kobject_put(ecryptfs_kobj);
Michael Halcrow237fead2006-10-04 02:16:22 -0700792 }
793out:
794 return rc;
795}
796
Ryusuke Konishia75de1b2007-08-10 13:00:56 -0700797static void do_sysfs_unregistration(void)
798{
Greg Kroah-Hartman6e90aa92007-11-06 15:08:08 -0800799 sysfs_remove_group(ecryptfs_kobj, &attr_group);
Greg Kroah-Hartman197b12d2007-12-20 08:13:05 -0800800 kobject_put(ecryptfs_kobj);
Ryusuke Konishia75de1b2007-08-10 13:00:56 -0700801}
802
Michael Halcrow237fead2006-10-04 02:16:22 -0700803static int __init ecryptfs_init(void)
804{
805 int rc;
806
807 if (ECRYPTFS_DEFAULT_EXTENT_SIZE > PAGE_CACHE_SIZE) {
808 rc = -EINVAL;
809 ecryptfs_printk(KERN_ERR, "The eCryptfs extent size is "
810 "larger than the host's page size, and so "
811 "eCryptfs cannot run on this system. The "
812 "default eCryptfs extent size is [%d] bytes; "
813 "the page size is [%d] bytes.\n",
814 ECRYPTFS_DEFAULT_EXTENT_SIZE, PAGE_CACHE_SIZE);
815 goto out;
816 }
817 rc = ecryptfs_init_kmem_caches();
818 if (rc) {
819 printk(KERN_ERR
820 "Failed to allocate one or more kmem_cache objects\n");
821 goto out;
822 }
823 rc = register_filesystem(&ecryptfs_fs_type);
824 if (rc) {
825 printk(KERN_ERR "Failed to register filesystem\n");
Michael Halcrowcf81f892007-10-16 01:28:07 -0700826 goto out_free_kmem_caches;
Michael Halcrow237fead2006-10-04 02:16:22 -0700827 }
Michael Halcrow237fead2006-10-04 02:16:22 -0700828 rc = do_sysfs_registration();
829 if (rc) {
830 printk(KERN_ERR "sysfs registration failed\n");
Michael Halcrowcf81f892007-10-16 01:28:07 -0700831 goto out_unregister_filesystem;
Michael Halcrow237fead2006-10-04 02:16:22 -0700832 }
Michael Halcrow746f1e52008-07-23 21:30:02 -0700833 rc = ecryptfs_init_kthread();
834 if (rc) {
835 printk(KERN_ERR "%s: kthread initialization failed; "
836 "rc = [%d]\n", __func__, rc);
837 goto out_do_sysfs_unregistration;
838 }
Tyler Hicks624ae522008-10-15 22:02:51 -0700839 rc = ecryptfs_init_messaging();
Michael Halcrowdddfa462007-02-12 00:53:44 -0800840 if (rc) {
Michael Halcrow746f1e52008-07-23 21:30:02 -0700841 printk(KERN_ERR "Failure occured while attempting to "
Tyler Hicks624ae522008-10-15 22:02:51 -0700842 "initialize the communications channel to "
843 "ecryptfsd\n");
Michael Halcrow746f1e52008-07-23 21:30:02 -0700844 goto out_destroy_kthread;
Michael Halcrow956159c2007-10-16 01:27:55 -0700845 }
846 rc = ecryptfs_init_crypto();
847 if (rc) {
848 printk(KERN_ERR "Failure whilst attempting to init crypto; "
849 "rc = [%d]\n", rc);
Michael Halcrowcf81f892007-10-16 01:28:07 -0700850 goto out_release_messaging;
Michael Halcrowdddfa462007-02-12 00:53:44 -0800851 }
Eric Sandeen2830bfd2008-02-06 01:38:34 -0800852 if (ecryptfs_verbosity > 0)
853 printk(KERN_CRIT "eCryptfs verbosity set to %d. Secret values "
854 "will be written to the syslog!\n", ecryptfs_verbosity);
855
Michael Halcrowcf81f892007-10-16 01:28:07 -0700856 goto out;
857out_release_messaging:
Tyler Hicks624ae522008-10-15 22:02:51 -0700858 ecryptfs_release_messaging();
Michael Halcrow746f1e52008-07-23 21:30:02 -0700859out_destroy_kthread:
860 ecryptfs_destroy_kthread();
Michael Halcrowcf81f892007-10-16 01:28:07 -0700861out_do_sysfs_unregistration:
862 do_sysfs_unregistration();
863out_unregister_filesystem:
864 unregister_filesystem(&ecryptfs_fs_type);
865out_free_kmem_caches:
866 ecryptfs_free_kmem_caches();
Michael Halcrow237fead2006-10-04 02:16:22 -0700867out:
868 return rc;
869}
870
871static void __exit ecryptfs_exit(void)
872{
Michael Halcrowcf81f892007-10-16 01:28:07 -0700873 int rc;
874
875 rc = ecryptfs_destroy_crypto();
876 if (rc)
877 printk(KERN_ERR "Failure whilst attempting to destroy crypto; "
878 "rc = [%d]\n", rc);
Tyler Hicks624ae522008-10-15 22:02:51 -0700879 ecryptfs_release_messaging();
Michael Halcrow746f1e52008-07-23 21:30:02 -0700880 ecryptfs_destroy_kthread();
Michael Halcrowcf81f892007-10-16 01:28:07 -0700881 do_sysfs_unregistration();
Michael Halcrow237fead2006-10-04 02:16:22 -0700882 unregister_filesystem(&ecryptfs_fs_type);
883 ecryptfs_free_kmem_caches();
884}
885
886MODULE_AUTHOR("Michael A. Halcrow <mhalcrow@us.ibm.com>");
887MODULE_DESCRIPTION("eCryptfs");
888
889MODULE_LICENSE("GPL");
890
891module_init(ecryptfs_init)
892module_exit(ecryptfs_exit)