linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [Bug] s5p-sss crypto driver doesn't set next AES-CBC IV
@ 2019-02-15 18:51 ` Eric Biggers
  2019-02-16  9:52   ` Krzysztof Kozlowski
  2019-02-19  9:58   ` Kamil Konieczny
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Biggers @ 2019-02-15 18:51 UTC (permalink / raw)
  To: Christoph Manszewski, Krzysztof Kozlowski, Vladimir Zapolskiy,
	Kamil Konieczny, linux-samsung-soc
  Cc: linux-crypto, linux-arm-kernel

Hello,

The AES-CBC implementation in the s5p-sss crypto driver is failing the improved
crypto self-tests I currently have out for review.  The improved tests check
that all CBC implementations update the IV buffer to be the last ciphertext
block.  This has always been required so that requests can be chained, but
unfortunately it wasn't tested for by the self-tests until now.

See the boot logs for Exynos platforms from the KernelCI job here:
https://kernelci.org/boot/all/job/ardb/branch/for-kernelci/kernel/v5.0-rc1-149-g64c945c018af/

alg: skcipher: cbc-aes-s5p encryption test failed (wrong output IV) on test vector 0, cfg=\"in-place\"
00000000: 3d af ba 42 9d 9e b4 30 b4 22 da 80 2c 9f ac 41

You can reproduce by pulling from
https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git
branch "iv-out-testing", unsetting CONFIG_CRYPTO_MANAGER_DISABLE_TESTS,
setting CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y, rebooting and checking dmesg.

(CRYPTO_MANAGER_EXTRA_TESTS is probably unneeded for this, but you might as well
use it.  Also you can optionally revert the last patch, which makes crypto
self-test failures cause a kernel panic for testing purposes.  It's possible
that ctr-aes-s5p is failing too but it was just never gotten to...)

The patch series is also available on the linux-crypto mailing list:
https://patchwork.kernel.org/cover/10811951/

Note that I don't have this hardware myself, so if it turns out that no one is
interested in fixing this anytime soon I'll instead have to propose disabling
these algorithm(s) until they can be fixed.

Thanks,

- Eric

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [Bug] s5p-sss crypto driver doesn't set next AES-CBC IV
  2019-02-15 18:51 ` [Bug] s5p-sss crypto driver doesn't set next AES-CBC IV Eric Biggers
@ 2019-02-16  9:52   ` Krzysztof Kozlowski
  2019-02-19  9:58   ` Kamil Konieczny
  1 sibling, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2019-02-16  9:52 UTC (permalink / raw)
  To: Eric Biggers
  Cc: linux-samsung-soc, Christoph Manszewski, Vladimir Zapolskiy,
	linux-crypto, Kamil Konieczny, linux-arm-kernel

On Fri, 15 Feb 2019 at 19:51, Eric Biggers <ebiggers@kernel.org> wrote:
>
> Hello,
>
> The AES-CBC implementation in the s5p-sss crypto driver is failing the improved
> crypto self-tests I currently have out for review.  The improved tests check
> that all CBC implementations update the IV buffer to be the last ciphertext
> block.  This has always been required so that requests can be chained, but
> unfortunately it wasn't tested for by the self-tests until now.
>
> See the boot logs for Exynos platforms from the KernelCI job here:
> https://kernelci.org/boot/all/job/ardb/branch/for-kernelci/kernel/v5.0-rc1-149-g64c945c018af/
>
> alg: skcipher: cbc-aes-s5p encryption test failed (wrong output IV) on test vector 0, cfg=\"in-place\"
> 00000000: 3d af ba 42 9d 9e b4 30 b4 22 da 80 2c 9f ac 41
>
> You can reproduce by pulling from
> https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/linux.git
> branch "iv-out-testing", unsetting CONFIG_CRYPTO_MANAGER_DISABLE_TESTS,
> setting CONFIG_CRYPTO_MANAGER_EXTRA_TESTS=y, rebooting and checking dmesg.
>
> (CRYPTO_MANAGER_EXTRA_TESTS is probably unneeded for this, but you might as well
> use it.  Also you can optionally revert the last patch, which makes crypto
> self-test failures cause a kernel panic for testing purposes.  It's possible
> that ctr-aes-s5p is failing too but it was just never gotten to...)
>
> The patch series is also available on the linux-crypto mailing list:
> https://patchwork.kernel.org/cover/10811951/
>
> Note that I don't have this hardware myself, so if it turns out that no one is
> interested in fixing this anytime soon I'll instead have to propose disabling
> these algorithm(s) until they can be fixed.

Thanks for the report. I'll take a look. I have the HW so I think I
will be able to reproduce it easily.

Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [Bug] s5p-sss crypto driver doesn't set next AES-CBC IV
  2019-02-15 18:51 ` [Bug] s5p-sss crypto driver doesn't set next AES-CBC IV Eric Biggers
  2019-02-16  9:52   ` Krzysztof Kozlowski
