aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ecryptfs/mmap.c
diff options
context:
space:
mode:
authorTyler Hicks <tyhicks@linux.vnet.ibm.com>2010-02-11 08:10:38 -0500
committerTyler Hicks <tyhicks@linux.vnet.ibm.com>2010-03-23 13:29:49 -0400
commit157f1071354db1aed885816094888e0e257c9d0a (patch)
tree711d00d7dce97f846342db0a27b4a61c6b1966a4 /fs/ecryptfs/mmap.c
parent220bf991b0366cc50a94feede3d7341fa5710ee4 (diff)
eCryptfs: Fix metadata in xattr feature regression
Fixes regression in 8faece5f906725c10e7a1f6caf84452abadbdc7b When using the ecryptfs_xattr_metadata mount option, eCryptfs stores the metadata (normally stored at the front of the file) in the user.ecryptfs xattr. This causes ecryptfs_crypt_stat.num_header_bytes_at_front to be 0, since there is no header data at the front of the file. This results in too much memory being requested and ENOMEM being returned from ecryptfs_write_metadata(). This patch fixes the problem by using the num_header_bytes_at_front variable for specifying the max size of the metadata, despite whether it is stored in the header or xattr. Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Tyler Hicks <tyhicks@linux.vnet.ibm.com>
Diffstat (limited to 'fs/ecryptfs/mmap.c')
-rw-r--r--fs/ecryptfs/mmap.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/fs/ecryptfs/mmap.c b/fs/ecryptfs/mmap.c
index df4ce99d0597..5a30e01547f1 100644
--- a/fs/ecryptfs/mmap.c
+++ b/fs/ecryptfs/mmap.c
@@ -97,19 +97,6 @@ out:
97 * (big-endian) 97 * (big-endian)
98 * Octet 26: Begin RFC 2440 authentication token packet set 98 * Octet 26: Begin RFC 2440 authentication token packet set
99 */ 99 */
100static void set_header_info(char *page_virt,
101 struct ecryptfs_crypt_stat *crypt_stat)
102{
103 size_t written;
104 size_t save_num_header_bytes_at_front =
105 crypt_stat->num_header_bytes_at_front;
106
107 crypt_stat->num_header_bytes_at_front =
108 ECRYPTFS_MINIMUM_HEADER_EXTENT_SIZE;
109 ecryptfs_write_header_metadata(page_virt + 20, crypt_stat, &written);
110 crypt_stat->num_header_bytes_at_front =
111 save_num_header_bytes_at_front;
112}
113 100
114/** 101/**
115 * ecryptfs_copy_up_encrypted_with_header 102 * ecryptfs_copy_up_encrypted_with_header
@@ -146,9 +133,13 @@ ecryptfs_copy_up_encrypted_with_header(struct page *page,
146 memset(page_virt, 0, PAGE_CACHE_SIZE); 133 memset(page_virt, 0, PAGE_CACHE_SIZE);
147 /* TODO: Support more than one header extent */ 134 /* TODO: Support more than one header extent */
148 if (view_extent_num == 0) { 135 if (view_extent_num == 0) {
136 size_t written;
137
149 rc = ecryptfs_read_xattr_region( 138 rc = ecryptfs_read_xattr_region(
150 page_virt, page->mapping->host); 139 page_virt, page->mapping->host);
151 set_header_info(page_virt, crypt_stat); 140 ecryptfs_write_header_metadata(page_virt + 20,
141 crypt_stat,
142 &written);
152 } 143 }
153 kunmap_atomic(page_virt, KM_USER0); 144 kunmap_atomic(page_virt, KM_USER0);
154 flush_dcache_page(page); 145 flush_dcache_page(page);