Commit 419caed6 authored by Linus Torvalds's avatar Linus Torvalds

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
parents 06c2afb8 0b7ec177
...@@ -992,7 +992,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, ...@@ -992,7 +992,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
ssize_t plen; ssize_t plen;
/* use the existing memory in an allocated page */ /* use the existing memory in an allocated page */
if (ctx->merge) { if (ctx->merge && !(msg->msg_flags & MSG_SPLICE_PAGES)) {
sgl = list_entry(ctx->tsgl_list.prev, sgl = list_entry(ctx->tsgl_list.prev,
struct af_alg_tsgl, list); struct af_alg_tsgl, list);
sg = sgl->sg + sgl->cur - 1; sg = sgl->sg + sgl->cur - 1;
...@@ -1054,6 +1054,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, ...@@ -1054,6 +1054,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
ctx->used += plen; ctx->used += plen;
copied += plen; copied += plen;
size -= plen; size -= plen;
ctx->merge = 0;
} else { } else {
do { do {
struct page *pg; struct page *pg;
...@@ -1085,12 +1086,12 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size, ...@@ -1085,12 +1086,12 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
size -= plen; size -= plen;
sgl->cur++; sgl->cur++;
} while (len && sgl->cur < MAX_SGL_ENTS); } while (len && sgl->cur < MAX_SGL_ENTS);
ctx->merge = plen & (PAGE_SIZE - 1);
} }
if (!size) if (!size)
sg_mark_end(sg + sgl->cur - 1); sg_mark_end(sg + sgl->cur - 1);
ctx->merge = plen & (PAGE_SIZE - 1);
} }
err = 0; err = 0;
......
...@@ -68,13 +68,15 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg, ...@@ -68,13 +68,15 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg,
struct hash_ctx *ctx = ask->private; struct hash_ctx *ctx = ask->private;
ssize_t copied = 0; ssize_t copied = 0;
size_t len, max_pages, npages; size_t len, max_pages, npages;
bool continuing = ctx->more, need_init = false; bool continuing, need_init = false;
int err; int err;
max_pages = min_t(size_t, ALG_MAX_PAGES, max_pages = min_t(size_t, ALG_MAX_PAGES,
DIV_ROUND_UP(sk->sk_sndbuf, PAGE_SIZE)); DIV_ROUND_UP(sk->sk_sndbuf, PAGE_SIZE));
lock_sock(sk); lock_sock(sk);
continuing = ctx->more;
if (!continuing) { if (!continuing) {
/* Discard a previous request that wasn't marked MSG_MORE. */ /* Discard a previous request that wasn't marked MSG_MORE. */
hash_free_result(sk, ctx); hash_free_result(sk, ctx);
......
...@@ -185,8 +185,10 @@ static int software_key_query(const struct kernel_pkey_params *params, ...@@ -185,8 +185,10 @@ static int software_key_query(const struct kernel_pkey_params *params,
if (issig) { if (issig) {
sig = crypto_alloc_sig(alg_name, 0, 0); sig = crypto_alloc_sig(alg_name, 0, 0);
if (IS_ERR(sig)) if (IS_ERR(sig)) {
ret = PTR_ERR(sig);
goto error_free_key; goto error_free_key;
}
if (pkey->key_is_private) if (pkey->key_is_private)
ret = crypto_sig_set_privkey(sig, key, pkey->keylen); ret = crypto_sig_set_privkey(sig, key, pkey->keylen);
...@@ -208,8 +210,10 @@ static int software_key_query(const struct kernel_pkey_params *params, ...@@ -208,8 +210,10 @@ static int software_key_query(const struct kernel_pkey_params *params,
} }
} else { } else {
tfm = crypto_alloc_akcipher(alg_name, 0, 0); tfm = crypto_alloc_akcipher(alg_name, 0, 0);
if (IS_ERR(tfm)) if (IS_ERR(tfm)) {
ret = PTR_ERR(tfm);
goto error_free_key; goto error_free_key;
}
if (pkey->key_is_private) if (pkey->key_is_private)
ret = crypto_akcipher_set_priv_key(tfm, key, pkey->keylen); ret = crypto_akcipher_set_priv_key(tfm, key, pkey->keylen);
...@@ -300,8 +304,10 @@ static int software_key_eds_op(struct kernel_pkey_params *params, ...@@ -300,8 +304,10 @@ static int software_key_eds_op(struct kernel_pkey_params *params,
if (issig) { if (issig) {
sig = crypto_alloc_sig(alg_name, 0, 0); sig = crypto_alloc_sig(alg_name, 0, 0);
if (IS_ERR(sig)) if (IS_ERR(sig)) {
ret = PTR_ERR(sig);
goto error_free_key; goto error_free_key;
}
if (pkey->key_is_private) if (pkey->key_is_private)
ret = crypto_sig_set_privkey(sig, key, pkey->keylen); ret = crypto_sig_set_privkey(sig, key, pkey->keylen);
...@@ -313,8 +319,10 @@ static int software_key_eds_op(struct kernel_pkey_params *params, ...@@ -313,8 +319,10 @@ static int software_key_eds_op(struct kernel_pkey_params *params,
ksz = crypto_sig_maxsize(sig); ksz = crypto_sig_maxsize(sig);
} else { } else {
tfm = crypto_alloc_akcipher(alg_name, 0, 0); tfm = crypto_alloc_akcipher(alg_name, 0, 0);
if (IS_ERR(tfm)) if (IS_ERR(tfm)) {
ret = PTR_ERR(tfm);
goto error_free_key; goto error_free_key;
}
if (pkey->key_is_private) if (pkey->key_is_private)
ret = crypto_akcipher_set_priv_key(tfm, key, pkey->keylen); ret = crypto_akcipher_set_priv_key(tfm, key, pkey->keylen);
...@@ -411,8 +419,10 @@ int public_key_verify_signature(const struct public_key *pkey, ...@@ -411,8 +419,10 @@ int public_key_verify_signature(const struct public_key *pkey,
key = kmalloc(pkey->keylen + sizeof(u32) * 2 + pkey->paramlen, key = kmalloc(pkey->keylen + sizeof(u32) * 2 + pkey->paramlen,
GFP_KERNEL); GFP_KERNEL);
if (!key) if (!key) {
ret = -ENOMEM;
goto error_free_tfm; goto error_free_tfm;
}
memcpy(key, pkey->key, pkey->keylen); memcpy(key, pkey->key, pkey->keylen);
ptr = key + pkey->keylen; ptr = key + pkey->keylen;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment