Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERL-1229: Issue [ERL-533] seems to impact OTP 21 (10.3) #4115

Closed
OTP-Maintainer opened this issue Apr 16, 2020 · 6 comments
Closed

ERL-1229: Issue [ERL-533] seems to impact OTP 21 (10.3) #4115

OTP-Maintainer opened this issue Apr 16, 2020 · 6 comments
Labels
not a bug Issue is determined as not a bug by OTP priority:medium team:PS Assigned to OTP team PS

Comments

@OTP-Maintainer
Copy link

Original reporter: JIRAUSER14704
Affected version: Not Specified
Component: crypto
Migrated from: https://bugs.erlang.org/browse/ERL-1229


Hello!

We are experiencing issues on one of our Production machines with erlang. We are hoping to work together to figure out what could be causing this issue. 

We see this issue when launching our application.

Error from event viewer:

Faulting application name: erl.exe, version: 0.0.0.0, time stamp: 0x5c86ce75
Faulting module name: crypto.dll, version: 0.0.0.0, time stamp: 0x5c86d146
Exception code: 0xc0000005
Fault offset: 0x0000000000017623
Faulting process id: 0x4218
Faulting application start time: 0x01d61438d4116766
Faulting application path: C:\Program Files\erl10.3\erts-10.3\bin\erl.exe
Faulting module path: c:\Program Files\erl10.3\lib\crypto-4.4.1\priv\lib\crypto.dll
Report Id: e934c3d3-44b9-4c80-9080-da326a8005d3
Faulting package full name: 
Faulting package-relative application ID:

 

Any assistnce to resolve this issue is appreciated.

Attached are the hardware specs of the device.
@OTP-Maintainer
Copy link
Author

john said:

Thanks for your report!

After a bit of digging I think this is a bug in {{OpenSSL}}, affecting all Windows users with processors that support Intel SHA Extensions.

As a workaround, can you try disabling SHA extensions by setting the environment variable {{OPENSSL_ia32cap}} to {{~0:~0x20000000}} ?
{code:java}
##  openssl/crypto/sha/asm/sha1-x86_64.pl, at `sha1_block_data_order_shaext`

# Spill xmm6-9 to the stack as we'll clobber them. RAX has already been set to RSP earlier on.
$code.=<<___ if ($win64);
	lea	`-8-4*16`(%rsp),%rsp
	movaps	%xmm6,-8-4*16(%rax)
	movaps	%xmm7,-8-3*16(%rax)
	movaps	%xmm8,-8-2*16(%rax)
	movaps	%xmm9,-8-1*16(%rax)
.Lprologue_shaext:

# ... snip ....

.align	16
.Loop_shaext:
	dec		$num
	lea		0x40($inp),%rax		# next input block, note that this clobbers RAX
                                                # which is not saved anywhere.
	paddd		@MSG[0],$E
	cmovne		%rax,$inp

# ... snip ...

# Restore xmm6-9, using the now-clobbered RAX, either crashing outright or restoring the wrong
# values.
$code.=<<___ if ($win64);
	movaps	-8-4*16(%rax),%xmm6
	movaps	-8-3*16(%rax),%xmm7
	movaps	-8-2*16(%rax),%xmm8
	movaps	-8-1*16(%rax),%xmm9
	mov	%rax,%rsp
.Lepilogue_shaext:
{code}

@OTP-Maintainer
Copy link
Author

john said:

This was fixed in {{OpenSSL 1.1.0a}}, so it'll work in {{OTP 23}} which uses {{OpenSSL 1.1.1}}. Until then, you can either try the above workaround (please let us know if it works) or compile it yourself with a newer version of {{OpenSSL}}.

[https://github.com/openssl/openssl/commit/7123aa81e9fb19afb11fdf3850662c5f7ff1f19c]

@OTP-Maintainer
Copy link
Author

ingela said:

Not a bug in OTP but in OpenSSL

@OTP-Maintainer
Copy link
Author

JIRAUSER15903 said:

Just an FYI for everyone looking at a possible fix on OTP 23 the issue still happens with that version on a Surface Pro 7 hardware (intel i7 10th gen). The only workaround was use Erlang 32bit

@OTP-Maintainer OTP-Maintainer added not a bug Issue is determined as not a bug by OTP team:PS Assigned to OTP team PS priority:medium labels Feb 10, 2021
@mageshkumarn
Copy link

mageshkumarn commented Sep 28, 2023

john said:

Thanks for your report!

After a bit of digging I think this is a bug in {{OpenSSL}}, affecting all Windows users with processors that support Intel SHA Extensions.

As a workaround, can you try disabling SHA extensions by setting the environment variable {{OPENSSL_ia32cap}} to {{~0:~0x20000000}} ?
{code:java}
##  openssl/crypto/sha/asm/sha1-x86_64.pl, at `sha1_block_data_order_shaext`

# Spill xmm6-9 to the stack as we'll clobber them. RAX has already been set to RSP earlier on.
$code.=<<___ if ($win64);
	lea	`-8-4*16`(%rsp),%rsp
	movaps	%xmm6,-8-4*16(%rax)
	movaps	%xmm7,-8-3*16(%rax)
	movaps	%xmm8,-8-2*16(%rax)
	movaps	%xmm9,-8-1*16(%rax)
.Lprologue_shaext:

# ... snip ....

.align	16
.Loop_shaext:
	dec		$num
	lea		0x40($inp),%rax		# next input block, note that this clobbers RAX
                                                # which is not saved anywhere.
	paddd		@MSG[0],$E
	cmovne		%rax,$inp

# ... snip ...

# Restore xmm6-9, using the now-clobbered RAX, either crashing outright or restoring the wrong
# values.
$code.=<<___ if ($win64);
	movaps	-8-4*16(%rax),%xmm6
	movaps	-8-3*16(%rax),%xmm7
	movaps	-8-2*16(%rax),%xmm8
	movaps	-8-1*16(%rax),%xmm9
	mov	%rax,%rsp
.Lepilogue_shaext:
{code}

@OTP-Maintainer I'm getting the same problem. So I hope this would fix my issue as well. But, not sure where I need to make this change. Can you pour some light here please?

@jhogberg
Copy link
Contributor

jhogberg commented Sep 29, 2023

Update to newer versions of OpenSSL and OTP. They should not have this problem :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not a bug Issue is determined as not a bug by OTP priority:medium team:PS Assigned to OTP team PS
Projects
None yet
Development

No branches or pull requests

3 participants