2023-02-10 00:26:43

by Erhard Furtner

[permalink] [raw]
Subject: Segmentation fault + invalid opcode: 0000 [#1] SMP NOPTI at using ARIA cipher (kernel 6.2.0-rc7)

Hello!

I wanted to give the new ARIA cipher a try on my AMD FX-8370 but got a segmentation fault as a result:

# cryptsetup benchmark -c aria-ctr-plain64
# Tests are approximate using memory only (no storage IO).
Segmentation fault

Kernel 6.2.0-rc7 showed the use of an invalid opcode for this command:

[...]
invalid opcode: 0000 [#1] SMP NOPTI
CPU: 4 PID: 5388 Comm: cryptsetup Tainted: G T 6.2.0-rc7-bdver2 #2
Hardware name: Gigabyte Technology Co., Ltd. To be filled by O.E.M./970-GAMING, BIOS F2 04/06/2016
RIP: 0010:__aria_aesni_avx_crypt_16way+0x225/0x6000 [aria_aesni_avx_x86_64]
Code: c4 41 7a 7f 48 10 c4 41 7a 7f 50 20 c4 41 7a 7f 58 30 c4 41 7a 7f 60 40 c4 41 7a 7f 68 50 c4 41 7a 7f 70 60 c4 41 7a 7f 78 70 <c4> c2 79 78 41 0b c5 39 ef c0 c4 c2 79 78 41 0a c5 31 ef c8 c4 c2
RSP: 0018:ffffaf3f0df93b60 EFLAGS: 00010286
RAX: ffffaf3f0df93c38 RBX: ffffaf3f0df93c38 RCX: ffffaf3f0df93c38
RDX: ffffaf3f0df93c38 RSI: ffffaf3f0df93c38 RDI: ffff9a17a9e74c20
RBP: ffffaf3f0df93d70 R08: ffffaf3f0df93cb8 R09: ffff9a17a9e74c20
R10: ffff9a1776d51000 R11: ffff9a17c1286000 R12: fefefefefefefefe
R13: ffff9a17c1286000 R14: ffff9a1776d51100 R15: ffff9a1776d52000
FS: 00007f0a907020e0(0000) GS:ffff9a1a5ed00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f0a9010e000 CR3: 0000000123e6c000 CR4: 00000000000406e0
Call Trace:
<TASK>
aria_aesni_avx_ctr_crypt_16way+0x19/0x110 [aria_aesni_avx_x86_64]
aria_avx_ctr_encrypt+0x12e/0x2f3 [aria_aesni_avx_x86_64]
skcipher_recvmsg+0x30c/0x3e0 [algif_skcipher]
sock_read_iter+0x107/0x110
vfs_read+0x2d6/0x300
ksys_read+0xa1/0xe0
do_syscall_64+0x5b/0x80
? do_syscall_64+0x67/0x80
entry_SYSCALL_64_after_hwframe+0x4b/0xb5
RIP: 0033:0x7f0a90780230
Code: c3 8b 07 85 c0 75 24 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> e9 ea 1f ff ff 48 31 ed 48 89 e7 48 8d 35 dd 7b 03 00 48 83 e4
RSP: 002b:00007ffccd0ae718 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0a90780230
RDX: 0000000000010000 RSI: 00007f0a900ff000 RDI: 0000000000000006
RBP: 00007f0a907020e0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000010000
R13: 0000000000010000 R14: 00007f0a900ff000 R15: 00007ffccd0ae878
</TASK>
Modules linked in: aria_aesni_avx_x86_64 aria_generic ctr snd_hrtimer snd_seq snd_seq_device fuse zram zsmalloc nfsd auth_rpcgss lockd grace sunrpc cfg80211 ccm algif_aead cbc des_generic libdes ecb cmac sha1_ssse3 sha1_generic md5 md4 bnep bluetooth jitterentropy_rng drbg ansi_cprng ecdh_generic ecc rfkill dm_crypt nhpoly1305_sse2 nhpoly1305 chacha_generic chacha_x86_64 libchacha adiantum libpoly1305 algif_skcipher joydev input_leds amdgpu mfd_core gpu_sched drm_buddy dm_mod hid_generic usbhid hid crc32_pclmul sha512_ssse3 sha512_generic snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio led_class radeon snd_hda_codec_hdmi pkcs8_key_parser video wmi snd_hda_intel i2c_algo_bit snd_intel_dspcfg drm_ttm_helper snd_hda_codec aesni_intel ttm it87 snd_hwdep sr_mod libaes ohci_pci hwmon_vid evdev crypto_simd cdrom cryptd fam15h_power xhci_pci drm_display_helper ohci_hcd ehci_pci snd_hda_core k10temp hwmon xhci_hcd ehci_hcd drm_kms_helper snd_pcm syscopyarea 8250 sysfillrect
i2c_piix4 8250_base sysimgblt usbcore snd_timer serial_core usb_common drm snd drm_panel_orientation_quirks backlight soundcore acpi_cpufreq button processor efivarfs
---[ end trace 0000000000000000 ]---
RIP: 0010:__aria_aesni_avx_crypt_16way+0x225/0x6000 [aria_aesni_avx_x86_64]
Code: c4 41 7a 7f 48 10 c4 41 7a 7f 50 20 c4 41 7a 7f 58 30 c4 41 7a 7f 60 40 c4 41 7a 7f 68 50 c4 41 7a 7f 70 60 c4 41 7a 7f 78 70 <c4> c2 79 78 41 0b c5 39 ef c0 c4 c2 79 78 41 0a c5 31 ef c8 c4 c2
RSP: 0018:ffffaf3f0df93b60 EFLAGS: 00010286
RAX: ffffaf3f0df93c38 RBX: ffffaf3f0df93c38 RCX: ffffaf3f0df93c38
RDX: ffffaf3f0df93c38 RSI: ffffaf3f0df93c38 RDI: ffff9a17a9e74c20
RBP: ffffaf3f0df93d70 R08: ffffaf3f0df93cb8 R09: ffff9a17a9e74c20
R10: ffff9a1776d51000 R11: ffff9a17c1286000 R12: fefefefefefefefe
R13: ffff9a17c1286000 R14: ffff9a1776d51100 R15: ffff9a1776d52000
FS: 00007f0a907020e0(0000) GS:ffff9a1a5ed00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f0a9010e000 CR3: 0000000123e6c000 CR4: 00000000000406e0

Some data about the cpu:
# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 48 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 8
On-line CPU(s) list: 0-7
Vendor ID: AuthenticAMD
BIOS Vendor ID: AMD
Model name: AMD FX-8370 Eight-Core Processor
BIOS Model name: AMD FX-8370 Eight-Core Processor To Be Filled By O.E.M. CPU @ 4.
0GHz
BIOS CPU family: 63
CPU family: 21
Model: 2
Thread(s) per core: 2
Core(s) per socket: 4
Socket(s): 1
Stepping: 0
Frequency boost: enabled
CPU(s) scaling MHz: 60%
CPU max MHz: 4000.0000
CPU min MHz: 1400.0000
BogoMIPS: 8040.11
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush
mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc
rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf pni pclmulqdq monitor s
sse3 fma cx16 sse4_1 sse4_2 popcnt aes xsave avx f16c lahf_lm cmp_legacy svm ex
tapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs xop skinit wdt fm
a4 tce nodeid_msr tbm topoext perfctr_core perfctr_nb cpb hw_pstate ssbd ibpb v
mmcall bmi1 arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid d
ecodeassists pausefilter pfthreshold
Virtualization features:
Virtualization: AMD-V
Caches (sum of all):
L1d: 128 KiB (8 instances)
L1i: 256 KiB (4 instances)
L2: 8 MiB (4 instances)
L3: 8 MiB (1 instance)
Vulnerabilities:
Itlb multihit: Not affected
L1tf: Not affected
Mds: Not affected
Meltdown: Not affected
Mmio stale data: Not affected
Retbleed: Mitigation; untrained return thunk; SMT vulnerable
Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Spectre v2: Mitigation; Retpolines, IBPB conditional, STIBP disabled, RSB filling, PBRSB-eI
BRS Not affected
Srbds: Not affected
Tsx async abort: Not affected


Could it be that this AVX implementation of ARIA requires AVX2 actually? dmesg + custom kernel .config + aria-aesni-avx-x86_64.ko for my FX-8370 attached.

Regards,
Erhard


Attachments:
(No filename) (7.05 kB)
config_62-rc7_bdver2 (116.70 kB)
dmesg_62-rc7_bdver2.txt (65.47 kB)
aria-aesni-avx-x86_64.ko.gz (16.17 kB)
Download all attachments

2023-02-10 11:49:54

by Taehee Yoo

[permalink] [raw]
Subject: Re: Segmentation fault + invalid opcode: 0000 [#1] SMP NOPTI at using ARIA cipher (kernel 6.2.0-rc7)

On 2/10/23 09:26, Erhard F. wrote:
> Hello!

I Erhard.
Thank you so much for the report!

Herber sent the same report a few days ago.
So, I'm writing a patch for it and send it soon.
I will really appreciate it if you could test that patch.

>
> I wanted to give the new ARIA cipher a try on my AMD FX-8370 but got
a segmentation fault as a result:
>
> # cryptsetup benchmark -c aria-ctr-plain64
> # Tests are approximate using memory only (no storage IO).
> Segmentation fault
>
> Kernel 6.2.0-rc7 showed the use of an invalid opcode for this command:
>
> [...]
> invalid opcode: 0000 [#1] SMP NOPTI
> CPU: 4 PID: 5388 Comm: cryptsetup Tainted: G T
6.2.0-rc7-bdver2 #2
> Hardware name: Gigabyte Technology Co., Ltd. To be filled by
O.E.M./970-GAMING, BIOS F2 04/06/2016
> RIP: 0010:__aria_aesni_avx_crypt_16way+0x225/0x6000
[aria_aesni_avx_x86_64]
> Code: c4 41 7a 7f 48 10 c4 41 7a 7f 50 20 c4 41 7a 7f 58 30 c4 41 7a
7f 60 40 c4 41 7a 7f 68 50 c4 41 7a 7f 70 60 c4 41 7a 7f 78 70 <c4> c2
79 78 41 0b c5 39 ef c0 c4 c2 79 78 41 0a c5 31 ef c8 c4 c2
> RSP: 0018:ffffaf3f0df93b60 EFLAGS: 00010286
> RAX: ffffaf3f0df93c38 RBX: ffffaf3f0df93c38 RCX: ffffaf3f0df93c38
> RDX: ffffaf3f0df93c38 RSI: ffffaf3f0df93c38 RDI: ffff9a17a9e74c20
> RBP: ffffaf3f0df93d70 R08: ffffaf3f0df93cb8 R09: ffff9a17a9e74c20
> R10: ffff9a1776d51000 R11: ffff9a17c1286000 R12: fefefefefefefefe
> R13: ffff9a17c1286000 R14: ffff9a1776d51100 R15: ffff9a1776d52000
> FS: 00007f0a907020e0(0000) GS:ffff9a1a5ed00000(0000)
knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007f0a9010e000 CR3: 0000000123e6c000 CR4: 00000000000406e0
> Call Trace:
> <TASK>
> aria_aesni_avx_ctr_crypt_16way+0x19/0x110 [aria_aesni_avx_x86_64]
> aria_avx_ctr_encrypt+0x12e/0x2f3 [aria_aesni_avx_x86_64]
> skcipher_recvmsg+0x30c/0x3e0 [algif_skcipher]
> sock_read_iter+0x107/0x110
> vfs_read+0x2d6/0x300
> ksys_read+0xa1/0xe0
> do_syscall_64+0x5b/0x80
> ? do_syscall_64+0x67/0x80
> entry_SYSCALL_64_after_hwframe+0x4b/0xb5
> RIP: 0033:0x7f0a90780230
> Code: c3 8b 07 85 c0 75 24 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89
c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> e9
ea 1f ff ff 48 31 ed 48 89 e7 48 8d 35 dd 7b 03 00 48 83 e4
> RSP: 002b:00007ffccd0ae718 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
> RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0a90780230
> RDX: 0000000000010000 RSI: 00007f0a900ff000 RDI: 0000000000000006
> RBP: 00007f0a907020e0 R08: 0000000000000000 R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000010000
> R13: 0000000000010000 R14: 00007f0a900ff000 R15: 00007ffccd0ae878
> </TASK>
> Modules linked in: aria_aesni_avx_x86_64 aria_generic ctr snd_hrtimer
snd_seq snd_seq_device fuse zram zsmalloc nfsd auth_rpcgss lockd grace
sunrpc cfg80211 ccm algif_aead cbc des_generic libdes ecb cmac
sha1_ssse3 sha1_generic md5 md4 bnep bluetooth jitterentropy_rng drbg
ansi_cprng ecdh_generic ecc rfkill dm_crypt nhpoly1305_sse2 nhpoly1305
chacha_generic chacha_x86_64 libchacha adiantum libpoly1305
algif_skcipher joydev input_leds amdgpu mfd_core gpu_sched drm_buddy
dm_mod hid_generic usbhid hid crc32_pclmul sha512_ssse3 sha512_generic
snd_hda_codec_realtek snd_hda_codec_generic ledtrig_audio led_class
radeon snd_hda_codec_hdmi pkcs8_key_parser video wmi snd_hda_intel
i2c_algo_bit snd_intel_dspcfg drm_ttm_helper snd_hda_codec aesni_intel
ttm it87 snd_hwdep sr_mod libaes ohci_pci hwmon_vid evdev crypto_simd
cdrom cryptd fam15h_power xhci_pci drm_display_helper ohci_hcd ehci_pci
snd_hda_core k10temp hwmon xhci_hcd ehci_hcd drm_kms_helper snd_pcm
syscopyarea 8250 sysfillrect
> i2c_piix4 8250_base sysimgblt usbcore snd_timer serial_core
usb_common drm snd drm_panel_orientation_quirks backlight soundcore
acpi_cpufreq button processor efivarfs
> ---[ end trace 0000000000000000 ]---
> RIP: 0010:__aria_aesni_avx_crypt_16way+0x225/0x6000
[aria_aesni_avx_x86_64]
> Code: c4 41 7a 7f 48 10 c4 41 7a 7f 50 20 c4 41 7a 7f 58 30 c4 41 7a
7f 60 40 c4 41 7a 7f 68 50 c4 41 7a 7f 70 60 c4 41 7a 7f 78 70 <c4> c2
79 78 41 0b c5 39 ef c0 c4 c2 79 78 41 0a c5 31 ef c8 c4 c2
> RSP: 0018:ffffaf3f0df93b60 EFLAGS: 00010286
> RAX: ffffaf3f0df93c38 RBX: ffffaf3f0df93c38 RCX: ffffaf3f0df93c38
> RDX: ffffaf3f0df93c38 RSI: ffffaf3f0df93c38 RDI: ffff9a17a9e74c20
> RBP: ffffaf3f0df93d70 R08: ffffaf3f0df93cb8 R09: ffff9a17a9e74c20
> R10: ffff9a1776d51000 R11: ffff9a17c1286000 R12: fefefefefefefefe
> R13: ffff9a17c1286000 R14: ffff9a1776d51100 R15: ffff9a1776d52000
> FS: 00007f0a907020e0(0000) GS:ffff9a1a5ed00000(0000)
knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00007f0a9010e000 CR3: 0000000123e6c000 CR4: 00000000000406e0
>
> Some data about the cpu:
> # lscpu
> Architecture: x86_64
> CPU op-mode(s): 32-bit, 64-bit
> Address sizes: 48 bits physical, 48 bits virtual
> Byte Order: Little Endian
> CPU(s): 8
> On-line CPU(s) list: 0-7
> Vendor ID: AuthenticAMD
> BIOS Vendor ID: AMD
> Model name: AMD FX-8370 Eight-Core Processor
> BIOS Model name: AMD FX-8370 Eight-Core Processor
To Be Filled By O.E.M. CPU @ 4.
> 0GHz
> BIOS CPU family: 63
> CPU family: 21
> Model: 2
> Thread(s) per core: 2
> Core(s) per socket: 4
> Socket(s): 1
> Stepping: 0
> Frequency boost: enabled
> CPU(s) scaling MHz: 60%
> CPU max MHz: 4000.0000
> CPU min MHz: 1400.0000
> BogoMIPS: 8040.11
> Flags: fpu vme de pse tsc msr pae mce cx8 apic sep
mtrr pge mca cmov pat pse36 clflush
> mmx fxsr sse sse2 ht syscall nx mmxext
fxsr_opt pdpe1gb rdtscp lm constant_tsc
> rep_good nopl nonstop_tsc cpuid
extd_apicid aperfmperf pni pclmulqdq monitor s
> sse3 fma cx16 sse4_1 sse4_2 popcnt aes
xsave avx f16c lahf_lm cmp_legacy svm ex
> tapic cr8_legacy abm sse4a misalignsse
3dnowprefetch osvw ibs xop skinit wdt fm
> a4 tce nodeid_msr tbm topoext perfctr_core
perfctr_nb cpb hw_pstate ssbd ibpb v
> mmcall bmi1 arat npt lbrv svm_lock
nrip_save tsc_scale vmcb_clean flushbyasid d
> ecodeassists pausefilter pfthreshold
> Virtualization features:
> Virtualization: AMD-V
> Caches (sum of all):
> L1d: 128 KiB (8 instances)
> L1i: 256 KiB (4 instances)
> L2: 8 MiB (4 instances)
> L3: 8 MiB (1 instance)
> Vulnerabilities:
> Itlb multihit: Not affected
> L1tf: Not affected
> Mds: Not affected
> Meltdown: Not affected
> Mmio stale data: Not affected
> Retbleed: Mitigation; untrained return thunk; SMT
vulnerable
> Spec store bypass: Mitigation; Speculative Store Bypass
disabled via prctl
> Spectre v1: Mitigation; usercopy/swapgs barriers and
__user pointer sanitization
> Spectre v2: Mitigation; Retpolines, IBPB conditional,
STIBP disabled, RSB filling, PBRSB-eI
> BRS Not affected
> Srbds: Not affected
> Tsx async abort: Not affected
>
>
> Could it be that this AVX implementation of ARIA requires AVX2
actually? dmesg + custom kernel .config + aria-aesni-avx-x86_64.ko for
my FX-8370 attached.
>
> Regards,
> Erhard

Thank you so much,
Taehee Yoo