diff options
author | Tyler Hicks <tyhicks@canonical.com> | 2011-11-21 18:31:29 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-12-09 11:52:18 -0500 |
commit | 051726ea7a7d39c03cb5653c962b0b6f47b5cc37 (patch) | |
tree | 66eff6df3e7bfa8a1e0af89f537e9eed304514fe /fs/ecryptfs | |
parent | ac6766564c0305ca020fe747dfd7dbdf0881369d (diff) |
eCryptfs: Flush file in vma close
commit 32001d6fe9ac6b0423e674a3093aa56740849f3b upstream.
Dirty pages weren't being written back when an mmap'ed eCryptfs file was
closed before the mapping was unmapped. Since f_ops->flush() is not
called by the munmap() path, the lower file was simply being released.
This patch flushes the eCryptfs file in the vm_ops->close() path.
https://launchpad.net/bugs/870326
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/ecryptfs')
-rw-r--r-- | fs/ecryptfs/file.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/fs/ecryptfs/file.c b/fs/ecryptfs/file.c index 4ec9eb00a24..0c1a6527004 100644 --- a/fs/ecryptfs/file.c +++ b/fs/ecryptfs/file.c | |||
@@ -139,6 +139,27 @@ out: | |||
139 | return rc; | 139 | return rc; |
140 | } | 140 | } |
141 | 141 | ||
142 | static void ecryptfs_vma_close(struct vm_area_struct *vma) | ||
143 | { | ||
144 | filemap_write_and_wait(vma->vm_file->f_mapping); | ||
145 | } | ||
146 | |||
147 | static const struct vm_operations_struct ecryptfs_file_vm_ops = { | ||
148 | .close = ecryptfs_vma_close, | ||
149 | .fault = filemap_fault, | ||
150 | }; | ||
151 | |||
152 | static int ecryptfs_file_mmap(struct file *file, struct vm_area_struct *vma) | ||
153 | { | ||
154 | int rc; | ||
155 | |||
156 | rc = generic_file_mmap(file, vma); | ||
157 | if (!rc) | ||
158 | vma->vm_ops = &ecryptfs_file_vm_ops; | ||
159 | |||
160 | return rc; | ||
161 | } | ||
162 | |||
142 | struct kmem_cache *ecryptfs_file_info_cache; | 163 | struct kmem_cache *ecryptfs_file_info_cache; |
143 | 164 | ||
144 | /** | 165 | /** |
@@ -348,7 +369,7 @@ const struct file_operations ecryptfs_main_fops = { | |||
348 | #ifdef CONFIG_COMPAT | 369 | #ifdef CONFIG_COMPAT |
349 | .compat_ioctl = ecryptfs_compat_ioctl, | 370 | .compat_ioctl = ecryptfs_compat_ioctl, |
350 | #endif | 371 | #endif |
351 | .mmap = generic_file_mmap, | 372 | .mmap = ecryptfs_file_mmap, |
352 | .open = ecryptfs_open, | 373 | .open = ecryptfs_open, |
353 | .flush = ecryptfs_flush, | 374 | .flush = ecryptfs_flush, |
354 | .release = ecryptfs_release, | 375 | .release = ecryptfs_release, |