inode.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150
  1. /**
  2. * eCryptfs: Linux filesystem encryption layer
  3. *
  4. * Copyright (C) 1997-2004 Erez Zadok
  5. * Copyright (C) 2001-2004 Stony Brook University
  6. * Copyright (C) 2004-2007 International Business Machines Corp.
  7. * Author(s): Michael A. Halcrow <mahalcro@us.ibm.com>
  8. * Michael C. Thompsion <mcthomps@us.ibm.com>
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of the
  13. * License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  23. * 02111-1307, USA.
  24. */
  25. #include <linux/file.h>
  26. #include <linux/vmalloc.h>
  27. #include <linux/pagemap.h>
  28. #include <linux/dcache.h>
  29. #include <linux/namei.h>
  30. #include <linux/mount.h>
  31. #include <linux/fs_stack.h>
  32. #include <linux/slab.h>
  33. #include <linux/xattr.h>
  34. #include <asm/unaligned.h>
  35. #include "ecryptfs_kernel.h"
  36. static struct dentry *lock_parent(struct dentry *dentry)
  37. {
  38. struct dentry *dir;
  39. dir = dget_parent(dentry);
  40. inode_lock_nested(d_inode(dir), I_MUTEX_PARENT);
  41. return dir;
  42. }
  43. static void unlock_dir(struct dentry *dir)
  44. {
  45. inode_unlock(d_inode(dir));
  46. dput(dir);
  47. }
  48. static int ecryptfs_inode_test(struct inode *inode, void *lower_inode)
  49. {
  50. return ecryptfs_inode_to_lower(inode) == lower_inode;
  51. }
  52. static int ecryptfs_inode_set(struct inode *inode, void *opaque)
  53. {
  54. struct inode *lower_inode = opaque;
  55. ecryptfs_set_inode_lower(inode, lower_inode);
  56. fsstack_copy_attr_all(inode, lower_inode);
  57. /* i_size will be overwritten for encrypted regular files */
  58. fsstack_copy_inode_size(inode, lower_inode);
  59. inode->i_ino = lower_inode->i_ino;
  60. inode->i_mapping->a_ops = &ecryptfs_aops;
  61. if (S_ISLNK(inode->i_mode))
  62. inode->i_op = &ecryptfs_symlink_iops;
  63. else if (S_ISDIR(inode->i_mode))
  64. inode->i_op = &ecryptfs_dir_iops;
  65. else
  66. inode->i_op = &ecryptfs_main_iops;
  67. if (S_ISDIR(inode->i_mode))
  68. inode->i_fop = &ecryptfs_dir_fops;
  69. else if (special_file(inode->i_mode))
  70. init_special_inode(inode, inode->i_mode, inode->i_rdev);
  71. else
  72. inode->i_fop = &ecryptfs_main_fops;
  73. return 0;
  74. }
  75. static struct inode *__ecryptfs_get_inode(struct inode *lower_inode,
  76. struct super_block *sb)
  77. {
  78. struct inode *inode;
  79. if (lower_inode->i_sb != ecryptfs_superblock_to_lower(sb))
  80. return ERR_PTR(-EXDEV);
  81. if (!igrab(lower_inode))
  82. return ERR_PTR(-ESTALE);
  83. inode = iget5_locked(sb, (unsigned long)lower_inode,
  84. ecryptfs_inode_test, ecryptfs_inode_set,
  85. lower_inode);
  86. if (!inode) {
  87. iput(lower_inode);
  88. return ERR_PTR(-EACCES);
  89. }
  90. if (!(inode->i_state & I_NEW))
  91. iput(lower_inode);
  92. return inode;
  93. }
  94. struct inode *ecryptfs_get_inode(struct inode *lower_inode,
  95. struct super_block *sb)
  96. {
  97. struct inode *inode = __ecryptfs_get_inode(lower_inode, sb);
  98. if (!IS_ERR(inode) && (inode->i_state & I_NEW))
  99. unlock_new_inode(inode);
  100. return inode;
  101. }
  102. /**
  103. * ecryptfs_interpose
  104. * @lower_dentry: Existing dentry in the lower filesystem
  105. * @dentry: ecryptfs' dentry
  106. * @sb: ecryptfs's super_block
  107. *
  108. * Interposes upper and lower dentries.
  109. *
  110. * Returns zero on success; non-zero otherwise
  111. */
  112. static int ecryptfs_interpose(struct dentry *lower_dentry,
  113. struct dentry *dentry, struct super_block *sb)
  114. {
  115. struct inode *inode = ecryptfs_get_inode(d_inode(lower_dentry), sb);
  116. if (IS_ERR(inode))
  117. return PTR_ERR(inode);
  118. d_instantiate(dentry, inode);
  119. return 0;
  120. }
  121. static int ecryptfs_do_unlink(struct inode *dir, struct dentry *dentry,
  122. struct inode *inode)
  123. {
  124. struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
  125. struct inode *lower_dir_inode = ecryptfs_inode_to_lower(dir);
  126. struct dentry *lower_dir_dentry;
  127. int rc;
  128. dget(lower_dentry);
  129. lower_dir_dentry = lock_parent(lower_dentry);
  130. rc = vfs_unlink(lower_dir_inode, lower_dentry, NULL);
  131. if (rc) {
  132. printk(KERN_ERR "Error in vfs_unlink; rc = [%d]\n", rc);
  133. goto out_unlock;
  134. }
  135. fsstack_copy_attr_times(dir, lower_dir_inode);
  136. set_nlink(inode, ecryptfs_inode_to_lower(inode)->i_nlink);
  137. inode->i_ctime = dir->i_ctime;
  138. d_drop(dentry);
  139. out_unlock:
  140. unlock_dir(lower_dir_dentry);
  141. dput(lower_dentry);
  142. return rc;
  143. }
  144. /**
  145. * ecryptfs_do_create
  146. * @directory_inode: inode of the new file's dentry's parent in ecryptfs
  147. * @ecryptfs_dentry: New file's dentry in ecryptfs
  148. * @mode: The mode of the new file
  149. *
  150. * Creates the underlying file and the eCryptfs inode which will link to
  151. * it. It will also update the eCryptfs directory inode to mimic the
  152. * stat of the lower directory inode.
  153. *
  154. * Returns the new eCryptfs inode on success; an ERR_PTR on error condition
  155. */
  156. static struct inode *
  157. ecryptfs_do_create(struct inode *directory_inode,
  158. struct dentry *ecryptfs_dentry, umode_t mode)
  159. {
  160. int rc;
  161. struct dentry *lower_dentry;
  162. struct dentry *lower_dir_dentry;
  163. struct inode *inode;
  164. lower_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry);
  165. lower_dir_dentry = lock_parent(lower_dentry);
  166. rc = vfs_create(d_inode(lower_dir_dentry), lower_dentry, mode, true);
  167. if (rc) {
  168. printk(KERN_ERR "%s: Failure to create dentry in lower fs; "
  169. "rc = [%d]\n", __func__, rc);
  170. inode = ERR_PTR(rc);
  171. goto out_lock;
  172. }
  173. inode = __ecryptfs_get_inode(d_inode(lower_dentry),
  174. directory_inode->i_sb);
  175. if (IS_ERR(inode)) {
  176. vfs_unlink(d_inode(lower_dir_dentry), lower_dentry, NULL);
  177. goto out_lock;
  178. }
  179. fsstack_copy_attr_times(directory_inode, d_inode(lower_dir_dentry));
  180. fsstack_copy_inode_size(directory_inode, d_inode(lower_dir_dentry));
  181. out_lock:
  182. unlock_dir(lower_dir_dentry);
  183. return inode;
  184. }
  185. /**
  186. * ecryptfs_initialize_file
  187. *
  188. * Cause the file to be changed from a basic empty file to an ecryptfs
  189. * file with a header and first data page.
  190. *
  191. * Returns zero on success
  192. */
  193. int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,
  194. struct inode *ecryptfs_inode)
  195. {
  196. struct ecryptfs_crypt_stat *crypt_stat =
  197. &ecryptfs_inode_to_private(ecryptfs_inode)->crypt_stat;
  198. int rc = 0;
  199. if (S_ISDIR(ecryptfs_inode->i_mode)) {
  200. ecryptfs_printk(KERN_DEBUG, "This is a directory\n");
  201. crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
  202. goto out;
  203. }
  204. ecryptfs_printk(KERN_DEBUG, "Initializing crypto context\n");
  205. rc = ecryptfs_new_file_context(ecryptfs_inode);
  206. if (rc) {
  207. ecryptfs_printk(KERN_ERR, "Error creating new file "
  208. "context; rc = [%d]\n", rc);
  209. goto out;
  210. }
  211. rc = ecryptfs_get_lower_file(ecryptfs_dentry, ecryptfs_inode);
  212. if (rc) {
  213. printk(KERN_ERR "%s: Error attempting to initialize "
  214. "the lower file for the dentry with name "
  215. "[%pd]; rc = [%d]\n", __func__,
  216. ecryptfs_dentry, rc);
  217. goto out;
  218. }
  219. rc = ecryptfs_write_metadata(ecryptfs_dentry, ecryptfs_inode);
  220. if (rc)
  221. printk(KERN_ERR "Error writing headers; rc = [%d]\n", rc);
  222. ecryptfs_put_lower_file(ecryptfs_inode);
  223. out:
  224. return rc;
  225. }
  226. /**
  227. * ecryptfs_create
  228. * @dir: The inode of the directory in which to create the file.
  229. * @dentry: The eCryptfs dentry
  230. * @mode: The mode of the new file.
  231. *
  232. * Creates a new file.
  233. *
  234. * Returns zero on success; non-zero on error condition
  235. */
  236. static int
  237. ecryptfs_create(struct inode *directory_inode, struct dentry *ecryptfs_dentry,
  238. umode_t mode, bool excl)
  239. {
  240. struct inode *ecryptfs_inode;
  241. int rc;
  242. ecryptfs_inode = ecryptfs_do_create(directory_inode, ecryptfs_dentry,
  243. mode);
  244. if (IS_ERR(ecryptfs_inode)) {
  245. ecryptfs_printk(KERN_WARNING, "Failed to create file in"
  246. "lower filesystem\n");
  247. rc = PTR_ERR(ecryptfs_inode);
  248. goto out;
  249. }
  250. /* At this point, a file exists on "disk"; we need to make sure
  251. * that this on disk file is prepared to be an ecryptfs file */
  252. rc = ecryptfs_initialize_file(ecryptfs_dentry, ecryptfs_inode);
  253. if (rc) {
  254. ecryptfs_do_unlink(directory_inode, ecryptfs_dentry,
  255. ecryptfs_inode);
  256. iget_failed(ecryptfs_inode);
  257. goto out;
  258. }
  259. d_instantiate_new(ecryptfs_dentry, ecryptfs_inode);
  260. out:
  261. return rc;
  262. }
  263. static int ecryptfs_i_size_read(struct dentry *dentry, struct inode *inode)
  264. {
  265. struct ecryptfs_crypt_stat *crypt_stat;
  266. int rc;
  267. rc = ecryptfs_get_lower_file(dentry, inode);
  268. if (rc) {
  269. printk(KERN_ERR "%s: Error attempting to initialize "
  270. "the lower file for the dentry with name "
  271. "[%pd]; rc = [%d]\n", __func__,
  272. dentry, rc);
  273. return rc;
  274. }
  275. crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
  276. /* TODO: lock for crypt_stat comparison */
  277. if (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED))
  278. ecryptfs_set_default_sizes(crypt_stat);
  279. rc = ecryptfs_read_and_validate_header_region(inode);
  280. ecryptfs_put_lower_file(inode);
  281. if (rc) {
  282. rc = ecryptfs_read_and_validate_xattr_region(dentry, inode);
  283. if (!rc)
  284. crypt_stat->flags |= ECRYPTFS_METADATA_IN_XATTR;
  285. }
  286. /* Must return 0 to allow non-eCryptfs files to be looked up, too */
  287. return 0;
  288. }
  289. /**
  290. * ecryptfs_lookup_interpose - Dentry interposition for a lookup
  291. */
  292. static struct dentry *ecryptfs_lookup_interpose(struct dentry *dentry,
  293. struct dentry *lower_dentry)
  294. {
  295. struct path *path = ecryptfs_dentry_to_lower_path(dentry->d_parent);
  296. struct inode *inode, *lower_inode;
  297. struct ecryptfs_dentry_info *dentry_info;
  298. int rc = 0;
  299. dentry_info = kmem_cache_alloc(ecryptfs_dentry_info_cache, GFP_KERNEL);
  300. if (!dentry_info) {
  301. dput(lower_dentry);
  302. return ERR_PTR(-ENOMEM);
  303. }
  304. fsstack_copy_attr_atime(d_inode(dentry->d_parent),
  305. d_inode(path->dentry));
  306. BUG_ON(!d_count(lower_dentry));
  307. ecryptfs_set_dentry_private(dentry, dentry_info);
  308. dentry_info->lower_path.mnt = mntget(path->mnt);
  309. dentry_info->lower_path.dentry = lower_dentry;
  310. /*
  311. * negative dentry can go positive under us here - its parent is not
  312. * locked. That's OK and that could happen just as we return from
  313. * ecryptfs_lookup() anyway. Just need to be careful and fetch
  314. * ->d_inode only once - it's not stable here.
  315. */
  316. lower_inode = READ_ONCE(lower_dentry->d_inode);
  317. if (!lower_inode) {
  318. /* We want to add because we couldn't find in lower */
  319. d_add(dentry, NULL);
  320. return NULL;
  321. }
  322. inode = __ecryptfs_get_inode(lower_inode, dentry->d_sb);
  323. if (IS_ERR(inode)) {
  324. printk(KERN_ERR "%s: Error interposing; rc = [%ld]\n",
  325. __func__, PTR_ERR(inode));
  326. return ERR_CAST(inode);
  327. }
  328. if (S_ISREG(inode->i_mode)) {
  329. rc = ecryptfs_i_size_read(dentry, inode);
  330. if (rc) {
  331. make_bad_inode(inode);
  332. return ERR_PTR(rc);
  333. }
  334. }
  335. if (inode->i_state & I_NEW)
  336. unlock_new_inode(inode);
  337. return d_splice_alias(inode, dentry);
  338. }
  339. /**
  340. * ecryptfs_lookup
  341. * @ecryptfs_dir_inode: The eCryptfs directory inode
  342. * @ecryptfs_dentry: The eCryptfs dentry that we are looking up
  343. * @flags: lookup flags
  344. *
  345. * Find a file on disk. If the file does not exist, then we'll add it to the
  346. * dentry cache and continue on to read it from the disk.
  347. */
  348. static struct dentry *ecryptfs_lookup(struct inode *ecryptfs_dir_inode,
  349. struct dentry *ecryptfs_dentry,
  350. unsigned int flags)
  351. {
  352. char *encrypted_and_encoded_name = NULL;
  353. struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
  354. struct dentry *lower_dir_dentry, *lower_dentry;
  355. const char *name = ecryptfs_dentry->d_name.name;
  356. size_t len = ecryptfs_dentry->d_name.len;
  357. struct dentry *res;
  358. int rc = 0;
  359. lower_dir_dentry = ecryptfs_dentry_to_lower(ecryptfs_dentry->d_parent);
  360. mount_crypt_stat = &ecryptfs_superblock_to_private(
  361. ecryptfs_dentry->d_sb)->mount_crypt_stat;
  362. if (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) {
  363. rc = ecryptfs_encrypt_and_encode_filename(
  364. &encrypted_and_encoded_name, &len,
  365. mount_crypt_stat, name, len);
  366. if (rc) {
  367. printk(KERN_ERR "%s: Error attempting to encrypt and encode "
  368. "filename; rc = [%d]\n", __func__, rc);
  369. return ERR_PTR(rc);
  370. }
  371. name = encrypted_and_encoded_name;
  372. }
  373. lower_dentry = lookup_one_len_unlocked(name, lower_dir_dentry, len);
  374. if (IS_ERR(lower_dentry)) {
  375. ecryptfs_printk(KERN_DEBUG, "%s: lookup_one_len() returned "
  376. "[%ld] on lower_dentry = [%s]\n", __func__,
  377. PTR_ERR(lower_dentry),
  378. name);
  379. res = ERR_CAST(lower_dentry);
  380. } else {
  381. res = ecryptfs_lookup_interpose(ecryptfs_dentry, lower_dentry);
  382. }
  383. kfree(encrypted_and_encoded_name);
  384. return res;
  385. }
  386. static int ecryptfs_link(struct dentry *old_dentry, struct inode *dir,
  387. struct dentry *new_dentry)
  388. {
  389. struct dentry *lower_old_dentry;
  390. struct dentry *lower_new_dentry;
  391. struct dentry *lower_dir_dentry;
  392. u64 file_size_save;
  393. int rc;
  394. file_size_save = i_size_read(d_inode(old_dentry));
  395. lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
  396. lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
  397. dget(lower_old_dentry);
  398. dget(lower_new_dentry);
  399. lower_dir_dentry = lock_parent(lower_new_dentry);
  400. rc = vfs_link(lower_old_dentry, d_inode(lower_dir_dentry),
  401. lower_new_dentry, NULL);
  402. if (rc || d_really_is_negative(lower_new_dentry))
  403. goto out_lock;
  404. rc = ecryptfs_interpose(lower_new_dentry, new_dentry, dir->i_sb);
  405. if (rc)
  406. goto out_lock;
  407. fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
  408. fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry));
  409. set_nlink(d_inode(old_dentry),
  410. ecryptfs_inode_to_lower(d_inode(old_dentry))->i_nlink);
  411. i_size_write(d_inode(new_dentry), file_size_save);
  412. out_lock:
  413. unlock_dir(lower_dir_dentry);
  414. dput(lower_new_dentry);
  415. dput(lower_old_dentry);
  416. return rc;
  417. }
  418. static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
  419. {
  420. return ecryptfs_do_unlink(dir, dentry, d_inode(dentry));
  421. }
  422. static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry,
  423. const char *symname)
  424. {
  425. int rc;
  426. struct dentry *lower_dentry;
  427. struct dentry *lower_dir_dentry;
  428. char *encoded_symname;
  429. size_t encoded_symlen;
  430. struct ecryptfs_mount_crypt_stat *mount_crypt_stat = NULL;
  431. lower_dentry = ecryptfs_dentry_to_lower(dentry);
  432. dget(lower_dentry);
  433. lower_dir_dentry = lock_parent(lower_dentry);
  434. mount_crypt_stat = &ecryptfs_superblock_to_private(
  435. dir->i_sb)->mount_crypt_stat;
  436. rc = ecryptfs_encrypt_and_encode_filename(&encoded_symname,
  437. &encoded_symlen,
  438. mount_crypt_stat, symname,
  439. strlen(symname));
  440. if (rc)
  441. goto out_lock;
  442. rc = vfs_symlink(d_inode(lower_dir_dentry), lower_dentry,
  443. encoded_symname);
  444. kfree(encoded_symname);
  445. if (rc || d_really_is_negative(lower_dentry))
  446. goto out_lock;
  447. rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
  448. if (rc)
  449. goto out_lock;
  450. fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
  451. fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry));
  452. out_lock:
  453. unlock_dir(lower_dir_dentry);
  454. dput(lower_dentry);
  455. if (d_really_is_negative(dentry))
  456. d_drop(dentry);
  457. return rc;
  458. }
  459. static int ecryptfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
  460. {
  461. int rc;
  462. struct dentry *lower_dentry;
  463. struct dentry *lower_dir_dentry;
  464. lower_dentry = ecryptfs_dentry_to_lower(dentry);
  465. lower_dir_dentry = lock_parent(lower_dentry);
  466. rc = vfs_mkdir(d_inode(lower_dir_dentry), lower_dentry, mode);
  467. if (rc || d_really_is_negative(lower_dentry))
  468. goto out;
  469. rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
  470. if (rc)
  471. goto out;
  472. fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
  473. fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry));
  474. set_nlink(dir, d_inode(lower_dir_dentry)->i_nlink);
  475. out:
  476. unlock_dir(lower_dir_dentry);
  477. if (d_really_is_negative(dentry))
  478. d_drop(dentry);
  479. return rc;
  480. }
  481. static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
  482. {
  483. struct dentry *lower_dentry;
  484. struct dentry *lower_dir_dentry;
  485. int rc;
  486. lower_dentry = ecryptfs_dentry_to_lower(dentry);
  487. dget(dentry);
  488. lower_dir_dentry = lock_parent(lower_dentry);
  489. dget(lower_dentry);
  490. rc = vfs_rmdir(d_inode(lower_dir_dentry), lower_dentry);
  491. dput(lower_dentry);
  492. if (!rc && d_really_is_positive(dentry))
  493. clear_nlink(d_inode(dentry));
  494. fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
  495. set_nlink(dir, d_inode(lower_dir_dentry)->i_nlink);
  496. unlock_dir(lower_dir_dentry);
  497. if (!rc)
  498. d_drop(dentry);
  499. dput(dentry);
  500. return rc;
  501. }
  502. static int
  503. ecryptfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
  504. {
  505. int rc;
  506. struct dentry *lower_dentry;
  507. struct dentry *lower_dir_dentry;
  508. lower_dentry = ecryptfs_dentry_to_lower(dentry);
  509. lower_dir_dentry = lock_parent(lower_dentry);
  510. rc = vfs_mknod(d_inode(lower_dir_dentry), lower_dentry, mode, dev);
  511. if (rc || d_really_is_negative(lower_dentry))
  512. goto out;
  513. rc = ecryptfs_interpose(lower_dentry, dentry, dir->i_sb);
  514. if (rc)
  515. goto out;
  516. fsstack_copy_attr_times(dir, d_inode(lower_dir_dentry));
  517. fsstack_copy_inode_size(dir, d_inode(lower_dir_dentry));
  518. out:
  519. unlock_dir(lower_dir_dentry);
  520. if (d_really_is_negative(dentry))
  521. d_drop(dentry);
  522. return rc;
  523. }
  524. static int
  525. ecryptfs_rename(struct inode *old_dir, struct dentry *old_dentry,
  526. struct inode *new_dir, struct dentry *new_dentry,
  527. unsigned int flags)
  528. {
  529. int rc;
  530. struct dentry *lower_old_dentry;
  531. struct dentry *lower_new_dentry;
  532. struct dentry *lower_old_dir_dentry;
  533. struct dentry *lower_new_dir_dentry;
  534. struct dentry *trap = NULL;
  535. struct inode *target_inode;
  536. if (flags)
  537. return -EINVAL;
  538. lower_old_dentry = ecryptfs_dentry_to_lower(old_dentry);
  539. lower_new_dentry = ecryptfs_dentry_to_lower(new_dentry);
  540. dget(lower_old_dentry);
  541. dget(lower_new_dentry);
  542. lower_old_dir_dentry = dget_parent(lower_old_dentry);
  543. lower_new_dir_dentry = dget_parent(lower_new_dentry);
  544. target_inode = d_inode(new_dentry);
  545. trap = lock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
  546. /* source should not be ancestor of target */
  547. if (trap == lower_old_dentry) {
  548. rc = -EINVAL;
  549. goto out_lock;
  550. }
  551. /* target should not be ancestor of source */
  552. if (trap == lower_new_dentry) {
  553. rc = -ENOTEMPTY;
  554. goto out_lock;
  555. }
  556. rc = vfs_rename(d_inode(lower_old_dir_dentry), lower_old_dentry,
  557. d_inode(lower_new_dir_dentry), lower_new_dentry,
  558. NULL, 0);
  559. if (rc)
  560. goto out_lock;
  561. if (target_inode)
  562. fsstack_copy_attr_all(target_inode,
  563. ecryptfs_inode_to_lower(target_inode));
  564. fsstack_copy_attr_all(new_dir, d_inode(lower_new_dir_dentry));
  565. if (new_dir != old_dir)
  566. fsstack_copy_attr_all(old_dir, d_inode(lower_old_dir_dentry));
  567. out_lock:
  568. unlock_rename(lower_old_dir_dentry, lower_new_dir_dentry);
  569. dput(lower_new_dir_dentry);
  570. dput(lower_old_dir_dentry);
  571. dput(lower_new_dentry);
  572. dput(lower_old_dentry);
  573. return rc;
  574. }
  575. static char *ecryptfs_readlink_lower(struct dentry *dentry, size_t *bufsiz)
  576. {
  577. DEFINE_DELAYED_CALL(done);
  578. struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
  579. const char *link;
  580. char *buf;
  581. int rc;
  582. link = vfs_get_link(lower_dentry, &done);
  583. if (IS_ERR(link))
  584. return ERR_CAST(link);
  585. rc = ecryptfs_decode_and_decrypt_filename(&buf, bufsiz, dentry->d_sb,
  586. link, strlen(link));
  587. do_delayed_call(&done);
  588. if (rc)
  589. return ERR_PTR(rc);
  590. return buf;
  591. }
  592. static const char *ecryptfs_get_link(struct dentry *dentry,
  593. struct inode *inode,
  594. struct delayed_call *done)
  595. {
  596. size_t len;
  597. char *buf;
  598. if (!dentry)
  599. return ERR_PTR(-ECHILD);
  600. buf = ecryptfs_readlink_lower(dentry, &len);
  601. if (IS_ERR(buf))
  602. return buf;
  603. fsstack_copy_attr_atime(d_inode(dentry),
  604. d_inode(ecryptfs_dentry_to_lower(dentry)));
  605. buf[len] = '\0';
  606. set_delayed_call(done, kfree_link, buf);
  607. return buf;
  608. }
  609. /**
  610. * upper_size_to_lower_size
  611. * @crypt_stat: Crypt_stat associated with file
  612. * @upper_size: Size of the upper file
  613. *
  614. * Calculate the required size of the lower file based on the
  615. * specified size of the upper file. This calculation is based on the
  616. * number of headers in the underlying file and the extent size.
  617. *
  618. * Returns Calculated size of the lower file.
  619. */
  620. static loff_t
  621. upper_size_to_lower_size(struct ecryptfs_crypt_stat *crypt_stat,
  622. loff_t upper_size)
  623. {
  624. loff_t lower_size;
  625. lower_size = ecryptfs_lower_header_size(crypt_stat);
  626. if (upper_size != 0) {
  627. loff_t num_extents;
  628. num_extents = upper_size >> crypt_stat->extent_shift;
  629. if (upper_size & ~crypt_stat->extent_mask)
  630. num_extents++;
  631. lower_size += (num_extents * crypt_stat->extent_size);
  632. }
  633. return lower_size;
  634. }
  635. /**
  636. * truncate_upper
  637. * @dentry: The ecryptfs layer dentry
  638. * @ia: Address of the ecryptfs inode's attributes
  639. * @lower_ia: Address of the lower inode's attributes
  640. *
  641. * Function to handle truncations modifying the size of the file. Note
  642. * that the file sizes are interpolated. When expanding, we are simply
  643. * writing strings of 0's out. When truncating, we truncate the upper
  644. * inode and update the lower_ia according to the page index
  645. * interpolations. If ATTR_SIZE is set in lower_ia->ia_valid upon return,
  646. * the caller must use lower_ia in a call to notify_change() to perform
  647. * the truncation of the lower inode.
  648. *
  649. * Returns zero on success; non-zero otherwise
  650. */
  651. static int truncate_upper(struct dentry *dentry, struct iattr *ia,
  652. struct iattr *lower_ia)
  653. {
  654. int rc = 0;
  655. struct inode *inode = d_inode(dentry);
  656. struct ecryptfs_crypt_stat *crypt_stat;
  657. loff_t i_size = i_size_read(inode);
  658. loff_t lower_size_before_truncate;
  659. loff_t lower_size_after_truncate;
  660. if (unlikely((ia->ia_size == i_size))) {
  661. lower_ia->ia_valid &= ~ATTR_SIZE;
  662. return 0;
  663. }
  664. rc = ecryptfs_get_lower_file(dentry, inode);
  665. if (rc)
  666. return rc;
  667. crypt_stat = &ecryptfs_inode_to_private(d_inode(dentry))->crypt_stat;
  668. /* Switch on growing or shrinking file */
  669. if (ia->ia_size > i_size) {
  670. char zero[] = { 0x00 };
  671. lower_ia->ia_valid &= ~ATTR_SIZE;
  672. /* Write a single 0 at the last position of the file;
  673. * this triggers code that will fill in 0's throughout
  674. * the intermediate portion of the previous end of the
  675. * file and the new and of the file */
  676. rc = ecryptfs_write(inode, zero,
  677. (ia->ia_size - 1), 1);
  678. } else { /* ia->ia_size < i_size_read(inode) */
  679. /* We're chopping off all the pages down to the page
  680. * in which ia->ia_size is located. Fill in the end of
  681. * that page from (ia->ia_size & ~PAGE_MASK) to
  682. * PAGE_SIZE with zeros. */
  683. size_t num_zeros = (PAGE_SIZE
  684. - (ia->ia_size & ~PAGE_MASK));
  685. if (!(crypt_stat->flags & ECRYPTFS_ENCRYPTED)) {
  686. truncate_setsize(inode, ia->ia_size);
  687. lower_ia->ia_size = ia->ia_size;
  688. lower_ia->ia_valid |= ATTR_SIZE;
  689. goto out;
  690. }
  691. if (num_zeros) {
  692. char *zeros_virt;
  693. zeros_virt = kzalloc(num_zeros, GFP_KERNEL);
  694. if (!zeros_virt) {
  695. rc = -ENOMEM;
  696. goto out;
  697. }
  698. rc = ecryptfs_write(inode, zeros_virt,
  699. ia->ia_size, num_zeros);
  700. kfree(zeros_virt);
  701. if (rc) {
  702. printk(KERN_ERR "Error attempting to zero out "
  703. "the remainder of the end page on "
  704. "reducing truncate; rc = [%d]\n", rc);
  705. goto out;
  706. }
  707. }
  708. truncate_setsize(inode, ia->ia_size);
  709. rc = ecryptfs_write_inode_size_to_metadata(inode);
  710. if (rc) {
  711. printk(KERN_ERR "Problem with "
  712. "ecryptfs_write_inode_size_to_metadata; "
  713. "rc = [%d]\n", rc);
  714. goto out;
  715. }
  716. /* We are reducing the size of the ecryptfs file, and need to
  717. * know if we need to reduce the size of the lower file. */
  718. lower_size_before_truncate =
  719. upper_size_to_lower_size(crypt_stat, i_size);
  720. lower_size_after_truncate =
  721. upper_size_to_lower_size(crypt_stat, ia->ia_size);
  722. if (lower_size_after_truncate < lower_size_before_truncate) {
  723. lower_ia->ia_size = lower_size_after_truncate;
  724. lower_ia->ia_valid |= ATTR_SIZE;
  725. } else
  726. lower_ia->ia_valid &= ~ATTR_SIZE;
  727. }
  728. out:
  729. ecryptfs_put_lower_file(inode);
  730. return rc;
  731. }
  732. static int ecryptfs_inode_newsize_ok(struct inode *inode, loff_t offset)
  733. {
  734. struct ecryptfs_crypt_stat *crypt_stat;
  735. loff_t lower_oldsize, lower_newsize;
  736. crypt_stat = &ecryptfs_inode_to_private(inode)->crypt_stat;
  737. lower_oldsize = upper_size_to_lower_size(crypt_stat,
  738. i_size_read(inode));
  739. lower_newsize = upper_size_to_lower_size(crypt_stat, offset);
  740. if (lower_newsize > lower_oldsize) {
  741. /*
  742. * The eCryptfs inode and the new *lower* size are mixed here
  743. * because we may not have the lower i_mutex held and/or it may
  744. * not be appropriate to call inode_newsize_ok() with inodes
  745. * from other filesystems.
  746. */
  747. return inode_newsize_ok(inode, lower_newsize);
  748. }
  749. return 0;
  750. }
  751. /**
  752. * ecryptfs_truncate
  753. * @dentry: The ecryptfs layer dentry
  754. * @new_length: The length to expand the file to
  755. *
  756. * Simple function that handles the truncation of an eCryptfs inode and
  757. * its corresponding lower inode.
  758. *
  759. * Returns zero on success; non-zero otherwise
  760. */
  761. int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
  762. {
  763. struct iattr ia = { .ia_valid = ATTR_SIZE, .ia_size = new_length };
  764. struct iattr lower_ia = { .ia_valid = 0 };
  765. int rc;
  766. rc = ecryptfs_inode_newsize_ok(d_inode(dentry), new_length);
  767. if (rc)
  768. return rc;
  769. rc = truncate_upper(dentry, &ia, &lower_ia);
  770. if (!rc && lower_ia.ia_valid & ATTR_SIZE) {
  771. struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
  772. inode_lock(d_inode(lower_dentry));
  773. rc = notify_change(lower_dentry, &lower_ia, NULL);
  774. inode_unlock(d_inode(lower_dentry));
  775. }
  776. return rc;
  777. }
  778. static int
  779. ecryptfs_permission(struct inode *inode, int mask)
  780. {
  781. return inode_permission(ecryptfs_inode_to_lower(inode), mask);
  782. }
  783. /**
  784. * ecryptfs_setattr
  785. * @dentry: dentry handle to the inode to modify
  786. * @ia: Structure with flags of what to change and values
  787. *
  788. * Updates the metadata of an inode. If the update is to the size
  789. * i.e. truncation, then ecryptfs_truncate will handle the size modification
  790. * of both the ecryptfs inode and the lower inode.
  791. *
  792. * All other metadata changes will be passed right to the lower filesystem,
  793. * and we will just update our inode to look like the lower.
  794. */
  795. static int ecryptfs_setattr(struct dentry *dentry, struct iattr *ia)
  796. {
  797. int rc = 0;
  798. struct dentry *lower_dentry;
  799. struct iattr lower_ia;
  800. struct inode *inode;
  801. struct inode *lower_inode;
  802. struct ecryptfs_crypt_stat *crypt_stat;
  803. crypt_stat = &ecryptfs_inode_to_private(d_inode(dentry))->crypt_stat;
  804. if (!(crypt_stat->flags & ECRYPTFS_STRUCT_INITIALIZED)) {
  805. rc = ecryptfs_init_crypt_stat(crypt_stat);
  806. if (rc)
  807. return rc;
  808. }
  809. inode = d_inode(dentry);
  810. lower_inode = ecryptfs_inode_to_lower(inode);
  811. lower_dentry = ecryptfs_dentry_to_lower(dentry);
  812. mutex_lock(&crypt_stat->cs_mutex);
  813. if (d_is_dir(dentry))
  814. crypt_stat->flags &= ~(ECRYPTFS_ENCRYPTED);
  815. else if (d_is_reg(dentry)
  816. && (!(crypt_stat->flags & ECRYPTFS_POLICY_APPLIED)
  817. || !(crypt_stat->flags & ECRYPTFS_KEY_VALID))) {
  818. struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
  819. mount_crypt_stat = &ecryptfs_superblock_to_private(
  820. dentry->d_sb)->mount_crypt_stat;
  821. rc = ecryptfs_get_lower_file(dentry, inode);
  822. if (rc) {
  823. mutex_unlock(&crypt_stat->cs_mutex);
  824. goto out;
  825. }
  826. rc = ecryptfs_read_metadata(dentry);
  827. ecryptfs_put_lower_file(inode);
  828. if (rc) {
  829. if (!(mount_crypt_stat->flags
  830. & ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED)) {
  831. rc = -EIO;
  832. printk(KERN_WARNING "Either the lower file "
  833. "is not in a valid eCryptfs format, "
  834. "or the key could not be retrieved. "
  835. "Plaintext passthrough mode is not "
  836. "enabled; returning -EIO\n");
  837. mutex_unlock(&crypt_stat->cs_mutex);
  838. goto out;
  839. }
  840. rc = 0;
  841. crypt_stat->flags &= ~(ECRYPTFS_I_SIZE_INITIALIZED
  842. | ECRYPTFS_ENCRYPTED);
  843. }
  844. }
  845. mutex_unlock(&crypt_stat->cs_mutex);
  846. rc = setattr_prepare(dentry, ia);
  847. if (rc)
  848. goto out;
  849. if (ia->ia_valid & ATTR_SIZE) {
  850. rc = ecryptfs_inode_newsize_ok(inode, ia->ia_size);
  851. if (rc)
  852. goto out;
  853. }
  854. memcpy(&lower_ia, ia, sizeof(lower_ia));
  855. if (ia->ia_valid & ATTR_FILE)
  856. lower_ia.ia_file = ecryptfs_file_to_lower(ia->ia_file);
  857. if (ia->ia_valid & ATTR_SIZE) {
  858. rc = truncate_upper(dentry, ia, &lower_ia);
  859. if (rc < 0)
  860. goto out;
  861. }
  862. /*
  863. * mode change is for clearing setuid/setgid bits. Allow lower fs
  864. * to interpret this in its own way.
  865. */
  866. if (lower_ia.ia_valid & (ATTR_KILL_SUID | ATTR_KILL_SGID))
  867. lower_ia.ia_valid &= ~ATTR_MODE;
  868. inode_lock(d_inode(lower_dentry));
  869. rc = notify_change(lower_dentry, &lower_ia, NULL);
  870. inode_unlock(d_inode(lower_dentry));
  871. out:
  872. fsstack_copy_attr_all(inode, lower_inode);
  873. return rc;
  874. }
  875. static int ecryptfs_getattr_link(const struct path *path, struct kstat *stat,
  876. u32 request_mask, unsigned int flags)
  877. {
  878. struct dentry *dentry = path->dentry;
  879. struct ecryptfs_mount_crypt_stat *mount_crypt_stat;
  880. int rc = 0;
  881. mount_crypt_stat = &ecryptfs_superblock_to_private(
  882. dentry->d_sb)->mount_crypt_stat;
  883. generic_fillattr(d_inode(dentry), stat);
  884. if (mount_crypt_stat->flags & ECRYPTFS_GLOBAL_ENCRYPT_FILENAMES) {
  885. char *target;
  886. size_t targetsiz;
  887. target = ecryptfs_readlink_lower(dentry, &targetsiz);
  888. if (!IS_ERR(target)) {
  889. kfree(target);
  890. stat->size = targetsiz;
  891. } else {
  892. rc = PTR_ERR(target);
  893. }
  894. }
  895. return rc;
  896. }
  897. static int ecryptfs_getattr(const struct path *path, struct kstat *stat,
  898. u32 request_mask, unsigned int flags)
  899. {
  900. struct dentry *dentry = path->dentry;
  901. struct kstat lower_stat;
  902. int rc;
  903. rc = vfs_getattr(ecryptfs_dentry_to_lower_path(dentry), &lower_stat,
  904. request_mask, flags);
  905. if (!rc) {
  906. fsstack_copy_attr_all(d_inode(dentry),
  907. ecryptfs_inode_to_lower(d_inode(dentry)));
  908. generic_fillattr(d_inode(dentry), stat);
  909. stat->blocks = lower_stat.blocks;
  910. }
  911. return rc;
  912. }
  913. int
  914. ecryptfs_setxattr(struct dentry *dentry, struct inode *inode,
  915. const char *name, const void *value,
  916. size_t size, int flags)
  917. {
  918. int rc;
  919. struct dentry *lower_dentry;
  920. lower_dentry = ecryptfs_dentry_to_lower(dentry);
  921. if (!(d_inode(lower_dentry)->i_opflags & IOP_XATTR)) {
  922. rc = -EOPNOTSUPP;
  923. goto out;
  924. }
  925. rc = vfs_setxattr(lower_dentry, name, value, size, flags);
  926. if (!rc && inode)
  927. fsstack_copy_attr_all(inode, d_inode(lower_dentry));
  928. out:
  929. return rc;
  930. }
  931. ssize_t
  932. ecryptfs_getxattr_lower(struct dentry *lower_dentry, struct inode *lower_inode,
  933. const char *name, void *value, size_t size)
  934. {
  935. int rc;
  936. if (!(lower_inode->i_opflags & IOP_XATTR)) {
  937. rc = -EOPNOTSUPP;
  938. goto out;
  939. }
  940. inode_lock(lower_inode);
  941. rc = __vfs_getxattr(lower_dentry, lower_inode, name, value, size);
  942. inode_unlock(lower_inode);
  943. out:
  944. return rc;
  945. }
  946. static ssize_t
  947. ecryptfs_getxattr(struct dentry *dentry, struct inode *inode,
  948. const char *name, void *value, size_t size)
  949. {
  950. return ecryptfs_getxattr_lower(ecryptfs_dentry_to_lower(dentry),
  951. ecryptfs_inode_to_lower(inode),
  952. name, value, size);
  953. }
  954. static ssize_t
  955. ecryptfs_listxattr(struct dentry *dentry, char *list, size_t size)
  956. {
  957. int rc = 0;
  958. struct dentry *lower_dentry;
  959. lower_dentry = ecryptfs_dentry_to_lower(dentry);
  960. if (!d_inode(lower_dentry)->i_op->listxattr) {
  961. rc = -EOPNOTSUPP;
  962. goto out;
  963. }
  964. inode_lock(d_inode(lower_dentry));
  965. rc = d_inode(lower_dentry)->i_op->listxattr(lower_dentry, list, size);
  966. inode_unlock(d_inode(lower_dentry));
  967. out:
  968. return rc;
  969. }
  970. static int ecryptfs_removexattr(struct dentry *dentry, struct inode *inode,
  971. const char *name)
  972. {
  973. int rc;
  974. struct dentry *lower_dentry;
  975. struct inode *lower_inode;
  976. lower_dentry = ecryptfs_dentry_to_lower(dentry);
  977. lower_inode = ecryptfs_inode_to_lower(inode);
  978. if (!(lower_inode->i_opflags & IOP_XATTR)) {
  979. rc = -EOPNOTSUPP;
  980. goto out;
  981. }
  982. inode_lock(lower_inode);
  983. rc = __vfs_removexattr(lower_dentry, name);
  984. inode_unlock(lower_inode);
  985. out:
  986. return rc;
  987. }
  988. const struct inode_operations ecryptfs_symlink_iops = {
  989. .get_link = ecryptfs_get_link,
  990. .permission = ecryptfs_permission,
  991. .setattr = ecryptfs_setattr,
  992. .getattr = ecryptfs_getattr_link,
  993. .listxattr = ecryptfs_listxattr,
  994. };
  995. const struct inode_operations ecryptfs_dir_iops = {
  996. .create = ecryptfs_create,
  997. .lookup = ecryptfs_lookup,
  998. .link = ecryptfs_link,
  999. .unlink = ecryptfs_unlink,
  1000. .symlink = ecryptfs_symlink,
  1001. .mkdir = ecryptfs_mkdir,
  1002. .rmdir = ecryptfs_rmdir,
  1003. .mknod = ecryptfs_mknod,
  1004. .rename = ecryptfs_rename,
  1005. .permission = ecryptfs_permission,
  1006. .setattr = ecryptfs_setattr,
  1007. .listxattr = ecryptfs_listxattr,
  1008. };
  1009. const struct inode_operations ecryptfs_main_iops = {
  1010. .permission = ecryptfs_permission,
  1011. .setattr = ecryptfs_setattr,
  1012. .getattr = ecryptfs_getattr,
  1013. .listxattr = ecryptfs_listxattr,
  1014. };
  1015. static int ecryptfs_xattr_get(const struct xattr_handler *handler,
  1016. struct dentry *dentry, struct inode *inode,
  1017. const char *name, void *buffer, size_t size)
  1018. {
  1019. return ecryptfs_getxattr(dentry, inode, name, buffer, size);
  1020. }
  1021. static int ecryptfs_xattr_set(const struct xattr_handler *handler,
  1022. struct dentry *dentry, struct inode *inode,
  1023. const char *name, const void *value, size_t size,
  1024. int flags)
  1025. {
  1026. if (value)
  1027. return ecryptfs_setxattr(dentry, inode, name, value, size, flags);
  1028. else {
  1029. BUG_ON(flags != XATTR_REPLACE);
  1030. return ecryptfs_removexattr(dentry, inode, name);
  1031. }
  1032. }
  1033. const struct xattr_handler ecryptfs_xattr_handler = {
  1034. .prefix = "", /* match anything */
  1035. .get = ecryptfs_xattr_get,
  1036. .set = ecryptfs_xattr_set,
  1037. };
  1038. const struct xattr_handler *ecryptfs_xattr_handlers[] = {
  1039. &ecryptfs_xattr_handler,
  1040. NULL
  1041. };