stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
To: herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com,
	vdronov@redhat.com, Giovanni Cabiddu <giovanni.cabiddu@intel.com>,
	stable@vger.kernel.org, Adam Guerin <adam.guerin@intel.com>,
	Wojciech Ziemba <wojciech.ziemba@intel.com>
Subject: [PATCH v2 09/11] crypto: qat - add param check for DH
Date: Fri,  6 May 2022 15:39:01 +0100	[thread overview]
Message-ID: <20220506143903.31776-10-giovanni.cabiddu@intel.com> (raw)
In-Reply-To: <20220506143903.31776-1-giovanni.cabiddu@intel.com>

Reject requests with a source buffer that is bigger than the size of the
key. This is to prevent a possible integer underflow that might happen
when copying the source scatterlist into a linear buffer.

Cc: stable@vger.kernel.org
Signed-off-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Reviewed-by: Adam Guerin <adam.guerin@intel.com>
Reviewed-by: Wojciech Ziemba <wojciech.ziemba@intel.com>
---
 drivers/crypto/qat/qat_common/qat_asym_algs.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/crypto/qat/qat_common/qat_asym_algs.c b/drivers/crypto/qat/qat_common/qat_asym_algs.c
index 947eeff181b4..7173a2a0a484 100644
--- a/drivers/crypto/qat/qat_common/qat_asym_algs.c
+++ b/drivers/crypto/qat/qat_common/qat_asym_algs.c
@@ -235,6 +235,10 @@ static int qat_dh_compute_value(struct kpp_request *req)
 		req->dst_len = ctx->p_size;
 		return -EOVERFLOW;
 	}
+
+	if (req->src_len > ctx->p_size)
+		return -EINVAL;
+
 	memset(msg, '\0', sizeof(*msg));
 	ICP_QAT_FW_PKE_HDR_VALID_FLAG_SET(msg->pke_hdr,
 					  ICP_QAT_FW_COMN_REQ_FLAG_SET);
-- 
2.35.1


  parent reply	other threads:[~2022-05-06 14:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220506143903.31776-1-giovanni.cabiddu@intel.com>
2022-05-06 14:38 ` [PATCH v2 01/11] crypto: qat - use pre-allocated buffers in datapath Giovanni Cabiddu
2022-05-06 14:38 ` [PATCH v2 02/11] crypto: qat - refactor submission logic Giovanni Cabiddu
2022-05-06 14:38 ` [PATCH v2 03/11] crypto: qat - add backlog mechanism Giovanni Cabiddu
2022-05-06 14:38 ` [PATCH v2 04/11] crypto: qat - fix memory leak in RSA Giovanni Cabiddu
2022-05-06 14:38 ` [PATCH v2 05/11] crypto: qat - remove dma_free_coherent() for RSA Giovanni Cabiddu
2022-05-06 14:38 ` [PATCH v2 06/11] crypto: qat - remove dma_free_coherent() for DH Giovanni Cabiddu
2022-05-06 14:38 ` [PATCH v2 07/11] crypto: qat - set to zero DH parameters before free Giovanni Cabiddu
2022-05-06 14:43   ` Greg KH
2022-05-06 14:39 ` [PATCH v2 08/11] crypto: qat - add param check for RSA Giovanni Cabiddu
2022-05-06 14:39 ` Giovanni Cabiddu [this message]
2022-05-06 14:39 ` [PATCH v2 10/11] crypto: qat - honor CRYPTO_TFM_REQ_MAY_SLEEP flag Giovanni Cabiddu
2022-05-06 14:39 ` [PATCH v2 11/11] crypto: qat - re-enable registration of algorithms Giovanni Cabiddu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220506143903.31776-10-giovanni.cabiddu@intel.com \
    --to=giovanni.cabiddu@intel.com \
    --cc=adam.guerin@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=qat-linux@intel.com \
    --cc=stable@vger.kernel.org \
    --cc=vdronov@redhat.com \
    --cc=wojciech.ziemba@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).