<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/crypto/internal.h, branch v4.9.293</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.9.293</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.9.293'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2020-02-14T21:31:02Z</updated>
<entry>
<title>crypto: api - Fix race condition in crypto_spawn_alg</title>
<updated>2020-02-14T21:31:02Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2019-12-07T14:15:15Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=96ad8d508fcbe54ed2d559f03d1adaddf19b96e7'/>
<id>urn:sha1:96ad8d508fcbe54ed2d559f03d1adaddf19b96e7</id>
<content type='text'>
commit 73669cc556462f4e50376538d77ee312142e8a8a upstream.

The function crypto_spawn_alg is racy because it drops the lock
before shooting the dying algorithm.  The algorithm could disappear
altogether before we shoot it.

This patch fixes it by moving the shooting into the locked section.

Fixes: 6bfd48096ff8 ("[CRYPTO] api: Added spawns")
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: api - Add crypto_type_has_alg helper</title>
<updated>2016-01-25T14:42:12Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2016-01-23T05:51:01Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f2aefdab5dff83d3c801449051be1ba72c7e933a'/>
<id>urn:sha1:f2aefdab5dff83d3c801449051be1ba72c7e933a</id>
<content type='text'>
This patch adds the helper crypto_type_has_alg which is meant
to replace crypto_has_alg for new-style crypto types.  Rather
than hard-coding type/mask information they're now retrieved
from the crypto_type object.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: api - Remove linux/fips.h from internal.h</title>
<updated>2015-04-23T06:18:10Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2015-04-22T05:25:59Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7be58b1250f471a4548c0fe7a6b4001b62ea1e30'/>
<id>urn:sha1:7be58b1250f471a4548c0fe7a6b4001b62ea1e30</id>
<content type='text'>
Now that all fips_enabled users are including linux/fips.h directly
instead of getting it through internal.h, we can remove the fips.h
inclusions from internal.h.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: api - Add crypto_alg_extsize helper</title>
<updated>2015-04-21T02:19:54Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2015-04-20T05:39:00Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=38d21433112c25acdb8e93f60be629e7a1c27a26'/>
<id>urn:sha1:38d21433112c25acdb8e93f60be629e7a1c27a26</id>
<content type='text'>
This patch adds a crypto_alg_extsize helper that can be used
by algorithm types such as pcompress and shash.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: algboss - Hold ref count on larval</title>
<updated>2013-06-25T11:15:17Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2013-06-25T11:15:17Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=939e17799619e31331d2433041196529515a86a6'/>
<id>urn:sha1:939e17799619e31331d2433041196529515a86a6</id>
<content type='text'>
On Thu, Jun 20, 2013 at 10:00:21AM +0200, Daniel Borkmann wrote:
&gt; After having fixed a NULL pointer dereference in SCTP 1abd165e ("net:
&gt; sctp: fix NULL pointer dereference in socket destruction"), I ran into
&gt; the following NULL pointer dereference in the crypto subsystem with
&gt; the same reproducer, easily hit each time:
&gt; 
&gt; BUG: unable to handle kernel NULL pointer dereference at (null)
&gt; IP: [&lt;ffffffff81070321&gt;] __wake_up_common+0x31/0x90
&gt; PGD 0
&gt; Oops: 0000 [#1] SMP
&gt; Modules linked in: padlock_sha(F-) sha256_generic(F) sctp(F) libcrc32c(F) [..]
&gt; CPU: 6 PID: 3326 Comm: cryptomgr_probe Tainted: GF            3.10.0-rc5+ #1
&gt; Hardware name: Dell Inc. PowerEdge T410/0H19HD, BIOS 1.6.3 02/01/2011
&gt; task: ffff88007b6cf4e0 ti: ffff88007b7cc000 task.ti: ffff88007b7cc000
&gt; RIP: 0010:[&lt;ffffffff81070321&gt;]  [&lt;ffffffff81070321&gt;] __wake_up_common+0x31/0x90
&gt; RSP: 0018:ffff88007b7cde08  EFLAGS: 00010082
&gt; RAX: ffffffffffffffe8 RBX: ffff88003756c130 RCX: 0000000000000000
&gt; RDX: 0000000000000000 RSI: 0000000000000003 RDI: ffff88003756c130
&gt; RBP: ffff88007b7cde48 R08: 0000000000000000 R09: ffff88012b173200
&gt; R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000282
&gt; R13: ffff88003756c138 R14: 0000000000000000 R15: 0000000000000000
&gt; FS:  0000000000000000(0000) GS:ffff88012fc60000(0000) knlGS:0000000000000000
&gt; CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
&gt; CR2: 0000000000000000 CR3: 0000000001a0b000 CR4: 00000000000007e0
&gt; DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
&gt; DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
&gt; Stack:
&gt;  ffff88007b7cde28 0000000300000000 ffff88007b7cde28 ffff88003756c130
&gt;  0000000000000282 ffff88003756c128 ffffffff81227670 0000000000000000
&gt;  ffff88007b7cde78 ffffffff810722b7 ffff88007cdcf000 ffffffff81a90540
&gt; Call Trace:
&gt;  [&lt;ffffffff81227670&gt;] ? crypto_alloc_pcomp+0x20/0x20
&gt;  [&lt;ffffffff810722b7&gt;] complete_all+0x47/0x60
&gt;  [&lt;ffffffff81227708&gt;] cryptomgr_probe+0x98/0xc0
&gt;  [&lt;ffffffff81227670&gt;] ? crypto_alloc_pcomp+0x20/0x20
&gt;  [&lt;ffffffff8106760e&gt;] kthread+0xce/0xe0
&gt;  [&lt;ffffffff81067540&gt;] ? kthread_freezable_should_stop+0x70/0x70
&gt;  [&lt;ffffffff815450dc&gt;] ret_from_fork+0x7c/0xb0
&gt;  [&lt;ffffffff81067540&gt;] ? kthread_freezable_should_stop+0x70/0x70
&gt; Code: 41 56 41 55 41 54 53 48 83 ec 18 66 66 66 66 90 89 75 cc 89 55 c8
&gt;       4c 8d 6f 08 48 8b 57 08 41 89 cf 4d 89 c6 48 8d 42 e
&gt; RIP  [&lt;ffffffff81070321&gt;] __wake_up_common+0x31/0x90
&gt;  RSP &lt;ffff88007b7cde08&gt;
&gt; CR2: 0000000000000000
&gt; ---[ end trace b495b19270a4d37e ]---
&gt; 
&gt; My assumption is that the following is happening: the minimal SCTP
&gt; tool runs under ``echo 1 &gt; /proc/sys/net/sctp/auth_enable'', hence
&gt; it's making use of crypto_alloc_hash() via sctp_auth_init_hmacs().
&gt; It forks itself, heavily allocates, binds, listens and waits in
&gt; accept on sctp sockets, and then randomly kills some of them (no
&gt; need for an actual client in this case to hit this). Then, again,
&gt; allocating, binding, etc, and then killing child processes.
&gt; 
&gt; The problem that might be happening here is that cryptomgr requests
&gt; the module to probe/load through cryptomgr_schedule_probe(), but
&gt; before the thread handler cryptomgr_probe() returns, we return from
&gt; the wait_for_completion_interruptible() function and probably already
&gt; have cleared up larval, thus we run into a NULL pointer dereference
&gt; when in cryptomgr_probe() complete_all() is being called.
&gt; 
&gt; If we wait with wait_for_completion() instead, this panic will not
&gt; occur anymore. This is valid, because in case a signal is pending,
&gt; cryptomgr_probe() returns from probing anyway with properly calling
&gt; complete_all().

The use of wait_for_completion_interruptible is intentional so that
we don't lock up the thread if a bug causes us to never wake up.

This bug is caused by the helper thread using the larval without
holding a reference count on it.  If the helper thread completes
after the original thread requesting for help has gone away and
destroyed the larval, then we get the crash above.

So the fix is to hold a reference count on the larval.

Cc: &lt;stable@vger.kernel.org&gt; # 3.6+
Reported-by: Daniel Borkmann &lt;dborkman@redhat.com&gt;
Tested-by: Daniel Borkmann &lt;dborkman@redhat.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: algapi - Move larval completion into algboss</title>
<updated>2012-06-22T12:08:29Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2012-06-22T12:08:29Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=398710379f516012c52d2ae396a9ba919bd6a7ab'/>
<id>urn:sha1:398710379f516012c52d2ae396a9ba919bd6a7ab</id>
<content type='text'>
It has been observed that sometimes the crypto allocation code
will get stuck for 60 seconds or multiples thereof.  This is
usually caused by an algorithm failing to pass the self-test.

If an algorithm fails to be constructed, we will immediately notify
all larval waiters.  However, if it succeeds in construction, but
then fails the self-test, we won't notify anyone at all.

This patch fixes this by merging the notification in the case
where the algorithm fails to be constructed with that of the
the case where it pases the self-test.  This way regardless of
what happens, we'll give the larval waiters an answer.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: Export crypto_remove_final</title>
<updated>2011-10-21T12:24:03Z</updated>
<author>
<name>Steffen Klassert</name>
<email>steffen.klassert@secunet.com</email>
</author>
<published>2011-09-27T05:23:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=22e5b20be72e2e166c3ba915b01a59a8eb2dc71f'/>
<id>urn:sha1:22e5b20be72e2e166c3ba915b01a59a8eb2dc71f</id>
<content type='text'>
The upcomming crypto usrerspace configuration api needs
to remove the spawns on top on an algorithm, so export
crypto_remove_final.

Signed-off-by: Steffen Klassert &lt;steffen.klassert@secunet.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: Export crypto_remove_spawns</title>
<updated>2011-10-21T12:24:03Z</updated>
<author>
<name>Steffen Klassert</name>
<email>steffen.klassert@secunet.com</email>
</author>
<published>2011-09-27T05:22:08Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=89b596ba22d79dd5616616a9975192e1c2bea0fe'/>
<id>urn:sha1:89b596ba22d79dd5616616a9975192e1c2bea0fe</id>
<content type='text'>
The upcomming crypto usrerspace configuration api needs
to remove the spawns on top on an algorithm, so export
crypto_remove_spawns.

Signed-off-by: Steffen Klassert &lt;steffen.klassert@secunet.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: internal - Fix checkpatch errors</title>
<updated>2010-03-10T10:24:46Z</updated>
<author>
<name>Richard Hartmann</name>
<email>richih.mailinglist@gmail.com</email>
</author>
<published>2010-03-10T10:24:46Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=269ab459da46ae37979a0d16307d1fcaa05600b2'/>
<id>urn:sha1:269ab459da46ae37979a0d16307d1fcaa05600b2</id>
<content type='text'>
Signed-off-by: Richard Hartmann &lt;richih.mailinglist@gmail.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: cryptd - Switch to template create API</title>
<updated>2009-07-14T10:45:45Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2009-07-14T10:45:45Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=9cd899a32f611eb6328014f1d9e0ba31977812d9'/>
<id>urn:sha1:9cd899a32f611eb6328014f1d9e0ba31977812d9</id>
<content type='text'>
This patch changes cryptd to use the template-&gt;create function
instead of alloc in anticipation for the switch to new style
ahash algorithms.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
</feed>
