Two small fixes to the code that initializes the per-file crypto
contexts. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.14 (GNU/Linux) iQIcBAABCgAGBQJSMPiLAAoJENaSAD2qAscKbTUP/iYjgdQGDodEYTVg9ofUaJ8O ltzlIbVweglEW+Z7tr83vM1R29ta95WQK2PpK4SxV6+Jh6nJz9p9WLCvrugUXKOB GOd+WA/8i8lHGdydtnC8Cd3vhHG76oLwR+iv8HzI6TIdMWJMV5bNGT1D6GqADXca 4dl8pD8QTrh4jldjmYyiT8dFR4wfAvfcTvKKemMFY68LXpntVgt580hd7893LOUJ 7elAG0l1sygOWbgroJf1Rqm2OnRP9brET1+TgKAcJrv9AciidVkMCB72srkX82Bz eBGipzFaYT+3lDrK5iM+9l8NnQeYOFIp4JuId1wv28DH06/ExTWqfOZiq5VCq1gb /6spqQGj7mRp7oGk1yIvtTr7TxlbGqmUeP3wbClSmG+nsjAyC7ZsqVzgyJtgxd45 ox06Rf7jufkxbztYOQBa6qWerbvW3zS2Not9Usp5oBWlTLBV1xEVRdEX6QXii1nL z4CQTWgapx0AvuIWAsJbQMVLiHMEGA8luapo9GihODBdaHtX4lnQ3L2GURvjyy3I 0agE37ITpEDAFE4YzR5XquPvqHqlHFHb2PoE+7a96YXXFlR+ZkklAwQd4cbiomCT czFNLcWTmmKbW/i8IS/5wgOfQuNVfDjFXKw1ynCKcuB6mCK+ugImqTG8dT793ldB QVkmgx/s//v2/WbvxzNW =yb4P -----END PGP SIGNATURE----- Merge tag 'ecryptfs-3.12-rc1-crypt-ctx' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs Pull eCryptfs fixes from Tyler Hicks: "Two small fixes to the code that initializes the per-file crypto contexts" * tag 'ecryptfs-3.12-rc1-crypt-ctx' of git://git.kernel.org/pub/scm/linux/kernel/git/tyhicks/ecryptfs: ecryptfs: avoid ctx initialization race ecryptfs: remove check for if an array is NULL
This commit is contained in:
commit
1ae276a911
@ -609,39 +609,35 @@ int ecryptfs_init_crypt_ctx(struct ecryptfs_crypt_stat *crypt_stat)
|
||||
char *full_alg_name;
|
||||
int rc = -EINVAL;
|
||||
|
||||
if (!crypt_stat->cipher) {
|
||||
ecryptfs_printk(KERN_ERR, "No cipher specified\n");
|
||||
goto out;
|
||||
}
|
||||
ecryptfs_printk(KERN_DEBUG,
|
||||
"Initializing cipher [%s]; strlen = [%d]; "
|
||||
"key_size_bits = [%zd]\n",
|
||||
crypt_stat->cipher, (int)strlen(crypt_stat->cipher),
|
||||
crypt_stat->key_size << 3);
|
||||
mutex_lock(&crypt_stat->cs_tfm_mutex);
|
||||
if (crypt_stat->tfm) {
|
||||
rc = 0;
|
||||
goto out;
|
||||
goto out_unlock;
|
||||
}
|
||||
mutex_lock(&crypt_stat->cs_tfm_mutex);
|
||||
rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name,
|
||||
crypt_stat->cipher, "cbc");
|
||||
if (rc)
|
||||
goto out_unlock;
|
||||
crypt_stat->tfm = crypto_alloc_ablkcipher(full_alg_name, 0, 0);
|
||||
kfree(full_alg_name);
|
||||
if (IS_ERR(crypt_stat->tfm)) {
|
||||
rc = PTR_ERR(crypt_stat->tfm);
|
||||
crypt_stat->tfm = NULL;
|
||||
ecryptfs_printk(KERN_ERR, "cryptfs: init_crypt_ctx(): "
|
||||
"Error initializing cipher [%s]\n",
|
||||
crypt_stat->cipher);
|
||||
goto out_unlock;
|
||||
full_alg_name);
|
||||
goto out_free;
|
||||
}
|
||||
crypto_ablkcipher_set_flags(crypt_stat->tfm, CRYPTO_TFM_REQ_WEAK_KEY);
|
||||
rc = 0;
|
||||
out_free:
|
||||
kfree(full_alg_name);
|
||||
out_unlock:
|
||||
mutex_unlock(&crypt_stat->cs_tfm_mutex);
|
||||
out:
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user