devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] crypto: s5p-sss - Fix use after free of copied input buffer in error path
@ 2016-04-19 13:44 Krzysztof Kozlowski
  2016-04-19 13:44 ` [PATCH 2/2] crypto: s5p-sss - Remove useless hash interrupt handler Krzysztof Kozlowski
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2016-04-19 13:44 UTC (permalink / raw)
  To: Herbert Xu, David S. Miller, Krzysztof Kozlowski,
	Vladimir Zapolskiy, devicetree, linux-kernel, linux-crypto
  Cc: Bartlomiej Zolnierkiewicz

The driver makes copies of memory (input or output scatterlists) if they
are not aligned. In s5p_aes_crypt_start() error path (on unsuccessful
initialization of output scatterlist), if input scatterlist was not
aligned, the driver first freed copied input memory and then unmapped it
from the device, instead of doing otherwise (unmap and then free).

This was wrong in two ways:
1. Freed pages were still mapped to the device.
2. The dma_unmap_sg() iterated over freed scatterlist structure.

The call to s5p_free_sg_cpy() in this error path is not needed because
the copied scatterlists will be freed by s5p_aes_complete().

Fixes: 9e4a1100a445 ("crypto: s5p-sss - Handle unaligned buffers")
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
---
 drivers/crypto/s5p-sss.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/crypto/s5p-sss.c b/drivers/crypto/s5p-sss.c
index 4f6d5b3ec418..b0484d4d68d9 100644
--- a/drivers/crypto/s5p-sss.c
+++ b/drivers/crypto/s5p-sss.c
@@ -577,7 +577,6 @@ static void s5p_aes_crypt_start(struct s5p_aes_dev *dev, unsigned long mode)
 	return;
 
 outdata_error:
-	s5p_free_sg_cpy(dev, &dev->sg_src_cpy);
 	s5p_unset_indata(dev);
 
 indata_error:
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-04-21 15:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-19 13:44 [PATCH 1/2] crypto: s5p-sss - Fix use after free of copied input buffer in error path Krzysztof Kozlowski
2016-04-19 13:44 ` [PATCH 2/2] crypto: s5p-sss - Remove useless hash interrupt handler Krzysztof Kozlowski
     [not found]   ` <1461073452-10426-2-git-send-email-k.kozlowski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2016-04-20 10:04     ` Vladimir Zapolskiy
2016-04-21 15:24   ` Rob Herring
2016-04-20  9:59 ` [PATCH 1/2] crypto: s5p-sss - Fix use after free of copied input buffer in error path Herbert Xu
2016-04-20 10:03 ` Vladimir Zapolskiy

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).