@ 2019-02-19  9:58   ` Kamil Konieczny
  2019-02-19 10:11     ` Ard Biesheuvel
  1 sibling, 1 reply; 4+ messages in thread
From: Kamil Konieczny @ 2019-02-19  9:58 UTC (permalink / raw)
  To: Eric Biggers, Christoph Manszewski, Krzysztof Kozlowski,
	Vladimir Zapolskiy, linux-samsung-soc
  Cc: linux-crypto, linux-arm-kernel

Hi,

On 15.02.2019 19:51, Eric Biggers wrote:
> Hello,
> 
> The AES-CBC implementation in the s5p-sss crypto driver is failing the improved
> crypto self-tests I currently have out for review.  The improved tests check
> that all CBC implementations update the IV buffer to be the last ciphertext
> block.  This has always been required so that requests can be chained, but
> unfortunately it wasn't tested for by the self-tests until now.
> 
> See the boot logs for Exynos platforms from the KernelCI job here:
> https://kernelci.org/boot/all/job/ardb/branch/for-kernelci/kernel/v5.0-rc1-149-g64c945c018af/
> 
> alg: skcipher: cbc-aes-s5p encryption test failed (wrong output IV) on test vector 0, cfg=\"in-place\"
> 00000000: 3d af ba 42 9d 9e b4 30 b4 22 da 80 2c 9f ac 41
> [...]

I checked dmesg logs after my patch with:

root@target:~# dmesg |grep alg: |grep aes                                       
[    4.087168] crypto: alg: self-tests for aes-generic (aes) passed             
[    6.305202] crypto: alg: self-tests for ecb-aes-s5p (ecb(aes)) passed        
[    6.405489] crypto: alg: self-tests for cbc-aes-s5p (cbc(aes)) passed        
[    6.505000] crypto: alg: self-tests for ctr-aes-s5p (ctr(aes)) passed

and I noticed there are no cbc-aes-generic nor ctr-aes-generic

Did you test them in separate tree ? Why they are not registered in /proc/crypto ?

-- 
Best regards,
Kamil Konieczny
Samsung R&D Institute Poland


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [Bug] s5p-sss crypto driver doesn't set next AES-CBC IV
  2019-02-19  9:58   ` Kamil Konieczny
@ 2019-02-19 10:11     ` Ard Biesheuvel
  0 siblings, 0 replies; 4+ messages in thread
From: Ard Biesheuvel @ 2019-02-19 10:11 UTC (permalink / raw)
  To: Kamil Konieczny
  Cc: linux-samsung-soc, Christoph Manszewski, Krzysztof Kozlowski,
	Vladimir Zapolskiy, Eric Biggers,
	open list:HARDWARE RANDOM NUMBER GENERATOR CORE,
	linux-arm-kernel

On Tue, 19 Feb 2019 at 10:58, Kamil Konieczny
<k.konieczny@partner.samsung.com> wrote:
>
> Hi,
>
> On 15.02.2019 19:51, Eric Biggers wrote:
> > Hello,
> >
> > The AES-CBC implementation in the s5p-sss crypto driver is failing the improved
> > crypto self-tests I currently have out for review.  The improved tests check
> > that all CBC implementations update the IV buffer to be the last ciphertext
> > block.  This has always been required so that requests can be chained, but
> > unfortunately it wasn't tested for by the self-tests until now.
> >
> > See the boot logs for Exynos platforms from the KernelCI job here:
> > https://kernelci.org/boot/all/job/ardb/branch/for-kernelci/kernel/v5.0-rc1-149-g64c945c018af/
> >
> > alg: skcipher: cbc-aes-s5p encryption test failed (wrong output IV) on test vector 0, cfg=\"in-place\"
> > 00000000: 3d af ba 42 9d 9e b4 30 b4 22 da 80 2c 9f ac 41
> > [...]
>
> I checked dmesg logs after my patch with:
>
> root@target:~# dmesg |grep alg: |grep aes
> [    4.087168] crypto: alg: self-tests for aes-generic (aes) passed
> [    6.305202] crypto: alg: self-tests for ecb-aes-s5p (ecb(aes)) passed
> [    6.405489] crypto: alg: self-tests for cbc-aes-s5p (cbc(aes)) passed
> [    6.505000] crypto: alg: self-tests for ctr-aes-s5p (ctr(aes)) passed
>
> and I noticed there are no cbc-aes-generic nor ctr-aes-generic
>
> Did you test them in separate tree ? Why they are not registered in /proc/crypto ?
>

Generic CBC and CTR are template based, so they are only instantiated on demand.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2019-02-19 10:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20190215185148epcas3p23960bfe37c629ebb2103e673509949f4@epcas3p2.samsung.com>
2019-02-15 18:51 ` [Bug] s5p-sss crypto driver doesn't set next AES-CBC IV Eric Biggers
2019-02-16  9:52   ` Krzysztof Kozlowski
2019-02-19  9:58   ` Kamil Konieczny
2019-02-19 10:11     ` Ard Biesheuvel

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