Bug 1512845

Summary: libargon2 generates illegal instruction
Product: [Fedora] Fedora Reporter: Milan Broz <mbroz>
Component: argon2Assignee: Milan Broz <mbroz>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: fedora, okozina
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: argon2-20161029-2 argon2-20161029-2.fc27 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-11-25 20:38:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Milan Broz 2017-11-14 09:37:58 UTC
Description of problem:
The new cryptsetup2 will use Argon2 as a KDF and because there is already libargon2 in rawhide, I tried to compile it against this system library (instead of our bundled code).

Unfortunately it seems that it uses libargon2 optimized (native) version that does not run on some systems - it crashes with illegal instruction.
You should probably compile it with reference implementation only (Debian does it as well).

Version-Release number of selected component (if applicable):
libargon2-20161029-1.fc28.x86_64

Steps to Reproduce:

Please download and run test code from
https://github.com/mbroz/libargon2_test (it only calculates two test vectors from RFC draft).

On my VM (VMware desktop) it crashes this way:

Program received signal SIGILL, Illegal instruction.
blake2b_compress (S=S@entry=0x7fffffffdfc0, block=block@entry=0x7fffffffe020 "\004") at src/blake2/blake2b.c:213
213             ROUND(r);
(gdb) bt
#0  blake2b_compress (S=S@entry=0x7fffffffdfc0, block=block@entry=0x7fffffffe020 "\004") at src/blake2/blake2b.c:213
#1  0x00007ffff7bd2fee in blake2b_final (S=S@entry=0x7fffffffdfc0, out=out@entry=0x7fffffffe0f0, outlen=outlen@entry=64) at src/blake2/blake2b.c:281
#2  0x00007ffff7bd2445 in initial_hash (blockhash=blockhash@entry=0x7fffffffe0f0 "", context=context@entry=0x7fffffffe1e0, type=Argon2_i) at src/core.c:566
#3  0x00007ffff7bd2211 in initial_hash (type=<optimized out>, context=0x7fffffffe1e0, blockhash=0x7fffffffe0f0 "") at src/core.c:580
#4  initialize (instance=instance@entry=0x7fffffffe180, context=context@entry=0x7fffffffe1e0) at src/core.c:588
#5  0x00007ffff7bd1032 in argon2_ctx (context=0x7fffffffe1e0, type=<optimized out>) at src/argon2.c:78
#6  0x0000000000400ae3 in argon2_test_vectors () at argon2_generic.c:181
#7  0x0000000000400baf in main (argc=1, argv=0x7fffffffe3c8) at argon2_generic.c:198

Expected results:
The libargon2 must be supportable on all hw configurations.
(If we later link cryptsetup to it, it will also appear in critical path...)

Comment 1 Milan Broz 2017-11-14 10:54:14 UTC
spec build on x86_64 with "make -j1 OPTTARGET=i686" works, so it is really native optimization problem.

The spec should not decide on options according to builder CPU, this is misfeature of original Argon2 Makefile.

Comment 2 Milan Broz 2017-11-16 12:54:48 UTC
I rebuilt package argon2-20161029-2 with build flags according to build system.

Comment 3 Fedora Update System 2017-11-16 13:26:38 UTC
argon2-20161029-2.fc27 has been submitted as an update to Fedora 27. https://bodhi.fedoraproject.org/updates/FEDORA-2017-9ed9636acb

Comment 4 Fedora Update System 2017-11-17 18:55:06 UTC
argon2-20161029-2.fc27 has been pushed to the Fedora 27 testing repository. If problems still persist, please make note of it in this bug report.
See https://fedoraproject.org/wiki/QA:Updates_Testing for
instructions on how to install test updates.
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2017-9ed9636acb

Comment 5 Fedora Update System 2017-11-25 20:38:12 UTC
argon2-20161029-2.fc27 has been pushed to the Fedora 27 stable repository. If problems still persist, please make note of it in this bug report.