diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-11-17 17:16:21 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-11-17 17:16:21 -0500 |
commit | e0bcb42e602816415f6fe07313b6fc84932244b7 (patch) | |
tree | 36ece6403a56805a42332659f0762ce280bc936c | |
parent | b6b220b0c76f0aa9cb5efb882424a7acc109d898 (diff) | |
parent | 4670269faba728683f7250319a65390946c028e3 (diff) |
Merge tag 'ecryptfs-4.15-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs
Pull eCryptfs updates from Tyler Hicks:
- miscellaneous code cleanups and refactoring
- fix a possible use after free bug when unloading the module
* tag 'ecryptfs-4.15-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs:
eCryptfs: constify attribute_group structures.
ecryptfs: remove unnecessary i_version bump
ecryptfs: use ARRAY_SIZE
ecryptfs: Adjust four checks for null pointers
ecryptfs: Return an error code only as a constant in ecryptfs_add_global_auth_tok()
ecryptfs: Delete 21 error messages for a failed memory allocation
eCryptfs: use after free in ecryptfs_release_messaging()
ecryptfs: remove private bin2hex implementation
ecryptfs: add missing \n to end of various error messages
-rw-r--r-- | fs/ecryptfs/crypto.c | 44 | ||||
-rw-r--r-- | fs/ecryptfs/ecryptfs_kernel.h | 9 | ||||
-rw-r--r-- | fs/ecryptfs/inode.c | 4 | ||||
-rw-r--r-- | fs/ecryptfs/keystore.c | 48 | ||||
-rw-r--r-- | fs/ecryptfs/main.c | 4 | ||||
-rw-r--r-- | fs/ecryptfs/messaging.c | 13 | ||||
-rw-r--r-- | fs/ecryptfs/miscdev.c | 8 | ||||
-rw-r--r-- | fs/ecryptfs/mmap.c | 2 |
8 files changed, 34 insertions, 98 deletions
diff --git a/fs/ecryptfs/crypto.c b/fs/ecryptfs/crypto.c index e5e29f8c920b..846ca150d52e 100644 --- a/fs/ecryptfs/crypto.c +++ b/fs/ecryptfs/crypto.c | |||
@@ -36,27 +36,13 @@ | |||
36 | #include <linux/scatterlist.h> | 36 | #include <linux/scatterlist.h> |
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <asm/unaligned.h> | 38 | #include <asm/unaligned.h> |
39 | #include <linux/kernel.h> | ||
39 | #include "ecryptfs_kernel.h" | 40 | #include "ecryptfs_kernel.h" |
40 | 41 | ||
41 | #define DECRYPT 0 | 42 | #define DECRYPT 0 |
42 | #define ENCRYPT 1 | 43 | #define ENCRYPT 1 |
43 | 44 | ||
44 | /** | 45 | /** |
45 | * ecryptfs_to_hex | ||
46 | * @dst: Buffer to take hex character representation of contents of | ||
47 | * src; must be at least of size (src_size * 2) | ||
48 | * @src: Buffer to be converted to a hex string representation | ||
49 | * @src_size: number of bytes to convert | ||
50 | */ | ||
51 | void ecryptfs_to_hex(char *dst, char *src, size_t src_size) | ||
52 | { | ||
53 | int x; | ||
54 | |||
55 | for (x = 0; x < src_size; x++) | ||
56 | sprintf(&dst[x * 2], "%.2x", (unsigned char)src[x]); | ||
57 | } | ||
58 | |||
59 | /** | ||
60 | * ecryptfs_from_hex | 46 | * ecryptfs_from_hex |
61 | * @dst: Buffer to take the bytes from src hex; must be at least of | 47 | * @dst: Buffer to take the bytes from src hex; must be at least of |
62 | * size (src_size / 2) | 48 | * size (src_size / 2) |
@@ -899,8 +885,7 @@ static int ecryptfs_process_flags(struct ecryptfs_crypt_stat *crypt_stat, | |||
899 | u32 flags; | 885 | u32 flags; |
900 | 886 | ||
901 | flags = get_unaligned_be32(page_virt); | 887 | flags = get_unaligned_be32(page_virt); |
902 | for (i = 0; i < ((sizeof(ecryptfs_flag_map) | 888 | for (i = 0; i < ARRAY_SIZE(ecryptfs_flag_map); i++) |
903 | / sizeof(struct ecryptfs_flag_map_elem))); i++) | ||
904 | if (flags & ecryptfs_flag_map[i].file_flag) { | 889 | if (flags & ecryptfs_flag_map[i].file_flag) { |
905 | crypt_stat->flags |= ecryptfs_flag_map[i].local_flag; | 890 | crypt_stat->flags |= ecryptfs_flag_map[i].local_flag; |
906 | } else | 891 | } else |
@@ -937,8 +922,7 @@ void ecryptfs_write_crypt_stat_flags(char *page_virt, | |||
937 | u32 flags = 0; | 922 | u32 flags = 0; |
938 | int i; | 923 | int i; |
939 | 924 | ||
940 | for (i = 0; i < ((sizeof(ecryptfs_flag_map) | 925 | for (i = 0; i < ARRAY_SIZE(ecryptfs_flag_map); i++) |
941 | / sizeof(struct ecryptfs_flag_map_elem))); i++) | ||
942 | if (crypt_stat->flags & ecryptfs_flag_map[i].local_flag) | 926 | if (crypt_stat->flags & ecryptfs_flag_map[i].local_flag) |
943 | flags |= ecryptfs_flag_map[i].file_flag; | 927 | flags |= ecryptfs_flag_map[i].file_flag; |
944 | /* Version is in top 8 bits of the 32-bit flag vector */ | 928 | /* Version is in top 8 bits of the 32-bit flag vector */ |
@@ -1434,8 +1418,6 @@ int ecryptfs_read_metadata(struct dentry *ecryptfs_dentry) | |||
1434 | page_virt = kmem_cache_alloc(ecryptfs_header_cache, GFP_USER); | 1418 | page_virt = kmem_cache_alloc(ecryptfs_header_cache, GFP_USER); |
1435 | if (!page_virt) { | 1419 | if (!page_virt) { |
1436 | rc = -ENOMEM; | 1420 | rc = -ENOMEM; |
1437 | printk(KERN_ERR "%s: Unable to allocate page_virt\n", | ||
1438 | __func__); | ||
1439 | goto out; | 1421 | goto out; |
1440 | } | 1422 | } |
1441 | rc = ecryptfs_read_lower(page_virt, 0, crypt_stat->extent_size, | 1423 | rc = ecryptfs_read_lower(page_virt, 0, crypt_stat->extent_size, |
@@ -1522,9 +1504,6 @@ ecryptfs_encrypt_filename(struct ecryptfs_filename *filename, | |||
1522 | filename->encrypted_filename = | 1504 | filename->encrypted_filename = |
1523 | kmalloc(filename->encrypted_filename_size, GFP_KERNEL); | 1505 | kmalloc(filename->encrypted_filename_size, GFP_KERNEL); |
1524 | if (!filename->encrypted_filename) { | 1506 | if (!filename->encrypted_filename) { |
1525 | printk(KERN_ERR "%s: Out of memory whilst attempting " | ||
1526 | "to kmalloc [%zd] bytes\n", __func__, | ||
1527 | filename->encrypted_filename_size); | ||
1528 | rc = -ENOMEM; | 1507 | rc = -ENOMEM; |
1529 | goto out; | 1508 | goto out; |
1530 | } | 1509 | } |
@@ -1669,12 +1648,10 @@ ecryptfs_add_new_key_tfm(struct ecryptfs_key_tfm **key_tfm, char *cipher_name, | |||
1669 | BUG_ON(!mutex_is_locked(&key_tfm_list_mutex)); | 1648 | BUG_ON(!mutex_is_locked(&key_tfm_list_mutex)); |
1670 | 1649 | ||
1671 | tmp_tfm = kmem_cache_alloc(ecryptfs_key_tfm_cache, GFP_KERNEL); | 1650 | tmp_tfm = kmem_cache_alloc(ecryptfs_key_tfm_cache, GFP_KERNEL); |
1672 | if (key_tfm != NULL) | 1651 | if (key_tfm) |
1673 | (*key_tfm) = tmp_tfm; | 1652 | (*key_tfm) = tmp_tfm; |
1674 | if (!tmp_tfm) { | 1653 | if (!tmp_tfm) { |
1675 | rc = -ENOMEM; | 1654 | rc = -ENOMEM; |
1676 | printk(KERN_ERR "Error attempting to allocate from " | ||
1677 | "ecryptfs_key_tfm_cache\n"); | ||
1678 | goto out; | 1655 | goto out; |
1679 | } | 1656 | } |
1680 | mutex_init(&tmp_tfm->key_tfm_mutex); | 1657 | mutex_init(&tmp_tfm->key_tfm_mutex); |
@@ -1690,7 +1667,7 @@ ecryptfs_add_new_key_tfm(struct ecryptfs_key_tfm **key_tfm, char *cipher_name, | |||
1690 | "cipher with name = [%s]; rc = [%d]\n", | 1667 | "cipher with name = [%s]; rc = [%d]\n", |
1691 | tmp_tfm->cipher_name, rc); | 1668 | tmp_tfm->cipher_name, rc); |
1692 | kmem_cache_free(ecryptfs_key_tfm_cache, tmp_tfm); | 1669 | kmem_cache_free(ecryptfs_key_tfm_cache, tmp_tfm); |
1693 | if (key_tfm != NULL) | 1670 | if (key_tfm) |
1694 | (*key_tfm) = NULL; | 1671 | (*key_tfm) = NULL; |
1695 | goto out; | 1672 | goto out; |
1696 | } | 1673 | } |
@@ -1881,7 +1858,7 @@ ecryptfs_decode_from_filename(unsigned char *dst, size_t *dst_size, | |||
1881 | size_t src_byte_offset = 0; | 1858 | size_t src_byte_offset = 0; |
1882 | size_t dst_byte_offset = 0; | 1859 | size_t dst_byte_offset = 0; |
1883 | 1860 | ||
1884 | if (dst == NULL) { | 1861 | if (!dst) { |
1885 | (*dst_size) = ecryptfs_max_decoded_size(src_size); | 1862 | (*dst_size) = ecryptfs_max_decoded_size(src_size); |
1886 | goto out; | 1863 | goto out; |
1887 | } | 1864 | } |
@@ -1949,9 +1926,6 @@ int ecryptfs_encrypt_and_encode_filename( | |||
1949 | 1926 | ||
1950 | filename = kzalloc(sizeof(*filename), GFP_KERNEL); | 1927 | filename = kzalloc(sizeof(*filename), GFP_KERNEL); |
1951 | if (!filename) { | 1928 | if (!filename) { |
1952 | printk(KERN_ERR "%s: Out of memory whilst attempting " | ||
1953 | "to kzalloc [%zd] bytes\n", __func__, | ||
1954 | sizeof(*filename)); | ||
1955 | rc = -ENOMEM; | 1929 | rc = -ENOMEM; |
1956 | goto out; | 1930 | goto out; |
1957 | } | 1931 | } |
@@ -1980,9 +1954,6 @@ int ecryptfs_encrypt_and_encode_filename( | |||
1980 | + encoded_name_no_prefix_size); | 1954 | + encoded_name_no_prefix_size); |
1981 | (*encoded_name) = kmalloc((*encoded_name_size) + 1, GFP_KERNEL); | 1955 | (*encoded_name) = kmalloc((*encoded_name_size) + 1, GFP_KERNEL); |
1982 | if (!(*encoded_name)) { | 1956 | if (!(*encoded_name)) { |
1983 | printk(KERN_ERR "%s: Out of memory whilst attempting " | ||
1984 | "to kzalloc [%zd] bytes\n", __func__, | ||
1985 | (*encoded_name_size)); | ||
1986 | rc = -ENOMEM; | 1957 | rc = -ENOMEM; |
1987 | kfree(filename->encrypted_filename); | 1958 | kfree(filename->encrypted_filename); |
1988 | kfree(filename); | 1959 | kfree(filename); |
@@ -2064,9 +2035,6 @@ int ecryptfs_decode_and_decrypt_filename(char **plaintext_name, | |||
2064 | name, name_size); | 2035 | name, name_size); |
2065 | decoded_name = kmalloc(decoded_name_size, GFP_KERNEL); | 2036 | decoded_name = kmalloc(decoded_name_size, GFP_KERNEL); |
2066 | if (!decoded_name) { | 2037 | if (!decoded_name) { |
2067 | printk(KERN_ERR "%s: Out of memory whilst attempting " | ||
2068 | "to kmalloc [%zd] bytes\n", __func__, | ||
2069 | decoded_name_size); | ||
2070 | rc = -ENOMEM; | 2038 | rc = -ENOMEM; |
2071 | goto out; | 2039 | goto out; |
2072 | } | 2040 | } |
diff --git a/fs/ecryptfs/ecryptfs_kernel.h b/fs/ecryptfs/ecryptfs_kernel.h index 3fbc0ff79699..e74cb2a0b299 100644 --- a/fs/ecryptfs/ecryptfs_kernel.h +++ b/fs/ecryptfs/ecryptfs_kernel.h | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <crypto/skcipher.h> | 31 | #include <crypto/skcipher.h> |
32 | #include <keys/user-type.h> | 32 | #include <keys/user-type.h> |
33 | #include <keys/encrypted-type.h> | 33 | #include <keys/encrypted-type.h> |
34 | #include <linux/kernel.h> | ||
34 | #include <linux/fs.h> | 35 | #include <linux/fs.h> |
35 | #include <linux/fs_stack.h> | 36 | #include <linux/fs_stack.h> |
36 | #include <linux/namei.h> | 37 | #include <linux/namei.h> |
@@ -51,7 +52,13 @@ | |||
51 | #define ECRYPTFS_XATTR_NAME "user.ecryptfs" | 52 | #define ECRYPTFS_XATTR_NAME "user.ecryptfs" |
52 | 53 | ||
53 | void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok); | 54 | void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok); |
54 | extern void ecryptfs_to_hex(char *dst, char *src, size_t src_size); | 55 | static inline void |
56 | ecryptfs_to_hex(char *dst, char *src, size_t src_size) | ||
57 | { | ||
58 | char *end = bin2hex(dst, src, src_size); | ||
59 | *end = '\0'; | ||
60 | } | ||
61 | |||
55 | extern void ecryptfs_from_hex(char *dst, char *src, int dst_size); | 62 | extern void ecryptfs_from_hex(char *dst, char *src, int dst_size); |
56 | 63 | ||
57 | struct ecryptfs_key_record { | 64 | struct ecryptfs_key_record { |
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c index efc2db42d175..847904aa63a9 100644 --- a/fs/ecryptfs/inode.c +++ b/fs/ecryptfs/inode.c | |||
@@ -64,7 +64,6 @@ static int ecryptfs_inode_set(struct inode *inode, void *opaque) | |||
64 | /* i_size will be overwritten for encrypted regular files */ | 64 | /* i_size will be overwritten for encrypted regular files */ |
65 | fsstack_copy_inode_size(inode, lower_inode); | 65 | fsstack_copy_inode_size(inode, lower_inode); |
66 | inode->i_ino = lower_inode->i_ino; | 66 | inode->i_ino = lower_inode->i_ino; |
67 | inode->i_version++; | ||
68 | inode->i_mapping->a_ops = &ecryptfs_aops; | 67 | inode->i_mapping->a_ops = &ecryptfs_aops; |
69 | 68 | ||
70 | if (S_ISLNK(inode->i_mode)) | 69 | if (S_ISLNK(inode->i_mode)) |
@@ -334,9 +333,6 @@ static struct dentry *ecryptfs_lookup_interpose(struct dentry *dentry, | |||
334 | 333 | ||
335 | dentry_info = kmem_cache_alloc(ecryptfs_dentry_info_cache, GFP_KERNEL); | 334 | dentry_info = kmem_cache_alloc(ecryptfs_dentry_info_cache, GFP_KERNEL); |
336 | if (!dentry_info) { | 335 | if (!dentry_info) { |
337 | printk(KERN_ERR "%s: Out of memory whilst attempting " | ||
338 | "to allocate ecryptfs_dentry_info struct\n", | ||
339 | __func__); | ||
340 | dput(lower_dentry); | 336 | dput(lower_dentry); |
341 | return ERR_PTR(-ENOMEM); | 337 | return ERR_PTR(-ENOMEM); |
342 | } | 338 | } |
diff --git a/fs/ecryptfs/keystore.c b/fs/ecryptfs/keystore.c index fa218cd64f74..c89a58cfc991 100644 --- a/fs/ecryptfs/keystore.c +++ b/fs/ecryptfs/keystore.c | |||
@@ -639,11 +639,9 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes, | |||
639 | int rc = 0; | 639 | int rc = 0; |
640 | 640 | ||
641 | s = kzalloc(sizeof(*s), GFP_KERNEL); | 641 | s = kzalloc(sizeof(*s), GFP_KERNEL); |
642 | if (!s) { | 642 | if (!s) |
643 | printk(KERN_ERR "%s: Out of memory whilst trying to kmalloc " | ||
644 | "[%zd] bytes of kernel memory\n", __func__, sizeof(*s)); | ||
645 | return -ENOMEM; | 643 | return -ENOMEM; |
646 | } | 644 | |
647 | (*packet_size) = 0; | 645 | (*packet_size) = 0; |
648 | rc = ecryptfs_find_auth_tok_for_sig( | 646 | rc = ecryptfs_find_auth_tok_for_sig( |
649 | &auth_tok_key, | 647 | &auth_tok_key, |
@@ -687,7 +685,7 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes, | |||
687 | * separator, and then the filename */ | 685 | * separator, and then the filename */ |
688 | s->max_packet_size = (ECRYPTFS_TAG_70_MAX_METADATA_SIZE | 686 | s->max_packet_size = (ECRYPTFS_TAG_70_MAX_METADATA_SIZE |
689 | + s->block_aligned_filename_size); | 687 | + s->block_aligned_filename_size); |
690 | if (dest == NULL) { | 688 | if (!dest) { |
691 | (*packet_size) = s->max_packet_size; | 689 | (*packet_size) = s->max_packet_size; |
692 | goto out_unlock; | 690 | goto out_unlock; |
693 | } | 691 | } |
@@ -714,9 +712,6 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes, | |||
714 | s->block_aligned_filename = kzalloc(s->block_aligned_filename_size, | 712 | s->block_aligned_filename = kzalloc(s->block_aligned_filename_size, |
715 | GFP_KERNEL); | 713 | GFP_KERNEL); |
716 | if (!s->block_aligned_filename) { | 714 | if (!s->block_aligned_filename) { |
717 | printk(KERN_ERR "%s: Out of kernel memory whilst attempting to " | ||
718 | "kzalloc [%zd] bytes\n", __func__, | ||
719 | s->block_aligned_filename_size); | ||
720 | rc = -ENOMEM; | 715 | rc = -ENOMEM; |
721 | goto out_unlock; | 716 | goto out_unlock; |
722 | } | 717 | } |
@@ -769,10 +764,6 @@ ecryptfs_write_tag_70_packet(char *dest, size_t *remaining_bytes, | |||
769 | s->hash_desc = kmalloc(sizeof(*s->hash_desc) + | 764 | s->hash_desc = kmalloc(sizeof(*s->hash_desc) + |
770 | crypto_shash_descsize(s->hash_tfm), GFP_KERNEL); | 765 | crypto_shash_descsize(s->hash_tfm), GFP_KERNEL); |
771 | if (!s->hash_desc) { | 766 | if (!s->hash_desc) { |
772 | printk(KERN_ERR "%s: Out of kernel memory whilst attempting to " | ||
773 | "kmalloc [%zd] bytes\n", __func__, | ||
774 | sizeof(*s->hash_desc) + | ||
775 | crypto_shash_descsize(s->hash_tfm)); | ||
776 | rc = -ENOMEM; | 767 | rc = -ENOMEM; |
777 | goto out_release_free_unlock; | 768 | goto out_release_free_unlock; |
778 | } | 769 | } |
@@ -925,11 +916,9 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size, | |||
925 | (*filename_size) = 0; | 916 | (*filename_size) = 0; |
926 | (*filename) = NULL; | 917 | (*filename) = NULL; |
927 | s = kzalloc(sizeof(*s), GFP_KERNEL); | 918 | s = kzalloc(sizeof(*s), GFP_KERNEL); |
928 | if (!s) { | 919 | if (!s) |
929 | printk(KERN_ERR "%s: Out of memory whilst trying to kmalloc " | ||
930 | "[%zd] bytes of kernel memory\n", __func__, sizeof(*s)); | ||
931 | return -ENOMEM; | 920 | return -ENOMEM; |
932 | } | 921 | |
933 | if (max_packet_size < ECRYPTFS_TAG_70_MIN_METADATA_SIZE) { | 922 | if (max_packet_size < ECRYPTFS_TAG_70_MIN_METADATA_SIZE) { |
934 | printk(KERN_WARNING "%s: max_packet_size is [%zd]; it must be " | 923 | printk(KERN_WARNING "%s: max_packet_size is [%zd]; it must be " |
935 | "at least [%d]\n", __func__, max_packet_size, | 924 | "at least [%d]\n", __func__, max_packet_size, |
@@ -1015,9 +1004,6 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size, | |||
1015 | s->decrypted_filename = kmalloc(s->block_aligned_filename_size, | 1004 | s->decrypted_filename = kmalloc(s->block_aligned_filename_size, |
1016 | GFP_KERNEL); | 1005 | GFP_KERNEL); |
1017 | if (!s->decrypted_filename) { | 1006 | if (!s->decrypted_filename) { |
1018 | printk(KERN_ERR "%s: Out of memory whilst attempting to " | ||
1019 | "kmalloc [%zd] bytes\n", __func__, | ||
1020 | s->block_aligned_filename_size); | ||
1021 | rc = -ENOMEM; | 1007 | rc = -ENOMEM; |
1022 | goto out_unlock; | 1008 | goto out_unlock; |
1023 | } | 1009 | } |
@@ -1097,9 +1083,6 @@ ecryptfs_parse_tag_70_packet(char **filename, size_t *filename_size, | |||
1097 | } | 1083 | } |
1098 | (*filename) = kmalloc(((*filename_size) + 1), GFP_KERNEL); | 1084 | (*filename) = kmalloc(((*filename_size) + 1), GFP_KERNEL); |
1099 | if (!(*filename)) { | 1085 | if (!(*filename)) { |
1100 | printk(KERN_ERR "%s: Out of memory whilst attempting to " | ||
1101 | "kmalloc [%zd] bytes\n", __func__, | ||
1102 | ((*filename_size) + 1)); | ||
1103 | rc = -ENOMEM; | 1086 | rc = -ENOMEM; |
1104 | goto out_free_unlock; | 1087 | goto out_free_unlock; |
1105 | } | 1088 | } |
@@ -1333,7 +1316,7 @@ parse_tag_1_packet(struct ecryptfs_crypt_stat *crypt_stat, | |||
1333 | if ((*new_auth_tok)->session_key.encrypted_key_size | 1316 | if ((*new_auth_tok)->session_key.encrypted_key_size |
1334 | > ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES) { | 1317 | > ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES) { |
1335 | printk(KERN_WARNING "Tag 1 packet contains key larger " | 1318 | printk(KERN_WARNING "Tag 1 packet contains key larger " |
1336 | "than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES"); | 1319 | "than ECRYPTFS_MAX_ENCRYPTED_KEY_BYTES\n"); |
1337 | rc = -EINVAL; | 1320 | rc = -EINVAL; |
1338 | goto out; | 1321 | goto out; |
1339 | } | 1322 | } |
@@ -2525,11 +2508,9 @@ int ecryptfs_add_keysig(struct ecryptfs_crypt_stat *crypt_stat, char *sig) | |||
2525 | struct ecryptfs_key_sig *new_key_sig; | 2508 | struct ecryptfs_key_sig *new_key_sig; |
2526 | 2509 | ||
2527 | new_key_sig = kmem_cache_alloc(ecryptfs_key_sig_cache, GFP_KERNEL); | 2510 | new_key_sig = kmem_cache_alloc(ecryptfs_key_sig_cache, GFP_KERNEL); |
2528 | if (!new_key_sig) { | 2511 | if (!new_key_sig) |
2529 | printk(KERN_ERR | ||
2530 | "Error allocating from ecryptfs_key_sig_cache\n"); | ||
2531 | return -ENOMEM; | 2512 | return -ENOMEM; |
2532 | } | 2513 | |
2533 | memcpy(new_key_sig->keysig, sig, ECRYPTFS_SIG_SIZE_HEX); | 2514 | memcpy(new_key_sig->keysig, sig, ECRYPTFS_SIG_SIZE_HEX); |
2534 | new_key_sig->keysig[ECRYPTFS_SIG_SIZE_HEX] = '\0'; | 2515 | new_key_sig->keysig[ECRYPTFS_SIG_SIZE_HEX] = '\0'; |
2535 | /* Caller must hold keysig_list_mutex */ | 2516 | /* Caller must hold keysig_list_mutex */ |
@@ -2545,16 +2526,12 @@ ecryptfs_add_global_auth_tok(struct ecryptfs_mount_crypt_stat *mount_crypt_stat, | |||
2545 | char *sig, u32 global_auth_tok_flags) | 2526 | char *sig, u32 global_auth_tok_flags) |
2546 | { | 2527 | { |
2547 | struct ecryptfs_global_auth_tok *new_auth_tok; | 2528 | struct ecryptfs_global_auth_tok *new_auth_tok; |
2548 | int rc = 0; | ||
2549 | 2529 | ||
2550 | new_auth_tok = kmem_cache_zalloc(ecryptfs_global_auth_tok_cache, | 2530 | new_auth_tok = kmem_cache_zalloc(ecryptfs_global_auth_tok_cache, |
2551 | GFP_KERNEL); | 2531 | GFP_KERNEL); |
2552 | if (!new_auth_tok) { | 2532 | if (!new_auth_tok) |
2553 | rc = -ENOMEM; | 2533 | return -ENOMEM; |
2554 | printk(KERN_ERR "Error allocating from " | 2534 | |
2555 | "ecryptfs_global_auth_tok_cache\n"); | ||
2556 | goto out; | ||
2557 | } | ||
2558 | memcpy(new_auth_tok->sig, sig, ECRYPTFS_SIG_SIZE_HEX); | 2535 | memcpy(new_auth_tok->sig, sig, ECRYPTFS_SIG_SIZE_HEX); |
2559 | new_auth_tok->flags = global_auth_tok_flags; | 2536 | new_auth_tok->flags = global_auth_tok_flags; |
2560 | new_auth_tok->sig[ECRYPTFS_SIG_SIZE_HEX] = '\0'; | 2537 | new_auth_tok->sig[ECRYPTFS_SIG_SIZE_HEX] = '\0'; |
@@ -2562,7 +2539,6 @@ ecryptfs_add_global_auth_tok(struct ecryptfs_mount_crypt_stat *mount_crypt_stat, | |||
2562 | list_add(&new_auth_tok->mount_crypt_stat_list, | 2539 | list_add(&new_auth_tok->mount_crypt_stat_list, |
2563 | &mount_crypt_stat->global_auth_tok_list); | 2540 | &mount_crypt_stat->global_auth_tok_list); |
2564 | mutex_unlock(&mount_crypt_stat->global_auth_tok_list_mutex); | 2541 | mutex_unlock(&mount_crypt_stat->global_auth_tok_list_mutex); |
2565 | out: | 2542 | return 0; |
2566 | return rc; | ||
2567 | } | 2543 | } |
2568 | 2544 | ||
diff --git a/fs/ecryptfs/main.c b/fs/ecryptfs/main.c index 25aeaa7328ba..f2677c90d96e 100644 --- a/fs/ecryptfs/main.c +++ b/fs/ecryptfs/main.c | |||
@@ -426,7 +426,7 @@ static int ecryptfs_parse_options(struct ecryptfs_sb_info *sbi, char *options, | |||
426 | mount_crypt_stat->global_default_cipher_key_size); | 426 | mount_crypt_stat->global_default_cipher_key_size); |
427 | if (!cipher_code) { | 427 | if (!cipher_code) { |
428 | ecryptfs_printk(KERN_ERR, | 428 | ecryptfs_printk(KERN_ERR, |
429 | "eCryptfs doesn't support cipher: %s", | 429 | "eCryptfs doesn't support cipher: %s\n", |
430 | mount_crypt_stat->global_default_cipher_name); | 430 | mount_crypt_stat->global_default_cipher_name); |
431 | rc = -EINVAL; | 431 | rc = -EINVAL; |
432 | goto out; | 432 | goto out; |
@@ -781,7 +781,7 @@ static struct attribute *attributes[] = { | |||
781 | NULL, | 781 | NULL, |
782 | }; | 782 | }; |
783 | 783 | ||
784 | static struct attribute_group attr_group = { | 784 | static const struct attribute_group attr_group = { |
785 | .attrs = attributes, | 785 | .attrs = attributes, |
786 | }; | 786 | }; |
787 | 787 | ||
diff --git a/fs/ecryptfs/messaging.c b/fs/ecryptfs/messaging.c index 286f10b0363b..9fdd5bcf4564 100644 --- a/fs/ecryptfs/messaging.c +++ b/fs/ecryptfs/messaging.c | |||
@@ -147,8 +147,6 @@ ecryptfs_spawn_daemon(struct ecryptfs_daemon **daemon, struct file *file) | |||
147 | (*daemon) = kzalloc(sizeof(**daemon), GFP_KERNEL); | 147 | (*daemon) = kzalloc(sizeof(**daemon), GFP_KERNEL); |
148 | if (!(*daemon)) { | 148 | if (!(*daemon)) { |
149 | rc = -ENOMEM; | 149 | rc = -ENOMEM; |
150 | printk(KERN_ERR "%s: Failed to allocate [%zd] bytes of " | ||
151 | "GFP_KERNEL memory\n", __func__, sizeof(**daemon)); | ||
152 | goto out; | 150 | goto out; |
153 | } | 151 | } |
154 | (*daemon)->file = file; | 152 | (*daemon)->file = file; |
@@ -250,8 +248,6 @@ int ecryptfs_process_response(struct ecryptfs_daemon *daemon, | |||
250 | msg_ctx->msg = kmemdup(msg, msg_size, GFP_KERNEL); | 248 | msg_ctx->msg = kmemdup(msg, msg_size, GFP_KERNEL); |
251 | if (!msg_ctx->msg) { | 249 | if (!msg_ctx->msg) { |
252 | rc = -ENOMEM; | 250 | rc = -ENOMEM; |
253 | printk(KERN_ERR "%s: Failed to allocate [%zd] bytes of " | ||
254 | "GFP_KERNEL memory\n", __func__, msg_size); | ||
255 | goto unlock; | 251 | goto unlock; |
256 | } | 252 | } |
257 | msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_DONE; | 253 | msg_ctx->state = ECRYPTFS_MSG_CTX_STATE_DONE; |
@@ -386,7 +382,6 @@ int __init ecryptfs_init_messaging(void) | |||
386 | GFP_KERNEL); | 382 | GFP_KERNEL); |
387 | if (!ecryptfs_daemon_hash) { | 383 | if (!ecryptfs_daemon_hash) { |
388 | rc = -ENOMEM; | 384 | rc = -ENOMEM; |
389 | printk(KERN_ERR "%s: Failed to allocate memory\n", __func__); | ||
390 | mutex_unlock(&ecryptfs_daemon_hash_mux); | 385 | mutex_unlock(&ecryptfs_daemon_hash_mux); |
391 | goto out; | 386 | goto out; |
392 | } | 387 | } |
@@ -398,7 +393,6 @@ int __init ecryptfs_init_messaging(void) | |||
398 | GFP_KERNEL); | 393 | GFP_KERNEL); |
399 | if (!ecryptfs_msg_ctx_arr) { | 394 | if (!ecryptfs_msg_ctx_arr) { |
400 | rc = -ENOMEM; | 395 | rc = -ENOMEM; |
401 | printk(KERN_ERR "%s: Failed to allocate memory\n", __func__); | ||
402 | goto out; | 396 | goto out; |
403 | } | 397 | } |
404 | mutex_init(&ecryptfs_msg_ctx_lists_mux); | 398 | mutex_init(&ecryptfs_msg_ctx_lists_mux); |
@@ -442,15 +436,16 @@ void ecryptfs_release_messaging(void) | |||
442 | } | 436 | } |
443 | if (ecryptfs_daemon_hash) { | 437 | if (ecryptfs_daemon_hash) { |
444 | struct ecryptfs_daemon *daemon; | 438 | struct ecryptfs_daemon *daemon; |
439 | struct hlist_node *n; | ||
445 | int i; | 440 | int i; |
446 | 441 | ||
447 | mutex_lock(&ecryptfs_daemon_hash_mux); | 442 | mutex_lock(&ecryptfs_daemon_hash_mux); |
448 | for (i = 0; i < (1 << ecryptfs_hash_bits); i++) { | 443 | for (i = 0; i < (1 << ecryptfs_hash_bits); i++) { |
449 | int rc; | 444 | int rc; |
450 | 445 | ||
451 | hlist_for_each_entry(daemon, | 446 | hlist_for_each_entry_safe(daemon, n, |
452 | &ecryptfs_daemon_hash[i], | 447 | &ecryptfs_daemon_hash[i], |
453 | euid_chain) { | 448 | euid_chain) { |
454 | rc = ecryptfs_exorcise_daemon(daemon); | 449 | rc = ecryptfs_exorcise_daemon(daemon); |
455 | if (rc) | 450 | if (rc) |
456 | printk(KERN_ERR "%s: Error whilst " | 451 | printk(KERN_ERR "%s: Error whilst " |
diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c index e4141f257495..f09cacaf8c80 100644 --- a/fs/ecryptfs/miscdev.c +++ b/fs/ecryptfs/miscdev.c | |||
@@ -163,12 +163,8 @@ int ecryptfs_send_miscdev(char *data, size_t data_size, | |||
163 | struct ecryptfs_message *msg; | 163 | struct ecryptfs_message *msg; |
164 | 164 | ||
165 | msg = kmalloc((sizeof(*msg) + data_size), GFP_KERNEL); | 165 | msg = kmalloc((sizeof(*msg) + data_size), GFP_KERNEL); |
166 | if (!msg) { | 166 | if (!msg) |
167 | printk(KERN_ERR "%s: Out of memory whilst attempting " | ||
168 | "to kmalloc(%zd, GFP_KERNEL)\n", __func__, | ||
169 | (sizeof(*msg) + data_size)); | ||
170 | return -ENOMEM; | 167 | return -ENOMEM; |
171 | } | ||
172 | 168 | ||
173 | mutex_lock(&msg_ctx->mux); | 169 | mutex_lock(&msg_ctx->mux); |
174 | msg_ctx->msg = msg; | 170 | msg_ctx->msg = msg; |
@@ -383,7 +379,7 @@ ecryptfs_miscdev_write(struct file *file, const char __user *buf, | |||
383 | goto memdup; | 379 | goto memdup; |
384 | } else if (count < MIN_MSG_PKT_SIZE || count > MAX_MSG_PKT_SIZE) { | 380 | } else if (count < MIN_MSG_PKT_SIZE || count > MAX_MSG_PKT_SIZE) { |
385 | printk(KERN_WARNING "%s: Acceptable packet size range is " | 381 | printk(KERN_WARNING "%s: Acceptable packet size range is " |
386 | "[%d-%zu], but amount of data written is [%zu].", | 382 | "[%d-%zu], but amount of data written is [%zu].\n", |
387 | __func__, MIN_MSG_PKT_SIZE, MAX_MSG_PKT_SIZE, count); | 383 | __func__, MIN_MSG_PKT_SIZE, MAX_MSG_PKT_SIZE, count); |
388 | return -EINVAL; | 384 | return -EINVAL; |
389 | } | 385 | } |
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c index 1f0c471b4ba3..cdf358b209d9 100644 --- a/fs/ecryptfs/mmap.c +++ b/fs/ecryptfs/mmap.c | |||
@@ -431,8 +431,6 @@ static int ecryptfs_write_inode_size_to_xattr(struct inode *ecryptfs_inode) | |||
431 | } | 431 | } |
432 | xattr_virt = kmem_cache_alloc(ecryptfs_xattr_cache, GFP_KERNEL); | 432 | xattr_virt = kmem_cache_alloc(ecryptfs_xattr_cache, GFP_KERNEL); |
433 | if (!xattr_virt) { | 433 | if (!xattr_virt) { |
434 | printk(KERN_ERR "Out of memory whilst attempting to write " | ||
435 | "inode size to xattr\n"); | ||
436 | rc = -ENOMEM; | 434 | rc = -ENOMEM; |
437 | goto out; | 435 | goto out; |
438 | } | 436 | } |