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

iscsi-target: Use shash and ahash

This patch replaces uses of the long obsolete hash interface with
either shash (for non-SG users) or ahash.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+117 -124
+46 -40
drivers/target/iscsi/iscsi_target.c
··· 16 16 * GNU General Public License for more details. 17 17 ******************************************************************************/ 18 18 19 + #include <crypto/hash.h> 19 20 #include <linux/string.h> 20 21 #include <linux/kthread.h> 21 - #include <linux/crypto.h> 22 22 #include <linux/completion.h> 23 23 #include <linux/module.h> 24 24 #include <linux/vmalloc.h> ··· 1190 1190 } 1191 1191 1192 1192 static u32 iscsit_do_crypto_hash_sg( 1193 - struct hash_desc *hash, 1193 + struct ahash_request *hash, 1194 1194 struct iscsi_cmd *cmd, 1195 1195 u32 data_offset, 1196 1196 u32 data_length, ··· 1201 1201 struct scatterlist *sg; 1202 1202 unsigned int page_off; 1203 1203 1204 - crypto_hash_init(hash); 1204 + crypto_ahash_init(hash); 1205 1205 1206 1206 sg = cmd->first_data_sg; 1207 1207 page_off = cmd->first_data_sg_off; ··· 1209 1209 while (data_length) { 1210 1210 u32 cur_len = min_t(u32, data_length, (sg->length - page_off)); 1211 1211 1212 - crypto_hash_update(hash, sg, cur_len); 1212 + ahash_request_set_crypt(hash, sg, NULL, cur_len); 1213 + crypto_ahash_update(hash); 1213 1214 1214 1215 data_length -= cur_len; 1215 1216 page_off = 0; ··· 1222 1221 struct scatterlist pad_sg; 1223 1222 1224 1223 sg_init_one(&pad_sg, pad_bytes, padding); 1225 - crypto_hash_update(hash, &pad_sg, padding); 1224 + ahash_request_set_crypt(hash, &pad_sg, (u8 *)&data_crc, 1225 + padding); 1226 + crypto_ahash_finup(hash); 1227 + } else { 1228 + ahash_request_set_crypt(hash, NULL, (u8 *)&data_crc, 0); 1229 + crypto_ahash_final(hash); 1226 1230 } 1227 - crypto_hash_final(hash, (u8 *) &data_crc); 1228 1231 1229 1232 return data_crc; 1230 1233 } 1231 1234 1232 1235 static void iscsit_do_crypto_hash_buf( 1233 - struct hash_desc *hash, 1236 + struct ahash_request *hash, 1234 1237 const void *buf, 1235 1238 u32 payload_length, 1236 1239 u32 padding, 1237 1240 u8 *pad_bytes, 1238 1241 u8 *data_crc) 1239 1242 { 1240 - struct scatterlist sg; 1243 + struct scatterlist sg[2]; 1241 1244 1242 - crypto_hash_init(hash); 1245 + sg_init_table(sg, ARRAY_SIZE(sg)); 1246 + sg_set_buf(sg, buf, payload_length); 1247 + sg_set_buf(sg + 1, pad_bytes, padding); 1243 1248 1244 - sg_init_one(&sg, buf, payload_length); 1245 - crypto_hash_update(hash, &sg, payload_length); 1249 + ahash_request_set_crypt(hash, sg, data_crc, payload_length + padding); 1246 1250 1247 - if (padding) { 1248 - sg_init_one(&sg, pad_bytes, padding); 1249 - crypto_hash_update(hash, &sg, padding); 1250 - } 1251 - crypto_hash_final(hash, data_crc); 1251 + crypto_ahash_digest(hash); 1252 1252 } 1253 1253 1254 1254 int ··· 1424 1422 if (conn->conn_ops->DataDigest) { 1425 1423 u32 data_crc; 1426 1424 1427 - data_crc = iscsit_do_crypto_hash_sg(&conn->conn_rx_hash, cmd, 1425 + data_crc = iscsit_do_crypto_hash_sg(conn->conn_rx_hash, cmd, 1428 1426 be32_to_cpu(hdr->offset), 1429 1427 payload_length, padding, 1430 1428 cmd->pad_bytes); ··· 1684 1682 } 1685 1683 1686 1684 if (conn->conn_ops->DataDigest) { 1687 - iscsit_do_crypto_hash_buf(&conn->conn_rx_hash, 1685 + iscsit_do_crypto_hash_buf(conn->conn_rx_hash, 1688 1686 ping_data, payload_length, 1689 1687 padding, cmd->pad_bytes, 1690 1688 (u8 *)&data_crc); ··· 2103 2101 goto reject; 2104 2102 2105 2103 if (conn->conn_ops->DataDigest) { 2106 - iscsit_do_crypto_hash_buf(&conn->conn_rx_hash, 2104 + iscsit_do_crypto_hash_buf(conn->conn_rx_hash, 2107 2105 text_in, payload_length, 2108 2106 padding, (u8 *)&pad_bytes, 2109 2107 (u8 *)&data_crc); ··· 2442 2440 if (conn->conn_ops->DataDigest) { 2443 2441 u32 data_crc; 2444 2442 2445 - data_crc = iscsit_do_crypto_hash_sg(&conn->conn_rx_hash, cmd, 2443 + data_crc = iscsit_do_crypto_hash_sg(conn->conn_rx_hash, cmd, 2446 2444 cmd->write_data_done, length, padding, 2447 2445 cmd->pad_bytes); 2448 2446 ··· 2555 2553 if (conn->conn_ops->HeaderDigest) { 2556 2554 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2557 2555 2558 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2556 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr, 2559 2557 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2560 2558 2561 2559 cmd->tx_size += ISCSI_CRC_LEN; ··· 2685 2683 if (conn->conn_ops->HeaderDigest) { 2686 2684 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2687 2685 2688 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->pdu, 2686 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, cmd->pdu, 2689 2687 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2690 2688 2691 2689 iov[0].iov_len += ISCSI_CRC_LEN; ··· 2713 2711 cmd->padding); 2714 2712 } 2715 2713 if (conn->conn_ops->DataDigest) { 2716 - cmd->data_crc = iscsit_do_crypto_hash_sg(&conn->conn_tx_hash, cmd, 2714 + cmd->data_crc = iscsit_do_crypto_hash_sg(conn->conn_tx_hash, cmd, 2717 2715 datain.offset, datain.length, cmd->padding, cmd->pad_bytes); 2718 2716 2719 2717 iov[iov_count].iov_base = &cmd->data_crc; ··· 2859 2857 if (conn->conn_ops->HeaderDigest) { 2860 2858 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2861 2859 2862 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, &cmd->pdu[0], 2860 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, &cmd->pdu[0], 2863 2861 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2864 2862 2865 2863 iov[0].iov_len += ISCSI_CRC_LEN; ··· 2917 2915 if (conn->conn_ops->HeaderDigest) { 2918 2916 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2919 2917 2920 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2918 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr, 2921 2919 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2922 2920 2923 2921 tx_size += ISCSI_CRC_LEN; ··· 2965 2963 if (conn->conn_ops->HeaderDigest) { 2966 2964 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 2967 2965 2968 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 2966 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr, 2969 2967 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 2970 2968 2971 2969 iov[0].iov_len += ISCSI_CRC_LEN; ··· 2995 2993 " padding bytes.\n", padding); 2996 2994 } 2997 2995 if (conn->conn_ops->DataDigest) { 2998 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 2996 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, 2999 2997 cmd->buf_ptr, cmd->buf_ptr_size, 3000 2998 padding, (u8 *)&cmd->pad_bytes, 3001 2999 (u8 *)&cmd->data_crc); ··· 3051 3049 if (conn->conn_ops->HeaderDigest) { 3052 3050 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3053 3051 3054 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3052 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr, 3055 3053 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3056 3054 3057 3055 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN; ··· 3241 3239 } 3242 3240 3243 3241 if (conn->conn_ops->DataDigest) { 3244 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3242 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, 3245 3243 cmd->sense_buffer, 3246 3244 (cmd->se_cmd.scsi_sense_length + padding), 3247 3245 0, NULL, (u8 *)&cmd->data_crc); ··· 3264 3262 if (conn->conn_ops->HeaderDigest) { 3265 3263 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3266 3264 3267 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->pdu, 3265 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, cmd->pdu, 3268 3266 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3269 3267 3270 3268 iov[0].iov_len += ISCSI_CRC_LEN; ··· 3334 3332 if (conn->conn_ops->HeaderDigest) { 3335 3333 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3336 3334 3337 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3335 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr, 3338 3336 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3339 3337 3340 3338 cmd->iov_misc[0].iov_len += ISCSI_CRC_LEN; ··· 3603 3601 if (conn->conn_ops->HeaderDigest) { 3604 3602 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3605 3603 3606 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3604 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr, 3607 3605 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3608 3606 3609 3607 iov[0].iov_len += ISCSI_CRC_LEN; ··· 3613 3611 } 3614 3612 3615 3613 if (conn->conn_ops->DataDigest) { 3616 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, 3614 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, 3617 3615 cmd->buf_ptr, text_length, 3618 3616 0, NULL, (u8 *)&cmd->data_crc); 3619 3617 ··· 3670 3668 if (conn->conn_ops->HeaderDigest) { 3671 3669 u32 *header_digest = (u32 *)&cmd->pdu[ISCSI_HDR_LEN]; 3672 3670 3673 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, hdr, 3671 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, hdr, 3674 3672 ISCSI_HDR_LEN, 0, NULL, (u8 *)header_digest); 3675 3673 3676 3674 iov[0].iov_len += ISCSI_CRC_LEN; ··· 3680 3678 } 3681 3679 3682 3680 if (conn->conn_ops->DataDigest) { 3683 - iscsit_do_crypto_hash_buf(&conn->conn_tx_hash, cmd->buf_ptr, 3681 + iscsit_do_crypto_hash_buf(conn->conn_tx_hash, cmd->buf_ptr, 3684 3682 ISCSI_HDR_LEN, 0, NULL, (u8 *)&cmd->data_crc); 3685 3683 3686 3684 iov[iov_count].iov_base = &cmd->data_crc; ··· 4147 4145 goto transport_err; 4148 4146 } 4149 4147 4150 - iscsit_do_crypto_hash_buf(&conn->conn_rx_hash, 4148 + iscsit_do_crypto_hash_buf(conn->conn_rx_hash, 4151 4149 buffer, ISCSI_HDR_LEN, 4152 4150 0, NULL, (u8 *)&checksum); 4153 4151 ··· 4361 4359 */ 4362 4360 iscsit_check_conn_usage_count(conn); 4363 4361 4364 - if (conn->conn_rx_hash.tfm) 4365 - crypto_free_hash(conn->conn_rx_hash.tfm); 4366 - if (conn->conn_tx_hash.tfm) 4367 - crypto_free_hash(conn->conn_tx_hash.tfm); 4362 + ahash_request_free(conn->conn_tx_hash); 4363 + if (conn->conn_rx_hash) { 4364 + struct crypto_ahash *tfm; 4365 + 4366 + tfm = crypto_ahash_reqtfm(conn->conn_rx_hash); 4367 + ahash_request_free(conn->conn_rx_hash); 4368 + crypto_free_ahash(tfm); 4369 + } 4368 4370 4369 4371 free_cpumask_var(conn->conn_cpumask); 4370 4372
+40 -66
drivers/target/iscsi/iscsi_target_auth.c
··· 16 16 * GNU General Public License for more details. 17 17 ******************************************************************************/ 18 18 19 + #include <crypto/hash.h> 19 20 #include <linux/kernel.h> 20 21 #include <linux/string.h> 21 - #include <linux/crypto.h> 22 22 #include <linux/err.h> 23 23 #include <linux/scatterlist.h> 24 24 ··· 185 185 unsigned char chap_n[MAX_CHAP_N_SIZE], chap_r[MAX_RESPONSE_LENGTH]; 186 186 size_t compare_len; 187 187 struct iscsi_chap *chap = conn->auth_protocol; 188 - struct crypto_hash *tfm; 189 - struct hash_desc desc; 190 - struct scatterlist sg; 188 + struct crypto_shash *tfm = NULL; 189 + struct shash_desc *desc = NULL; 191 190 int auth_ret = -1, ret, challenge_len; 192 191 193 192 memset(identifier, 0, 10); ··· 244 245 pr_debug("[server] Got CHAP_R=%s\n", chap_r); 245 246 chap_string_to_hex(client_digest, chap_r, strlen(chap_r)); 246 247 247 - tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); 248 + tfm = crypto_alloc_shash("md5", 0, 0); 248 249 if (IS_ERR(tfm)) { 249 - pr_err("Unable to allocate struct crypto_hash\n"); 250 - goto out; 251 - } 252 - desc.tfm = tfm; 253 - desc.flags = 0; 254 - 255 - ret = crypto_hash_init(&desc); 256 - if (ret < 0) { 257 - pr_err("crypto_hash_init() failed\n"); 258 - crypto_free_hash(tfm); 250 + tfm = NULL; 251 + pr_err("Unable to allocate struct crypto_shash\n"); 259 252 goto out; 260 253 } 261 254 262 - sg_init_one(&sg, &chap->id, 1); 263 - ret = crypto_hash_update(&desc, &sg, 1); 264 - if (ret < 0) { 265 - pr_err("crypto_hash_update() failed for id\n"); 266 - crypto_free_hash(tfm); 255 + desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(tfm), GFP_KERNEL); 256 + if (!desc) { 257 + pr_err("Unable to allocate struct shash_desc\n"); 267 258 goto out; 268 259 } 269 260 270 - sg_init_one(&sg, &auth->password, strlen(auth->password)); 271 - ret = crypto_hash_update(&desc, &sg, strlen(auth->password)); 261 + desc->tfm = tfm; 262 + desc->flags = 0; 263 + 264 + ret = crypto_shash_init(desc); 272 265 if (ret < 0) { 273 - pr_err("crypto_hash_update() failed for password\n"); 274 - crypto_free_hash(tfm); 266 + pr_err("crypto_shash_init() failed\n"); 275 267 goto out; 276 268 } 277 269 278 - sg_init_one(&sg, chap->challenge, CHAP_CHALLENGE_LENGTH); 279 - ret = crypto_hash_update(&desc, &sg, CHAP_CHALLENGE_LENGTH); 270 + ret = crypto_shash_update(desc, &chap->id, 1); 280 271 if (ret < 0) { 281 - pr_err("crypto_hash_update() failed for challenge\n"); 282 - crypto_free_hash(tfm); 272 + pr_err("crypto_shash_update() failed for id\n"); 283 273 goto out; 284 274 } 285 275 286 - ret = crypto_hash_final(&desc, server_digest); 276 + ret = crypto_shash_update(desc, (char *)&auth->password, 277 + strlen(auth->password)); 287 278 if (ret < 0) { 288 - pr_err("crypto_hash_final() failed for server digest\n"); 289 - crypto_free_hash(tfm); 279 + pr_err("crypto_shash_update() failed for password\n"); 290 280 goto out; 291 281 } 292 - crypto_free_hash(tfm); 282 + 283 + ret = crypto_shash_finup(desc, chap->challenge, 284 + CHAP_CHALLENGE_LENGTH, server_digest); 285 + if (ret < 0) { 286 + pr_err("crypto_shash_finup() failed for challenge\n"); 287 + goto out; 288 + } 293 289 294 290 chap_binaryhex_to_asciihex(response, server_digest, MD5_SIGNATURE_SIZE); 295 291 pr_debug("[server] MD5 Server Digest: %s\n", response); ··· 300 306 * authentication is not enabled. 301 307 */ 302 308 if (!auth->authenticate_target) { 303 - kfree(challenge); 304 - kfree(challenge_binhex); 305 - return 0; 309 + auth_ret = 0; 310 + goto out; 306 311 } 307 312 /* 308 313 * Get CHAP_I. ··· 365 372 /* 366 373 * Generate CHAP_N and CHAP_R for mutual authentication. 367 374 */ 368 - tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); 369 - if (IS_ERR(tfm)) { 370 - pr_err("Unable to allocate struct crypto_hash\n"); 371 - goto out; 372 - } 373 - desc.tfm = tfm; 374 - desc.flags = 0; 375 - 376 - ret = crypto_hash_init(&desc); 375 + ret = crypto_shash_init(desc); 377 376 if (ret < 0) { 378 - pr_err("crypto_hash_init() failed\n"); 379 - crypto_free_hash(tfm); 377 + pr_err("crypto_shash_init() failed\n"); 380 378 goto out; 381 379 } 382 380 383 381 /* To handle both endiannesses */ 384 382 id_as_uchar = id; 385 - sg_init_one(&sg, &id_as_uchar, 1); 386 - ret = crypto_hash_update(&desc, &sg, 1); 383 + ret = crypto_shash_update(desc, &id_as_uchar, 1); 387 384 if (ret < 0) { 388 - pr_err("crypto_hash_update() failed for id\n"); 389 - crypto_free_hash(tfm); 385 + pr_err("crypto_shash_update() failed for id\n"); 390 386 goto out; 391 387 } 392 388 393 - sg_init_one(&sg, auth->password_mutual, 394 - strlen(auth->password_mutual)); 395 - ret = crypto_hash_update(&desc, &sg, strlen(auth->password_mutual)); 389 + ret = crypto_shash_update(desc, auth->password_mutual, 390 + strlen(auth->password_mutual)); 396 391 if (ret < 0) { 397 - pr_err("crypto_hash_update() failed for" 392 + pr_err("crypto_shash_update() failed for" 398 393 " password_mutual\n"); 399 - crypto_free_hash(tfm); 400 394 goto out; 401 395 } 402 396 /* 403 397 * Convert received challenge to binary hex. 404 398 */ 405 - sg_init_one(&sg, challenge_binhex, challenge_len); 406 - ret = crypto_hash_update(&desc, &sg, challenge_len); 399 + ret = crypto_shash_finup(desc, challenge_binhex, challenge_len, 400 + digest); 407 401 if (ret < 0) { 408 - pr_err("crypto_hash_update() failed for ma challenge\n"); 409 - crypto_free_hash(tfm); 402 + pr_err("crypto_shash_finup() failed for ma challenge\n"); 410 403 goto out; 411 404 } 412 405 413 - ret = crypto_hash_final(&desc, digest); 414 - if (ret < 0) { 415 - pr_err("crypto_hash_final() failed for ma digest\n"); 416 - crypto_free_hash(tfm); 417 - goto out; 418 - } 419 - crypto_free_hash(tfm); 420 406 /* 421 407 * Generate CHAP_N and CHAP_R. 422 408 */ ··· 412 440 pr_debug("[server] Sending CHAP_R=0x%s\n", response); 413 441 auth_ret = 0; 414 442 out: 443 + kzfree(desc); 444 + crypto_free_shash(tfm); 415 445 kfree(challenge); 416 446 kfree(challenge_binhex); 417 447 return auth_ret;
+29 -16
drivers/target/iscsi/iscsi_target_login.c
··· 16 16 * GNU General Public License for more details. 17 17 ******************************************************************************/ 18 18 19 + #include <crypto/hash.h> 19 20 #include <linux/string.h> 20 21 #include <linux/kthread.h> 21 - #include <linux/crypto.h> 22 22 #include <linux/idr.h> 23 23 #include <scsi/iscsi_proto.h> 24 24 #include <target/target_core_base.h> ··· 115 115 */ 116 116 int iscsi_login_setup_crypto(struct iscsi_conn *conn) 117 117 { 118 + struct crypto_ahash *tfm; 119 + 118 120 /* 119 121 * Setup slicing by CRC32C algorithm for RX and TX libcrypto contexts 120 122 * which will default to crc32c_intel.ko for cpu_has_xmm4_2, or fallback 121 123 * to software 1x8 byte slicing from crc32c.ko 122 124 */ 123 - conn->conn_rx_hash.flags = 0; 124 - conn->conn_rx_hash.tfm = crypto_alloc_hash("crc32c", 0, 125 - CRYPTO_ALG_ASYNC); 126 - if (IS_ERR(conn->conn_rx_hash.tfm)) { 127 - pr_err("crypto_alloc_hash() failed for conn_rx_tfm\n"); 125 + tfm = crypto_alloc_ahash("crc32c", 0, CRYPTO_ALG_ASYNC); 126 + if (IS_ERR(tfm)) { 127 + pr_err("crypto_alloc_ahash() failed\n"); 128 128 return -ENOMEM; 129 129 } 130 130 131 - conn->conn_tx_hash.flags = 0; 132 - conn->conn_tx_hash.tfm = crypto_alloc_hash("crc32c", 0, 133 - CRYPTO_ALG_ASYNC); 134 - if (IS_ERR(conn->conn_tx_hash.tfm)) { 135 - pr_err("crypto_alloc_hash() failed for conn_tx_tfm\n"); 136 - crypto_free_hash(conn->conn_rx_hash.tfm); 131 + conn->conn_rx_hash = ahash_request_alloc(tfm, GFP_KERNEL); 132 + if (!conn->conn_rx_hash) { 133 + pr_err("ahash_request_alloc() failed for conn_rx_hash\n"); 134 + crypto_free_ahash(tfm); 137 135 return -ENOMEM; 138 136 } 137 + ahash_request_set_callback(conn->conn_rx_hash, 0, NULL, NULL); 138 + 139 + conn->conn_tx_hash = ahash_request_alloc(tfm, GFP_KERNEL); 140 + if (!conn->conn_tx_hash) { 141 + pr_err("ahash_request_alloc() failed for conn_tx_hash\n"); 142 + ahash_request_free(conn->conn_rx_hash); 143 + conn->conn_rx_hash = NULL; 144 + crypto_free_ahash(tfm); 145 + return -ENOMEM; 146 + } 147 + ahash_request_set_callback(conn->conn_tx_hash, 0, NULL, NULL); 139 148 140 149 return 0; 141 150 } ··· 1183 1174 iscsit_dec_session_usage_count(conn->sess); 1184 1175 } 1185 1176 1186 - if (!IS_ERR(conn->conn_rx_hash.tfm)) 1187 - crypto_free_hash(conn->conn_rx_hash.tfm); 1188 - if (!IS_ERR(conn->conn_tx_hash.tfm)) 1189 - crypto_free_hash(conn->conn_tx_hash.tfm); 1177 + ahash_request_free(conn->conn_tx_hash); 1178 + if (conn->conn_rx_hash) { 1179 + struct crypto_ahash *tfm; 1180 + 1181 + tfm = crypto_ahash_reqtfm(conn->conn_rx_hash); 1182 + ahash_request_free(conn->conn_rx_hash); 1183 + crypto_free_ahash(tfm); 1184 + } 1190 1185 1191 1186 free_cpumask_var(conn->conn_cpumask); 1192 1187
+2 -2
include/target/iscsi/iscsi_target_core.h
··· 570 570 spinlock_t response_queue_lock; 571 571 spinlock_t state_lock; 572 572 /* libcrypto RX and TX contexts for crc32c */ 573 - struct hash_desc conn_rx_hash; 574 - struct hash_desc conn_tx_hash; 573 + struct ahash_request *conn_rx_hash; 574 + struct ahash_request *conn_tx_hash; 575 575 /* Used for scheduling TX and RX connection kthreads */ 576 576 cpumask_var_t conn_cpumask; 577 577 unsigned int conn_rx_reset_cpumask:1;