diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2016-04-16 15:01:09 +0800 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2016-04-20 17:50:01 +0800 |
commit | e81f3340bba2bdcdf021aff511830e718e6e2112 (patch) | |
tree | 2fce034abb35b8caed6170cb9ebad27cc813f95f /fs/ecryptfs/super.c | |
parent | b3ab30a7cbdaf7ba20dddeac252cc0238312fff0 (diff) | |
download | linux-e81f3340bba2bdcdf021aff511830e718e6e2112.tar.gz linux-e81f3340bba2bdcdf021aff511830e718e6e2112.tar.bz2 linux-e81f3340bba2bdcdf021aff511830e718e6e2112.zip |
eCryptfs: Do not allocate hash tfm in NORECLAIM context
You cannot allocate crypto tfm objects in NORECLAIM or NOFS contexts.
The ecryptfs code currently does exactly that for the MD5 tfm.
This patch fixes it by preallocating the MD5 tfm in a safe context.
The MD5 tfm is also reentrant so this patch removes the superfluous
cs_hash_tfm_mutex.
Reported-by: Nicolas Boichat <drinkcat@chromium.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'fs/ecryptfs/super.c')
-rw-r--r-- | fs/ecryptfs/super.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/ecryptfs/super.c b/fs/ecryptfs/super.c index 77a486d3a51b..85411ceb0508 100644 --- a/fs/ecryptfs/super.c +++ b/fs/ecryptfs/super.c @@ -55,7 +55,10 @@ static struct inode *ecryptfs_alloc_inode(struct super_block *sb) inode_info = kmem_cache_alloc(ecryptfs_inode_info_cache, GFP_KERNEL); if (unlikely(!inode_info)) goto out; - ecryptfs_init_crypt_stat(&inode_info->crypt_stat); + if (ecryptfs_init_crypt_stat(&inode_info->crypt_stat)) { + kmem_cache_free(ecryptfs_inode_info_cache, inode_info); + goto out; + } mutex_init(&inode_info->lower_file_mutex); atomic_set(&inode_info->lower_file_count, 0); inode_info->lower_file = NULL; |