<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/crypto/caam/caamhash.c, branch linux-4.12.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.12.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.12.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2017-07-21T04:59:12Z</updated>
<entry>
<title>crypto: caam - fix signals handling</title>
<updated>2017-07-21T04:59:12Z</updated>
<author>
<name>Horia Geantă</name>
</author>
<published>2017-07-07T13:57:06Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9e724aa62501379bc0dde4811565e92e2c6a4686'/>
<id>urn:sha1:9e724aa62501379bc0dde4811565e92e2c6a4686</id>
<content type='text'>
commit 7459e1d25ffefa2b1be799477fcc1f6c62f6cec7 upstream.

Driver does not properly handle the case when signals interrupt
wait_for_completion_interruptible():
-it does not check for return value
-completion structure is allocated on stack; in case a signal interrupts
the sleep, it will go out of scope, causing the worker thread
(caam_jr_dequeue) to fail when it accesses it

wait_for_completion_interruptible() is replaced with uninterruptable
wait_for_completion().
We choose to block all signals while waiting for I/O (device executing
the split key generation job descriptor) since the alternative - in
order to have a deterministic device state - would be to flush the job
ring (aborting *all* in-progress jobs).

Fixes: 045e36780f115 ("crypto: caam - ahash hmac support")
Fixes: 4c1ec1f930154 ("crypto: caam - refactor key_gen, sg")
Signed-off-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>crypto: caam - fix state buffer DMA (un)mapping</title>
<updated>2017-02-15T05:23:43Z</updated>
<author>
<name>Horia Geantă</name>
</author>
<published>2017-02-10T12:07:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=944c3d4dca34403e802287a1e7e9d02c06dce0d5'/>
<id>urn:sha1:944c3d4dca34403e802287a1e7e9d02c06dce0d5</id>
<content type='text'>
If we register the DMA API debug notification chain to
receive platform bus events:
    dma_debug_add_bus(&amp;platform_bus_type);
we start receiving warnings after a simple test like "modprobe caam_jr &amp;&amp;
modprobe caamhash &amp;&amp; modprobe -r caamhash &amp;&amp; modprobe -r caam_jr":
platform ffe301000.jr: DMA-API: device driver has pending DMA allocations while released from device [count=1938]
One of leaked entries details: [device address=0x0000000173fda090] [size=63 bytes] [mapped with DMA_TO_DEVICE] [mapped as single]

It turns out there are several issues with handling buf_dma (mapping of buffer
holding the previous chunk smaller than hash block size):
-detection of buf_dma mapping failure occurs too late, after a job descriptor
using that value has been submitted for execution
-dma mapping leak - unmapping is not performed in all places: for e.g.
in ahash_export or in most ahash_fin* callbacks (due to current back-to-back
implementation of buf_dma unmapping/mapping)

Fix these by:
-calling dma_mapping_error() on buf_dma right after the mapping and providing
an error code if needed
-unmapping buf_dma during the "job done" (ahash_done_*) callbacks

Signed-off-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: caam - abstract ahash request double buffering</title>
<updated>2017-02-15T05:23:43Z</updated>
<author>
<name>Horia Geantă</name>
</author>
<published>2017-02-10T12:07:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0355d23d4034f42b28db19520bc8865e26053404'/>
<id>urn:sha1:0355d23d4034f42b28db19520bc8865e26053404</id>
<content type='text'>
caamhash uses double buffering for holding previous/current
and next chunks (data smaller than block size) to be hashed.

Add (inline) functions to abstract this mechanism.

Signed-off-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: caam - fix error path for ctx_dma mapping failure</title>
<updated>2017-02-15T05:23:42Z</updated>
<author>
<name>Horia Geantă</name>
</author>
<published>2017-02-10T12:07:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=87ec02e7409d787348c244039aa3536a812dfa8b'/>
<id>urn:sha1:87ec02e7409d787348c244039aa3536a812dfa8b</id>
<content type='text'>
In case ctx_dma dma mapping fails, ahash_unmap_ctx() tries to
dma unmap an invalid address:
map_seq_out_ptr_ctx() / ctx_map_to_sec4_sg() -&gt; goto unmap_ctx -&gt;
-&gt; ahash_unmap_ctx() -&gt; dma unmap ctx_dma

