From: Stephan Mueller <smueller@chronox.de>
To: Harsh Jain <harshjain.prof@gmail.com>
Cc: herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org
Subject: Re: kernel tainted while exporting shash context using af_alg interface
Date: Wed, 28 Oct 2015 12:23:54 +0100 [thread overview]
Message-ID: <28376488.AMz6xlEXXD@tauon.atsec.com> (raw)
In-Reply-To: <CAFXBA=mM=6TRbGV1VfE7fHnvYecit+rZgExduCex+wzKmd231Q@mail.gmail.com>
Am Mittwoch, 28. Oktober 2015, 16:24:34 schrieb Harsh Jain:
Hi Harsh,
>Hi Stephan,
>
>I tried your patch on my machine. Kernel is not crashing. The openssl
>break with this. Can you share HMAC program which you are suspecting
>it will not work or do you already have some test written in
>libkcapi/test.sh which will fail.
See comments above test/kcapi-main.c:cavs_hash
* HMAC command line invocation:
* $ ./kcapi -x 3 -c "hmac(sha1)" -k 6e77ebd479da794707bc6cde3694f552ea892dab
-p
31b62a797adbff6b8a358d2b5206e01fee079de8cdfc4695138bba163b4efbf30127343e7fd4fbc696c3d38d8f27f57c024b5056f726ceeb4c31d98e57751ec8cbe8904ee0f9b031ae6a0c55da5e062475b3d7832191d4057643ef5fa446801d59a04693e573a8159cd2416b7bd39c7f0fe63c599365e04d596c05736beaab58
* 7f204ea665666f5bd2b370e546d1b408005e4d85
To do that, apply your patch and then
1. open lib/kcapi-kernel-if.c and change line 567 from
handle->opfd = accept(handle->tfmfd, NULL, 0);
to
handle->opfd = accept(handle->tfmfd, NULL, 0);
handle->opfd = accept(handle->opfd, NULL, 0);
handle->opfd = accept(handle->opfd, NULL, 0);
handle->opfd = accept(handle->opfd, NULL, 0);
handle->opfd = accept(handle->opfd, NULL, 0);
You will see that the hash commands will pass, the HMAC fails
Without your patch, the kernel crashes (same as with your OpenSSL code).
The reason is that setkey is applied on the TFM that is not conveyed to the
subsequent TFMs generated with new accepts.
>
>
>Regards
>Harsh Jain
>
>On Wed, Oct 28, 2015 at 6:25 AM, Stephan Mueller <smueller@chronox.de> wrote:
>> Am Mittwoch, 28. Oktober 2015, 01:09:58 schrieb Stephan Mueller:
>>
>> Hi Harsh,
>>
>>> However, any error in user space should not crash the kernel. So, a fix
>>> should be done. But I think your code is not correct as it solidifies a
>>> broken user space code.
>>
>> After thinking a bit again, I think your approach is correct after all. I
>> was able to reproduce the crash by simply adding more accept calls to my
>> test code. And I can confirm that your patch works, for hashes.
>>
>> *BUT* it does NOT work for HMAC as the key is set on the TFM and the
>> subsequent accepts do not transport the key. Albeit your code prevents the
>> kernel from crashing, the HMAC calculation will be done with an empty key
>> as
>> the setkey operation does not reach the TFM handle in the subordinate
>> accept() call.
>>
>> So, I would think that the second accept is simply broken, for HMAC at
>> least.
>>
>> Herbert, what is the purpose of that subordinate accept that is implemented
>> with hash_accept? As this is broken for HMACs, should it be removed
>> entirely?
>>
>> --
>> Ciao
>> Stephan
>
>--
>To unsubscribe from this list: send the line "unsubscribe linux-crypto" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
Ciao
Stephan
next prev parent reply other threads:[~2015-10-28 11:24 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-25 6:26 kernel tainted while exporting shash context using af_alg interface Harsh Jain
2015-10-25 11:58 ` Stephan Mueller
2015-10-26 6:19 ` Harsh Jain
2015-10-26 9:21 ` Harsh Jain
2015-10-28 0:09 ` Stephan Mueller
2015-10-28 0:55 ` Stephan Mueller
2015-10-28 10:54 ` Harsh Jain
2015-10-28 11:23 ` Stephan Mueller [this message]
2015-10-30 8:32 ` Harsh Jain
2015-10-30 11:10 ` Stephan Mueller
2015-10-30 12:16 ` crypto: algif_hash - Only export and import on sockets with data Herbert Xu
2015-10-30 23:45 ` Stephan Mueller
2015-11-01 9:11 ` [PATCH v2] " Herbert Xu
2015-11-01 11:06 ` Stephan Mueller
2015-11-01 11:07 ` Stephan Mueller
2015-11-02 3:12 ` Herbert Xu
2015-11-05 7:42 ` Harsh Jain
2015-11-05 12:19 ` Herbert Xu
2015-11-02 5:48 ` kernel tainted while exporting shash context using af_alg interface Harsh Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=28376488.AMz6xlEXXD@tauon.atsec.com \
--to=smueller@chronox.de \
--cc=harshjain.prof@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox