Commit decabd66 authored by Al Viro's avatar Al Viro
Browse files

fix a couple of ecryptfs leaks



First of all, get_sb_nodev() grabs anon dev minor and we
never free it in ecryptfs ->kill_sb().  Moreover, on one
of the failure exits in ecryptfs_get_sb() we leak things -
it happens before we set ->s_root and ->put_super() won't
be called in that case.  Solution: kill ->put_super(), do
all that stuff in ->kill_sb().  And use kill_anon_sb() instead
of generic_shutdown_super() to deal with anon dev leak.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 89468071
...@@ -633,11 +633,16 @@ out: ...@@ -633,11 +633,16 @@ out:
* @sb: The ecryptfs super block * @sb: The ecryptfs super block
* *
* Used to bring the superblock down and free the private data. * Used to bring the superblock down and free the private data.
* Private data is free'd in ecryptfs_put_super()
*/ */
static void ecryptfs_kill_block_super(struct super_block *sb) static void ecryptfs_kill_block_super(struct super_block *sb)
{ {
generic_shutdown_super(sb); struct ecryptfs_sb_info *sb_info = ecryptfs_superblock_to_private(sb);
kill_anon_super(sb);
if (!sb_info)
return;
ecryptfs_destroy_mount_crypt_stat(&sb_info->mount_crypt_stat);
bdi_destroy(&sb_info->bdi);
kmem_cache_free(ecryptfs_sb_info_cache, sb_info);
} }
static struct file_system_type ecryptfs_fs_type = { static struct file_system_type ecryptfs_fs_type = {
......
...@@ -108,27 +108,6 @@ void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode) ...@@ -108,27 +108,6 @@ void ecryptfs_init_inode(struct inode *inode, struct inode *lower_inode)
inode->i_mapping->a_ops = &ecryptfs_aops; inode->i_mapping->a_ops = &ecryptfs_aops;
} }
/**
* ecryptfs_put_super
* @sb: Pointer to the ecryptfs super block
*
* Final actions when unmounting a file system.
* This will handle deallocation and release of our private data.
*/
static void ecryptfs_put_super(struct super_block *sb)
{
struct ecryptfs_sb_info *sb_info = ecryptfs_superblock_to_private(sb);
lock_kernel();
ecryptfs_destroy_mount_crypt_stat(&sb_info->mount_crypt_stat);
bdi_destroy(&sb_info->bdi);
kmem_cache_free(ecryptfs_sb_info_cache, sb_info);
ecryptfs_set_superblock_private(sb, NULL);
unlock_kernel();
}
/** /**
* ecryptfs_statfs * ecryptfs_statfs
* @sb: The ecryptfs super block * @sb: The ecryptfs super block
...@@ -203,7 +182,6 @@ const struct super_operations ecryptfs_sops = { ...@@ -203,7 +182,6 @@ const struct super_operations ecryptfs_sops = {
.alloc_inode = ecryptfs_alloc_inode, .alloc_inode = ecryptfs_alloc_inode,
.destroy_inode = ecryptfs_destroy_inode, .destroy_inode = ecryptfs_destroy_inode,
.drop_inode = generic_delete_inode, .drop_inode = generic_delete_inode,
.put_super = ecryptfs_put_super,
.statfs = ecryptfs_statfs, .statfs = ecryptfs_statfs,
.remount_fs = NULL, .remount_fs = NULL,
.clear_inode = ecryptfs_clear_inode, .clear_inode = ecryptfs_clear_inode,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment