Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1238297

[PATCH 3.12 09/84] crypto: caam - fix memory corruption in ahash_final_ctx

From Jiri Slaby <jslaby@suse.cz>
Newsgroups linux.kernel
Subject [PATCH 3.12 09/84] crypto: caam - fix memory corruption in ahash_final_ctx
Date 2015-10-02 16:00 +0200
Message-ID <qf92s-5aj-55@gated-at.bofh.it> (permalink)
References <qf8zn-4Bq-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Horia Geant? <horia.geanta@freescale.com>

3.12-stable review patch.  If anyone has any objections, please let me know.

===============

commit b310c178e6d897f82abb9da3af1cd7c02b09f592 upstream.

When doing pointer operation for accessing the HW S/G table,
a value representing number of entries (and not number of bytes)
must be used.

Fixes: 045e36780f115 ("crypto: caam - ahash hmac support")
Signed-off-by: Horia Geant? <horia.geanta@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
 drivers/crypto/caam/caamhash.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c
index af351f478b14..92d2116bf1ad 100644
--- a/drivers/crypto/caam/caamhash.c
+++ b/drivers/crypto/caam/caamhash.c
@@ -897,13 +897,14 @@ static int ahash_final_ctx(struct ahash_request *req)
 			  state->buflen_1;
 	u32 *sh_desc = ctx->sh_desc_fin, *desc;
 	dma_addr_t ptr = ctx->sh_desc_fin_dma;
-	int sec4_sg_bytes;
+	int sec4_sg_bytes, sec4_sg_src_index;
 	int digestsize = crypto_ahash_digestsize(ahash);
 	struct ahash_edesc *edesc;
 	int ret = 0;
 	int sh_len;
 
-	sec4_sg_bytes = (1 + (buflen ? 1 : 0)) * sizeof(struct sec4_sg_entry);
+	sec4_sg_src_index = 1 + (buflen ? 1 : 0);
+	sec4_sg_bytes = sec4_sg_src_index * sizeof(struct sec4_sg_entry);
 
 	/* allocate space for base edesc and hw desc commands, link tables */
 	edesc = kmalloc(sizeof(struct ahash_edesc) + DESC_JOB_IO_LEN +
@@ -930,7 +931,7 @@ static int ahash_final_ctx(struct ahash_request *req)
 	state->buf_dma = try_buf_map_to_sec4_sg(jrdev, edesc->sec4_sg + 1,
 						buf, state->buf_dma, buflen,
 						last_buflen);
-	(edesc->sec4_sg + sec4_sg_bytes - 1)->len |= SEC4_SG_LEN_FIN;
+	(edesc->sec4_sg + sec4_sg_src_index - 1)->len |= SEC4_SG_LEN_FIN;
 
 	append_seq_in_ptr(desc, edesc->sec4_sg_dma, ctx->ctx_len + buflen,
 			  LDST_SGF);
-- 
2.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 3.12 00/84] 3.12.49-stable review Jiri Slaby <jslaby@suse.cz> - 2015-10-02 16:00 +0200
  [PATCH 3.12 01/84] PCI: Add dev_flags bit to access VPD through function 0 Jiri Slaby <jslaby@suse.cz> - 2015-10-02 16:00 +0200
    [PATCH 3.12 09/84] crypto: caam - fix memory corruption in ahash_final_ctx Jiri Slaby <jslaby@suse.cz> - 2015-10-02 16:00 +0200
    [PATCH 3.12 20/84] usb: host: ehci-sys: delete useless bus_to_hcd conversion Jiri Slaby <jslaby@suse.cz> - 2015-10-02 16:00 +0200
    [PATCH 3.12 02/84] PCI: Add VPD function 0 quirk for Intel Ethernet devices Jiri Slaby <jslaby@suse.cz> - 2015-10-02 16:00 +0200
    [PATCH 3.12 10/84] arm64: KVM: Fix host crash when injecting a fault into a 32bit guest Jiri Slaby <jslaby@suse.cz> - 2015-10-02 16:00 +0200
    [PATCH 3.12 07/84] libfc: Fix fc_fcp_cleanup_each_cmd() Jiri Slaby <jslaby@suse.cz> - 2015-10-02 16:00 +0200
    [PATCH 3.12 04/84] staging: comedi: usbduxsigma: don't clobber ao_timer in command test Jiri Slaby <jslaby@suse.cz> - 2015-10-02 16:00 +0200
  Re: [PATCH 3.12 00/84] 3.12.49-stable review Shuah Khan <shuahkh@osg.samsung.com> - 2015-10-02 17:40 +0200
  Re: [PATCH 3.12 00/84] 3.12.49-stable review Guenter Roeck <linux@roeck-us.net> - 2015-10-02 18:10 +0200

csiph-web