<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/crypto/internal.h, branch v3.16.40</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.16.40</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v3.16.40'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2013-06-25T11:15:17Z</updated>
<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>
<entry>
<title>crypto: hash - Remove legacy hash/digest implementaion</title>
<updated>2009-07-14T04:58:07Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2009-07-12T05:58:04Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=6941c3a0aabb6ad4167827360f384e9daed7dd7f'/>
<id>urn:sha1:6941c3a0aabb6ad4167827360f384e9daed7dd7f</id>
<content type='text'>
This patch removes the implementation of hash and digest now that
no algorithms use them anymore.  The interface though will remain
until the users are converted across.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: api - Add crypto_attr_alg2 helper</title>
<updated>2009-07-08T10:58:29Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2009-07-08T09:53:16Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=d06854f0243d91badabaab14503f7f3bb770061d'/>
<id>urn:sha1:d06854f0243d91badabaab14503f7f3bb770061d</id>
<content type='text'>
This patch adds the helper crypto_attr_alg2 which is similar to
crypto_attr_alg but takes an extra frontend argument.  This is
intended to be used by new style algorithm types such as shash.

Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>random: Add optional continuous repetition test to entropy store based rngs</title>
<updated>2009-06-18T11:50:21Z</updated>
<author>
<name>Neil Horman</name>
<email>nhorman@tuxdriver.com</email>
</author>
<published>2009-06-18T11:50:21Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5b739ef8a4e8cf5201d21abff897e292c232477b'/>
<id>urn:sha1:5b739ef8a4e8cf5201d21abff897e292c232477b</id>
<content type='text'>
FIPS-140 requires that all random number generators implement continuous self
tests in which each extracted block of data is compared against the last block
for repetition.  The ansi_cprng implements such a test, but it would be nice if
the hw rng's did the same thing.  Obviously its not something thats always
needed, but it seems like it would be a nice feature to have on occasion. I've
written the below patch which allows individual entropy stores to be flagged as
desiring a continuous test to be run on them as is extracted.  By default this
option is off, but is enabled in the event that fips mode is selected during
bootup.

Signed-off-by: Neil Horman &lt;nhorman@tuxdriver.com&gt;
Acked-by: Matt Mackall &lt;mpm@selenic.com&gt;
Signed-off-by: Herbert Xu &lt;herbert@gondor.apana.org.au&gt;
</content>
</entry>
<entry>
<title>crypto: testmgr - Dynamically allocate xbuf and axbuf</title>
<updated>2009-06-02T04:04:45Z</updated>
<author>
<name>Herbert Xu</name>
<email>herbert@gondor.apana.org.au</email>
</author>
<published>2009-05-06T06:15:47Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=f8b0d4d09dc9d0a73fcdcf6c2724650529ec417d'/>
<id>urn:sha1:f8b0d4d09dc9d0a73fcdcf6c2724650529ec417d</id>
<content type='text'>
We currently allocate temporary memory that is used for testing
statically.  This renders the testing engine non-reentrant. As
algorithms may nest, i.e., one may construct another in order to
carry out a part of its operation, this is unacceptable.  For
example, it has been reported that an AEAD implementation allocates
a cipher in its setkey function, which causes it to fail during
testing as the temporary memory is overwritten.

This patch replaces the static memory with dynamically allocated
buffers.  We need a maximum of 16 pages so this slightly increases
the chances of an algorithm failing due to memory shortage.
However, as testing usually occurs at registration, this shouldn't
be a big problem.

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