Skip to content

Commit 419caed

Browse files
committed
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
2 parents 06c2afb + 0b7ec17 commit 419caed

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

crypto/af_alg.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
992992
ssize_t plen;
993993

994994
/* use the existing memory in an allocated page */
995-
if (ctx->merge) {
995+
if (ctx->merge && !(msg->msg_flags & MSG_SPLICE_PAGES)) {
996996
sgl = list_entry(ctx->tsgl_list.prev,
997997
struct af_alg_tsgl, list);
998998
sg = sgl->sg + sgl->cur - 1;
@@ -1054,6 +1054,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
10541054
ctx->used += plen;
10551055
copied += plen;
10561056
size -= plen;
1057+
ctx->merge = 0;
10571058
} else {
10581059
do {
10591060
struct page *pg;
@@ -1085,12 +1086,12 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
10851086
size -= plen;
10861087
sgl->cur++;
10871088
} while (len && sgl->cur < MAX_SGL_ENTS);
1089+
1090+
ctx->merge = plen & (PAGE_SIZE - 1);
10881091
}
10891092

10901093
if (!size)
10911094
sg_mark_end(sg + sgl->cur - 1);
1092-
1093-
ctx->merge = plen & (PAGE_SIZE - 1);
10941095
}
10951096

10961097
err = 0;

crypto/algif_hash.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,15 @@ static int hash_sendmsg(struct socket *sock, struct msghdr *msg,
6868
struct hash_ctx *ctx = ask->private;
6969
ssize_t copied = 0;
7070
size_t len, max_pages, npages;
71-
bool continuing = ctx->more, need_init = false;
71+
bool continuing, need_init = false;
7272
int err;
7373

7474
max_pages = min_t(size_t, ALG_MAX_PAGES,
7575
DIV_ROUND_UP(sk->sk_sndbuf, PAGE_SIZE));
7676

7777
lock_sock(sk);
78+
continuing = ctx->more;
79+
7880
if (!continuing) {
7981
/* Discard a previous request that wasn't marked MSG_MORE. */
8082
hash_free_result(sk, ctx);

crypto/asymmetric_keys/public_key.c

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ static int software_key_query(const struct kernel_pkey_params *params,
185185

186186
if (issig) {
187187
sig = crypto_alloc_sig(alg_name, 0, 0);
188-
if (IS_ERR(sig))
188+
if (IS_ERR(sig)) {
189+
ret = PTR_ERR(sig);
189190
goto error_free_key;
191+
}
190192

191193
if (pkey->key_is_private)
192194
ret = crypto_sig_set_privkey(sig, key, pkey->keylen);
@@ -208,8 +210,10 @@ static int software_key_query(const struct kernel_pkey_params *params,
208210
}
209211
} else {
210212
tfm = crypto_alloc_akcipher(alg_name, 0, 0);
211-
if (IS_ERR(tfm))
213+
if (IS_ERR(tfm)) {
214+
ret = PTR_ERR(tfm);
212215
goto error_free_key;
216+
}
213217

214218
if (pkey->key_is_private)
215219
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,
300304

301305
if (issig) {
302306
sig = crypto_alloc_sig(alg_name, 0, 0);
303-
if (IS_ERR(sig))
307+
if (IS_ERR(sig)) {
308+
ret = PTR_ERR(sig);
304309
goto error_free_key;
310+
}
305311

306312
if (pkey->key_is_private)
307313
ret = crypto_sig_set_privkey(sig, key, pkey->keylen);
@@ -313,8 +319,10 @@ static int software_key_eds_op(struct kernel_pkey_params *params,
313319
ksz = crypto_sig_maxsize(sig);
314320
} else {
315321
tfm = crypto_alloc_akcipher(alg_name, 0, 0);
316-
if (IS_ERR(tfm))
322+
if (IS_ERR(tfm)) {
323+
ret = PTR_ERR(tfm);
317324
goto error_free_key;
325+
}
318326

319327
if (pkey->key_is_private)
320328
ret = crypto_akcipher_set_priv_key(tfm, key, pkey->keylen);
@@ -411,8 +419,10 @@ int public_key_verify_signature(const struct public_key *pkey,
411419

412420
key = kmalloc(pkey->keylen + sizeof(u32) * 2 + pkey->paramlen,
413421
GFP_KERNEL);
414-
if (!key)
422+
if (!key) {
423+
ret = -ENOMEM;
415424
goto error_free_tfm;
425+
}
416426

417427
memcpy(key, pkey->key, pkey->keylen);
418428
ptr = key + pkey->keylen;

0 commit comments

Comments
 (0)