OSDN Git Service

x86/crypto: aesni - fix crash in cryptomgr_test
authorDave Watson <davejwatson@fb.com>
Mon, 6 Aug 2018 15:02:20 +0000 (08:02 -0700)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Fri, 14 Sep 2018 15:15:54 +0000 (23:15 +0800)
commit30f8922c71c269bc832729bcce4163d1958dfdcf
treed8cdd601032474674285289e73f83d12ee63da87
parent0b9fd4033c3987ff6264e35b47a42b3acfa80190
x86/crypto: aesni - fix crash in cryptomgr_test

Fix a freeze issue in early boot stages happening with x86_64
that could be avoided only with CONFIG_CRYPTO_MANAGER_DISABLE_TESTS=y

Bisecting gives bad commit is 1476db2d129d5
("crypto: aesni - Move HashKey computation from stack to gcm_context")

Use unaligned mov instructions to avoid general protection fault

Here follows the console log of the problem:

[    1.377775] general protection fault: 0000 [#1] PREEMPT SMP
[    1.378746] CPU: 3 PID: 958 Comm: cryptomgr_test Not tainted 4.18.0-rc8-android-x86_64-g1a7fa0435ab6 #24
[    1.378746] Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006
[    1.378746] RIP: 0010:aesni_gcm_init+0x89/0x30f
[    1.378746] Code: 0f 6f ca 66 0f 73 fa 08 66 0f 73 d9 08 66 0f eb da 66 0f 70 d1 24 66 0f 76 15 83 11 03 01 66 0f db 15 6b 11 03 01 66 0f ef da <66> 0f 7f 5e 60 66 0f 6f eb 66 0f 70 cb 4e 66 0f ef cb 66 0f 7f 8e
[    1.378746] RSP: 0000:ffff9fef010377d8 EFLAGS: 00010246
[    1.378746] RAX: ffff9fef01037b98 RBX: 0000000000000010 RCX: ffff9ab4de49d050
[    1.378746] RDX: ffff9fef01037b98 RSI: ffff9fef010378c8 RDI: ffff9ab4de49d060
[    1.378746] RBP: 0000000000000000 R08: ffff9ab4de48e000 R09: 0000000000000008
[    1.378746] R10: ffff9ab55e0e1000 R11: 0000000000000000 R12: ffff9ab4de49d050
[    1.378746] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000008
[    1.378746] FS:  0000000000000000(0000) GS:ffff9ab4e3d80000(0000) knlGS:0000000000000000
[    1.378746] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    1.378746] CR2: 0000000000000000 CR3: 000000009980a001 CR4: 00000000000606e0
[    1.378746] Call Trace:
[    1.378746]  ? gcmaes_crypt_by_sg+0x12c/0x610
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to_asm+0x40/0x70
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to_asm+0x40/0x70
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to_asm+0x40/0x70
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to_asm+0x40/0x70
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to_asm+0x40/0x70
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to_asm+0x40/0x70
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to_asm+0x40/0x70
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to+0x14d/0x4a0
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? cache_alloc_refill+0x600/0x8e0
[    1.378746]  ? gcmaes_encrypt+0x1b8/0x380
[    1.378746]  ? rfc4106_set_hash_subkey+0x65/0xb0
[    1.378746]  ? aesni_enc+0xf/0x14
[    1.378746]  ? rfc4106_set_hash_subkey+0x65/0xb0
[    1.378746]  ? crypto_aead_setkey+0xa6/0xe0
[    1.378746]  ? try_to_wake_up+0x4b0/0x4b0
[    1.378746]  ? crypto_aead_setkey+0xa6/0xe0
[    1.378746]  ? helper_rfc4106_encrypt+0x91/0xc0
[    1.378746]  ? __test_aead+0xd8c/0x1290
[    1.378746]  ? __kmalloc+0x126/0x200
[    1.378746]  ? crypto_create_tfm+0x39/0xe0
[    1.378746]  ? test_aead+0x33/0xd0
[    1.378746]  ? alg_test_aead+0x4d/0xb0
[    1.378746]  ? alg_test.part.11+0xd7/0x280
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? finish_task_switch+0x90/0x240
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __schedule+0x311/0x881
[    1.378746]  ? __wake_up_common+0x86/0x120
[    1.378746]  ? cryptomgr_probe+0xe0/0xe0
[    1.378746]  ? cryptomgr_test+0x40/0x50
[    1.378746]  ? kthread+0xfa/0x130
[    1.378746]  ? __switch_to_asm+0x34/0x70
[    1.378746]  ? __kthread_parkme+0x70/0x70
[    1.378746]  ? ret_from_fork+0x35/0x40
[    1.378746] Modules linked in:
[    1.490849] ---[ end trace db6c6409ac47aa26 ]---
[    1.491659] RIP: 0010:aesni_gcm_init+0x89/0x30f
[    1.492819] Code: 0f 6f ca 66 0f 73 fa 08 66 0f 73 d9 08 66 0f eb da 66 0f 70 d1 24 66 0f 76 15 83 11 03 01 66 0f db 15 6b 11 03 01 66 0f ef da <66> 0f 7f 5e 60 66 0f 6f eb 66 0f 70 cb 4e 66 0f ef cb 66 0f 7f 8e
[    1.497069] RSP: 0000:ffff9fef010377d8 EFLAGS: 00010246
[    1.498193] RAX: ffff9fef01037b98 RBX: 0000000000000010 RCX: ffff9ab4de49d050
[    1.499901] RDX: ffff9fef01037b98 RSI: ffff9fef010378c8 RDI: ffff9ab4de49d060
[    1.502322] RBP: 0000000000000000 R08: ffff9ab4de48e000 R09: 0000000000000008
[    1.505797] R10: ffff9ab55e0e1000 R11: 0000000000000000 R12: ffff9ab4de49d050
[    1.507597] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000008
[    1.509530] FS:  0000000000000000(0000) GS:ffff9ab4e3d80000(0000) knlGS:0000000000000000
[    1.511639] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    1.513132] CR2: 0000000000000000 CR3: 000000009980a001 CR4: 00000000000606e0
[    1.514915] note: cryptomgr_test[958] exited with preempt_count 2

Fixes: 1476db2d129d5 ("crypto: aesni - Move HashKey computation from stack to gcm_context")
Reported-by: Mauro Rossi <issor.oruam@gmail.com>
Tested-by: Mauro Rossi <issor.oruam@gmail.com>
arch/x86/crypto/aesni-intel_asm.S