Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm crypt: omit parsing of the encapsulated cipher

Only the ESSIV IV generation mode used to use cc->cipher so it could
instantiate the bare cipher used to encrypt the IV. However, this is
now taken care of by the ESSIV template, and so no users of cc->cipher
remain. So remove it altogether.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

Ard Biesheuvel and committed by
Mike Snitzer
b1d1e296 a1a262b6

-58
-58
drivers/md/dm-crypt.c
··· 143 143 struct task_struct *write_thread; 144 144 struct rb_root write_tree; 145 145 146 - char *cipher; 147 146 char *cipher_string; 148 147 char *cipher_auth; 149 148 char *key_string; ··· 2139 2140 if (cc->dev) 2140 2141 dm_put_device(ti, cc->dev); 2141 2142 2142 - kzfree(cc->cipher); 2143 2143 kzfree(cc->cipher_string); 2144 2144 kzfree(cc->key_string); 2145 2145 kzfree(cc->cipher_auth); ··· 2215 2217 ti->error = "Invalid IV mode"; 2216 2218 return -EINVAL; 2217 2219 } 2218 - 2219 - return 0; 2220 - } 2221 - 2222 - /* 2223 - * Workaround to parse cipher algorithm from crypto API spec. 2224 - * The cc->cipher is currently used only in ESSIV. 2225 - * This should be probably done by crypto-api calls (once available...) 2226 - */ 2227 - static int crypt_ctr_blkdev_cipher(struct crypt_config *cc) 2228 - { 2229 - const char *alg_name = NULL; 2230 - char *start, *end; 2231 - 2232 - if (crypt_integrity_aead(cc)) { 2233 - alg_name = crypto_tfm_alg_name(crypto_aead_tfm(any_tfm_aead(cc))); 2234 - if (!alg_name) 2235 - return -EINVAL; 2236 - if (crypt_integrity_hmac(cc)) { 2237 - alg_name = strchr(alg_name, ','); 2238 - if (!alg_name) 2239 - return -EINVAL; 2240 - } 2241 - alg_name++; 2242 - } else { 2243 - alg_name = crypto_tfm_alg_name(crypto_skcipher_tfm(any_tfm(cc))); 2244 - if (!alg_name) 2245 - return -EINVAL; 2246 - } 2247 - 2248 - start = strchr(alg_name, '('); 2249 - end = strchr(alg_name, ')'); 2250 - 2251 - if (!start && !end) { 2252 - cc->cipher = kstrdup(alg_name, GFP_KERNEL); 2253 - return cc->cipher ? 0 : -ENOMEM; 2254 - } 2255 - 2256 - if (!start || !end || ++start >= end) 2257 - return -EINVAL; 2258 - 2259 - cc->cipher = kzalloc(end - start + 1, GFP_KERNEL); 2260 - if (!cc->cipher) 2261 - return -ENOMEM; 2262 - 2263 - strncpy(cc->cipher, start, end - start); 2264 2220 2265 2221 return 0; 2266 2222 } ··· 2328 2376 else 2329 2377 cc->iv_size = crypto_skcipher_ivsize(any_tfm(cc)); 2330 2378 2331 - ret = crypt_ctr_blkdev_cipher(cc); 2332 - if (ret < 0) { 2333 - ti->error = "Cannot allocate cipher string"; 2334 - return -ENOMEM; 2335 - } 2336 - 2337 2379 return 0; 2338 2380 } 2339 2381 ··· 2361 2415 return -EINVAL; 2362 2416 } 2363 2417 cc->key_parts = cc->tfms_count; 2364 - 2365 - cc->cipher = kstrdup(cipher, GFP_KERNEL); 2366 - if (!cc->cipher) 2367 - goto bad_mem; 2368 2418 2369 2419 chainmode = strsep(&tmp, "-"); 2370 2420 *ivmode = strsep(&tmp, ":");