Skip to content

Commit a69eddf

Browse files
committed
Merge tag 'v6.19-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
Pull crypto fixes from Herbert Xu: - Fix UAF in seqiv - Fix regression in hisilicon * tag 'v6.19-p2' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: crypto: hisilicon/qm - fix incorrect judgment in qm_get_complete_eqe_num() crypto: seqiv - Do not use req->iv after crypto_aead_encrypt
2 parents f8f9c1f + b74fd80 commit a69eddf

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

crypto/seqiv.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static int seqiv_aead_encrypt(struct aead_request *req)
5050
struct aead_geniv_ctx *ctx = crypto_aead_ctx(geniv);
5151
struct aead_request *subreq = aead_request_ctx(req);
5252
crypto_completion_t compl;
53+
bool unaligned_info;
5354
void *data;
5455
u8 *info;
5556
unsigned int ivsize = 8;
@@ -68,8 +69,9 @@ static int seqiv_aead_encrypt(struct aead_request *req)
6869
memcpy_sglist(req->dst, req->src,
6970
req->assoclen + req->cryptlen);
7071

71-
if (unlikely(!IS_ALIGNED((unsigned long)info,
72-
crypto_aead_alignmask(geniv) + 1))) {
72+
unaligned_info = !IS_ALIGNED((unsigned long)info,
73+
crypto_aead_alignmask(geniv) + 1);
74+
if (unlikely(unaligned_info)) {
7375
info = kmemdup(req->iv, ivsize, req->base.flags &
7476
CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
7577
GFP_ATOMIC);
@@ -89,7 +91,7 @@ static int seqiv_aead_encrypt(struct aead_request *req)
8991
scatterwalk_map_and_copy(info, req->dst, req->assoclen, ivsize, 1);
9092

9193
err = crypto_aead_encrypt(subreq);
92-
if (unlikely(info != req->iv))
94+
if (unlikely(unaligned_info))
9395
seqiv_aead_encrypt_complete2(req, err);
9496
return err;
9597
}

drivers/crypto/hisilicon/qm.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ static void qm_get_complete_eqe_num(struct hisi_qm *qm)
991991
return;
992992
poll_data = &qm->poll_data[cqn];
993993

994-
while (QM_EQE_PHASE(dw0) != qm->status.eqc_phase) {
994+
do {
995995
poll_data->qp_finish_id[eqe_num] = dw0 & QM_EQE_CQN_MASK;
996996
eqe_num++;
997997

@@ -1004,11 +1004,10 @@ static void qm_get_complete_eqe_num(struct hisi_qm *qm)
10041004
qm->status.eq_head++;
10051005
}
10061006

1007-
if (eqe_num == (eq_depth >> 1) - 1)
1008-
break;
1009-
10101007
dw0 = le32_to_cpu(eqe->dw0);
1011-
}
1008+
if (QM_EQE_PHASE(dw0) != qm->status.eqc_phase)
1009+
break;
1010+
} while (eqe_num < (eq_depth >> 1) - 1);
10121011

10131012
poll_data->eqe_num = eqe_num;
10141013
queue_work(qm->wq, &poll_data->work);

0 commit comments

Comments
 (0)