diff options
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/crypto.c | 30 | ||||
-rw-r--r-- | fs/ecryptfs/inode.c | 21 | ||||
-rw-r--r-- | fs/ecryptfs/main.c | 4 |
3 files changed, 23 insertions, 32 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index 7b99917ffad..06db79d05c1 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -475,8 +475,8 @@ int ecryptfs_encrypt_page(struct page *page) | |||
475 | { | 475 | { |
476 | struct inode *ecryptfs_inode; | 476 | struct inode *ecryptfs_inode; |
477 | struct ecryptfs_crypt_stat *crypt_stat; | 477 | struct ecryptfs_crypt_stat *crypt_stat; |
478 | char *enc_extent_virt = NULL; | 478 | char *enc_extent_virt; |
479 | struct page *enc_extent_page; | 479 | struct page *enc_extent_page = NULL; |
480 | loff_t extent_offset; | 480 | loff_t extent_offset; |
481 | int rc = 0; | 481 | int rc = 0; |
482 | 482 | ||
@@ -492,14 +492,14 @@ int ecryptfs_encrypt_page(struct page *page) | |||
492 | page->index); | 492 | page->index); |
493 | goto out; | 493 | goto out; |
494 | } | 494 | } |
495 | enc_extent_virt = kmalloc(PAGE_CACHE_SIZE, GFP_USER); | 495 | enc_extent_page = alloc_page(GFP_USER); |
496 | if (!enc_extent_virt) { | 496 | if (!enc_extent_page) { |
497 | rc = -ENOMEM; | 497 | rc = -ENOMEM; |
498 | ecryptfs_printk(KERN_ERR, "Error allocating memory for " | 498 | ecryptfs_printk(KERN_ERR, "Error allocating memory for " |
499 | "encrypted extent\n"); | 499 | "encrypted extent\n"); |
500 | goto out; | 500 | goto out; |
501 | } | 501 | } |
502 | enc_extent_page = virt_to_page(enc_extent_virt); | 502 | enc_extent_virt = kmap(enc_extent_page); |
503 | for (extent_offset = 0; | 503 | for (extent_offset = 0; |
504 | extent_offset < (PAGE_CACHE_SIZE / crypt_stat->extent_size); | 504 | extent_offset < (PAGE_CACHE_SIZE / crypt_stat->extent_size); |
505 | extent_offset++) { | 505 | extent_offset++) { |
@@ -527,7 +527,10 @@ int ecryptfs_encrypt_page(struct page *page) | |||
527 | } | 527 | } |
528 | } | 528 | } |
529 | out: | 529 | out: |
530 | kfree(enc_extent_virt); | 530 | if (enc_extent_page) { |
531 | kunmap(enc_extent_page); | ||
532 | __free_page(enc_extent_page); | ||
533 | } | ||
531 | return rc; | 534 | return rc; |
532 | } | 535 | } |
533 | 536 | ||
@@ -609,8 +612,8 @@ int ecryptfs_decrypt_page(struct page *page) | |||
609 | { | 612 | { |
610 | struct inode *ecryptfs_inode; | 613 | struct inode *ecryptfs_inode; |
611 | struct ecryptfs_crypt_stat *crypt_stat; | 614 | struct ecryptfs_crypt_stat *crypt_stat; |
612 | char *enc_extent_virt = NULL; | 615 | char *enc_extent_virt; |
613 | struct page *enc_extent_page; | 616 | struct page *enc_extent_page = NULL; |
614 | unsigned long extent_offset; | 617 | unsigned long extent_offset; |
615 | int rc = 0; | 618 | int rc = 0; |
616 | 619 | ||
@@ -627,14 +630,14 @@ int ecryptfs_decrypt_page(struct page *page) | |||
627 | page->index); | 630 | page->index); |
628 | goto out; | 631 | goto out; |
629 | } | 632 | } |
630 | enc_extent_virt = kmalloc(PAGE_CACHE_SIZE, GFP_USER); | 633 | enc_extent_page = alloc_page(GFP_USER); |
631 | if (!enc_extent_virt) { | 634 | if (!enc_extent_page) { |
632 | rc = -ENOMEM; | 635 | rc = -ENOMEM; |
633 | ecryptfs_printk(KERN_ERR, "Error allocating memory for " | 636 | ecryptfs_printk(KERN_ERR, "Error allocating memory for " |
634 | "encrypted extent\n"); | 637 | "encrypted extent\n"); |
635 | goto out; | 638 | goto out; |
636 | } | 639 | } |
637 | enc_extent_page = virt_to_page(enc_extent_virt); | 640 | enc_extent_virt = kmap(enc_extent_page); |
638 | for (extent_offset = 0; | 641 | for (extent_offset = 0; |
639 | extent_offset < (PAGE_CACHE_SIZE / crypt_stat->extent_size); | 642 | extent_offset < (PAGE_CACHE_SIZE / crypt_stat->extent_size); |
640 | extent_offset++) { | 643 | extent_offset++) { |
@@ -662,7 +665,10 @@ int ecryptfs_decrypt_page(struct page *page) | |||
662 | } | 665 | } |
663 | } | 666 | } |
664 | out: | 667 | out: |
665 | kfree(enc_extent_virt); | 668 | if (enc_extent_page) { |
669 | kunmap(enc_extent_page); | ||
670 | __free_page(enc_extent_page); | ||
671 | } | ||
666 | return rc; | 672 | return rc; |
667 | } | 673 | } |
668 | 674 | ||
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index d755455e3bf..89209f00f9c 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -465,7 +465,6 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry, | |||
465 | int rc; | 465 | int rc; |
466 | struct dentry *lower_dentry; | 466 | struct dentry *lower_dentry; |
467 | struct dentry *lower_dir_dentry; | 467 | struct dentry *lower_dir_dentry; |
468 | umode_t mode; | ||
469 | char *encoded_symname; | 468 | char *encoded_symname; |
470 | int encoded_symlen; | 469 | int encoded_symlen; |
471 | struct ecryptfs_crypt_stat *crypt_stat = NULL; | 470 | struct ecryptfs_crypt_stat *crypt_stat = NULL; |
@@ -473,7 +472,6 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry, | |||
473 | lower_dentry = ecryptfs_dentry_to_lower(dentry); | 472 | lower_dentry = ecryptfs_dentry_to_lower(dentry); |
474 | dget(lower_dentry); | 473 | dget(lower_dentry); |
475 | lower_dir_dentry = lock_parent(lower_dentry); | 474 | lower_dir_dentry = lock_parent(lower_dentry); |
476 | mode = S_IALLUGO; | ||
477 | encoded_symlen = ecryptfs_encode_filename(crypt_stat, symname, | 475 | encoded_symlen = ecryptfs_encode_filename(crypt_stat, symname, |
478 | strlen(symname), | 476 | strlen(symname), |
479 | &encoded_symname); | 477 | &encoded_symname); |
@@ -482,7 +480,7 @@ static int ecryptfs_symlink(struct inode *dir, struct dentry *dentry, | |||
482 | goto out_lock; | 480 | goto out_lock; |
483 | } | 481 | } |
484 | rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry, | 482 | rc = vfs_symlink(lower_dir_dentry->d_inode, lower_dentry, |
485 | encoded_symname, mode); | 483 | encoded_symname); |
486 | kfree(encoded_symname); | 484 | kfree(encoded_symname); |
487 | if (rc || !lower_dentry->d_inode) | 485 | if (rc || !lower_dentry->d_inode) |
488 | goto out_lock; | 486 | goto out_lock; |
@@ -830,22 +828,9 @@ out: | |||
830 | } | 828 | } |
831 | 829 | ||
832 | static int | 830 | static int |
833 | ecryptfs_permission(struct inode *inode, int mask, struct nameidata *nd) | 831 | ecryptfs_permission(struct inode *inode, int mask) |
834 | { | 832 | { |
835 | int rc; | 833 | return inode_permission(ecryptfs_inode_to_lower(inode), mask); |
836 | |||
837 | if (nd) { | ||
838 | struct vfsmount *vfsmnt_save = nd->path.mnt; | ||
839 | struct dentry *dentry_save = nd->path.dentry; | ||
840 | |||
841 | nd->path.mnt = ecryptfs_dentry_to_lower_mnt(nd->path.dentry); | ||
842 | nd->path.dentry = ecryptfs_dentry_to_lower(nd->path.dentry); | ||
843 | rc = permission(ecryptfs_inode_to_lower(inode), mask, nd); | ||
844 | nd->path.mnt = vfsmnt_save; | ||
845 | nd->path.dentry = dentry_save; | ||
846 | } else | ||
847 | rc = permission(ecryptfs_inode_to_lower(inode), mask, NULL); | ||
848 | return rc; | ||
849 | } | 834 | } |
850 | 835 | ||
851 | /** | 836 | /** |
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 6f403cfba14..448dfd597b5 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -578,7 +578,7 @@ static struct file_system_type ecryptfs_fs_type = { | |||
578 | * Initializes the ecryptfs_inode_info_cache when it is created | 578 | * Initializes the ecryptfs_inode_info_cache when it is created |
579 | */ | 579 | */ |
580 | static void | 580 | static void |
581 | inode_info_init_once(struct kmem_cache *cachep, void *vptr) | 581 | inode_info_init_once(void *vptr) |
582 | { | 582 | { |
583 | struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr; | 583 | struct ecryptfs_inode_info *ei = (struct ecryptfs_inode_info *)vptr; |
584 | 584 | ||
@@ -589,7 +589,7 @@ static struct ecryptfs_cache_info { | |||
589 | struct kmem_cache **cache; | 589 | struct kmem_cache **cache; |
590 | const char *name; | 590 | const char *name; |
591 | size_t size; | 591 | size_t size; |
592 | void (*ctor)(struct kmem_cache *cache, void *obj); | 592 | void (*ctor)(void *obj); |
593 | } ecryptfs_cache_infos[] = { | 593 | } ecryptfs_cache_infos[] = { |
594 | { | 594 | { |
595 | .cache = &ecryptfs_auth_tok_list_item_cache, | 595 | .cache = &ecryptfs_auth_tok_list_item_cache, |