There is also possible to reach ahash_unmap_ctx() with ctx_dma
uninitialzed or to try to unmap the same address twice.

Fix these by setting ctx_dma = 0 where needed:
-initialize ctx_dma in ahash_init()
-clear ctx_dma in case of mapping error (instead of holding
the error code returned by the dma map function)
-clear ctx_dma after each unmapping

Fixes: 32686d34f8fb6 ("crypto: caam - ensure that we clean up after an error")
Signed-off-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: caam - fix DMA API leaks for multiple setkey() calls</title>
<updated>2017-02-15T05:23:41Z</updated>
<author>
<name>Horia Geantă</name>
</author>
<published>2017-02-10T12:07:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bbf2234494afd14a720d61a233c21b95e4261326'/>
<id>urn:sha1:bbf2234494afd14a720d61a233c21b95e4261326</id>
<content type='text'>
setkey() callback may be invoked multiple times for the same tfm.
In this case, DMA API leaks are caused by shared descriptors
(and key for caamalg) being mapped several times and unmapped only once.
Fix this by performing mapping / unmapping only in crypto algorithm's
cra_init() / cra_exit() callbacks and sync_for_device in the setkey()
tfm callback.

Signed-off-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: caam - don't dma_map key for hash algorithms</title>
<updated>2017-02-15T05:23:41Z</updated>
<author>
<name>Horia Geantă</name>
</author>
<published>2017-02-10T12:07:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cfb725f6d3d31355fa4510da7d7bdce807045b42'/>
<id>urn:sha1:cfb725f6d3d31355fa4510da7d7bdce807045b42</id>
<content type='text'>
Shared descriptors for hash algorithms are small enough
for (split) keys to be inlined in all cases.
Since driver already does this, all what's left is to remove
unused ctx-&gt;key_dma.

Fixes: 045e36780f115 ("crypto: caam - ahash hmac support")
Signed-off-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: caam - refactor ahash shared descriptor generation</title>
<updated>2016-11-28T13:23:23Z</updated>
<author>
<name>Horia Geantă</name>
</author>
<published>2016-11-22T13:44:11Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=1a0166f19974d8eb262ff03e621d19eb5894230d'/>
<id>urn:sha1:1a0166f19974d8eb262ff03e621d19eb5894230d</id>
<content type='text'>
Move ahash shared descriptor generation into a single function.
Currently there is no plan to support ahash on any other interface
besides the Job Ring, thus for now the functionality is not exported.

Signed-off-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: caam - consolidate split key length computation</title>
<updated>2016-11-28T13:23:23Z</updated>
<author>
<name>Horia Geantă</name>
</author>
<published>2016-11-22T13:44:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6655cb8e56691fab3291c83d2afd6f1fd0776ecf'/>
<id>urn:sha1:6655cb8e56691fab3291c83d2afd6f1fd0776ecf</id>
<content type='text'>
Move split key length and padded length computation from caamalg.c
and caamhash.c to key_gen.c.

Signed-off-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: caam - rewrite some generic inline append cmds</title>
<updated>2016-11-28T13:23:22Z</updated>
<author>
<name>Horia Geantă</name>
</author>
<published>2016-11-22T13:44:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=281669dfbabedb8b44466c4e788df71ff43bd8b5'/>
<id>urn:sha1:281669dfbabedb8b44466c4e788df71ff43bd8b5</id>
<content type='text'>
A few descriptor commands are generated using generic
inline append "append_cmd" function.
Rewrite them using specific inline append functions.

Signed-off-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: caam - remove superfluous alg_op algorithm param</title>
<updated>2016-11-28T13:23:22Z</updated>
<author>
<name>Horia Geantă</name>
</author>
<published>2016-11-22T13:44:05Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=488ebc3a41260d62b24c18271356abc1f3ffdb63'/>
<id>urn:sha1:488ebc3a41260d62b24c18271356abc1f3ffdb63</id>
<content type='text'>
Information carried by alg_op can be deduced from adata-&gt;algtype
plus some fixed flags.

Signed-off-by: Horia Geantă &lt;horia.geanta@nxp.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
</feed>
