forked from mirrors/linux
		
	eCryptfs: Flush file in vma close
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> Cc: stable@kernel.org [2.6.39+]
This commit is contained in:
		
							parent
							
								
									b59db43ad4
								
							
						
					
					
						commit
						32001d6fe9
					
				
					 1 changed files with 22 additions and 1 deletions
				
			
		| 
						 | 
					@ -139,6 +139,27 @@ static int ecryptfs_readdir(struct file *file, void *dirent, filldir_t filldir)
 | 
				
			||||||
	return rc;
 | 
						return rc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void ecryptfs_vma_close(struct vm_area_struct *vma)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						filemap_write_and_wait(vma->vm_file->f_mapping);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const struct vm_operations_struct ecryptfs_file_vm_ops = {
 | 
				
			||||||
 | 
						.close		= ecryptfs_vma_close,
 | 
				
			||||||
 | 
						.fault		= filemap_fault,
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int ecryptfs_file_mmap(struct file *file, struct vm_area_struct *vma)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						int rc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						rc = generic_file_mmap(file, vma);
 | 
				
			||||||
 | 
						if (!rc)
 | 
				
			||||||
 | 
							vma->vm_ops = &ecryptfs_file_vm_ops;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return rc;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
struct kmem_cache *ecryptfs_file_info_cache;
 | 
					struct kmem_cache *ecryptfs_file_info_cache;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -349,7 +370,7 @@ const struct file_operations ecryptfs_main_fops = {
 | 
				
			||||||
#ifdef CONFIG_COMPAT
 | 
					#ifdef CONFIG_COMPAT
 | 
				
			||||||
	.compat_ioctl = ecryptfs_compat_ioctl,
 | 
						.compat_ioctl = ecryptfs_compat_ioctl,
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
	.mmap = generic_file_mmap,
 | 
						.mmap = ecryptfs_file_mmap,
 | 
				
			||||||
	.open = ecryptfs_open,
 | 
						.open = ecryptfs_open,
 | 
				
			||||||
	.flush = ecryptfs_flush,
 | 
						.flush = ecryptfs_flush,
 | 
				
			||||||
	.release = ecryptfs_release,
 | 
						.release = ecryptfs_release,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue