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

Merge tag 'v6.5-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6

Pull crypto fixes from Herbert Xu:
"Fix a couple of regressions in af_alg and incorrect return values in
crypto/asymmetric_keys/public_key"

* tag 'v6.5-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
crypto: algif_hash - Fix race between MORE and non-MORE sends
KEYS: asymmetric: Fix error codes
crypto: af_alg - Fix merging of written data into spliced pages

+22 -9
+4 -3
crypto/af_alg.c
··· 992 992 ssize_t plen; 993 993 994 994 /* use the existing memory in an allocated page */ 995 - if (ctx->merge) { 995 + if (ctx->merge && !(msg->msg_flags & MSG_SPLICE_PAGES)) { 996 996 sgl = list_entry(ctx->tsgl_list.prev, 997 997 struct af_alg_tsgl, list); 998 998 sg = sgl->sg + sgl->cur - 1; ··· 1054 1054 ctx->used += plen; 1055 1055 copied += plen; 1056 1056 size -= plen; 1057 + ctx->merge = 0; 1057 1058 } else { 1058 1059 do { 1059 1060 struct page *pg; ··· 1086 1085 size -= plen; 1087 1086 sgl->cur++; 1088 1087 } while (len && sgl->cur < MAX_SGL_ENTS); 1088 + 1089 + ctx->merge = plen & (PAGE_SIZE - 1); 1089 1090 } 1090 1091 1091 1092 if (!size) 1092 1093 sg_mark_end(sg + sgl->cur - 1); 1093 - 1094 - ctx->merge = plen & (PAGE_SIZE - 1); 1095 1094 } 1096 1095 1097 1096 err = 0;
+3 -1
crypto/algif_hash.c
··· 68 68 struct hash_ctx *ctx = ask->private; 69 69 ssize_t copied = 0; 70 70 size_t len, max_pages, npages; 71 - bool continuing = ctx->more, need_init = false; 71 + bool continuing, need_init = false; 72 72 int err; 73 73 74 74 max_pages = min_t(size_t, ALG_MAX_PAGES, 75 75 DIV_ROUND_UP(sk->sk_sndbuf, PAGE_SIZE)); 76 76 77 77 lock_sock(sk); 78 + continuing = ctx->more; 79 + 78 80 if (!continuing) { 79 81 /* Discard a previous request that wasn't marked MSG_MORE. */ 80 82 hash_free_result(sk, ctx);
+15 -5
crypto/asymmetric_keys/public_key.c
··· 185 185 186 186 if (issig) { 187 187 sig = crypto_alloc_sig(alg_name, 0, 0); 188 - if (IS_ERR(sig)) 188 + if (IS_ERR(sig)) { 189 + ret = PTR_ERR(sig); 189 190 goto error_free_key; 191 + } 190 192 191 193 if (pkey->key_is_private) 192 194 ret = crypto_sig_set_privkey(sig, key, pkey->keylen); ··· 210 208 } 211 209 } else { 212 210 tfm = crypto_alloc_akcipher(alg_name, 0, 0); 213 - if (IS_ERR(tfm)) 211 + if (IS_ERR(tfm)) { 212 + ret = PTR_ERR(tfm); 214 213 goto error_free_key; 214 + } 215 215 216 216 if (pkey->key_is_private) 217 217 ret = crypto_akcipher_set_priv_key(tfm, key, pkey->keylen); ··· 304 300 305 301 if (issig) { 306 302 sig = crypto_alloc_sig(alg_name, 0, 0); 307 - if (IS_ERR(sig)) 303 + if (IS_ERR(sig)) { 304 + ret = PTR_ERR(sig); 308 305 goto error_free_key; 306 + } 309 307 310 308 if (pkey->key_is_private) 311 309 ret = crypto_sig_set_privkey(sig, key, pkey->keylen); ··· 319 313 ksz = crypto_sig_maxsize(sig); 320 314 } else { 321 315 tfm = crypto_alloc_akcipher(alg_name, 0, 0); 322 - if (IS_ERR(tfm)) 316 + if (IS_ERR(tfm)) { 317 + ret = PTR_ERR(tfm); 323 318 goto error_free_key; 319 + } 324 320 325 321 if (pkey->key_is_private) 326 322 ret = crypto_akcipher_set_priv_key(tfm, key, pkey->keylen); ··· 419 411 420 412 key = kmalloc(pkey->keylen + sizeof(u32) * 2 + pkey->paramlen, 421 413 GFP_KERNEL); 422 - if (!key) 414 + if (!key) { 415 + ret = -ENOMEM; 423 416 goto error_free_tfm; 417 + } 424 418 425 419 memcpy(key, pkey->key, pkey->keylen); 426 420 ptr = key + pkey->keylen;