Skip to content

armcap: skip probing _armv7_tick() - #18852

Closed
cgutman wants to merge 1 commit into
openssl:masterfrom
cgutman:skip_armv7tick
Closed

cgutman wants to merge 1 commit into
openssl:masterfrom
cgutman:skip_armv7tick

Conversation

@cgutman

@cgutman cgutman commented Jul 23, 2022 •

Copy link
Copy Markdown
Contributor

Using _armv7_tick() leads to crashes on a variety of AArch32 Android devices while providing little benefit. Nobody has succeeded in getting a reliable repro to debug it for years, so just disable it by default on these known problematic configurations unless the user opts in by setting OPENSSL_armcap.

If this approach is acceptable, this should also be backported to OpenSSL_1_1_1-stable to resolve the linked issues.

Fixes #14838
Fixes #17009
Fixes #17465

@openssl-machine openssl-machine added the hold: cla required The contributor needs to submit a license agreement. label Jul 23, 2022
@paulidale paulidale added branch: master Applies to master branch approval: review pending This pull request needs review by a committer branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL) branch: 3.0 Applies to openssl-3.0 branch (EOL) triaged: bug The issue/pr is/fixes a bug labels Jul 25, 2022
@hlandau

hlandau commented Jul 25, 2022

Copy link
Copy Markdown
Member

Thanks. This looks good, but you will need to sign a CLA:

https://www.openssl.org/policies/cla.html

@cgutman

cgutman commented Jul 26, 2022

Copy link
Copy Markdown
Contributor Author

I emailed the CLA in yesterday. Will the bot automatically remove the CLA hold label once that gets reviewed and processed?

@davidben

Copy link
Copy Markdown
Contributor

Really OpenSSL shouldn't be probing for support like this on any platform. It's very unreliable in big.LITTLE situations. See #14838 (comment)

Although it doesn't look like the feature OpenSSL wants here even has a getauxval value. So I'd also suggest revisiting uses of the feature in the first place.

@cgutman

cgutman commented Jul 26, 2022

Copy link
Copy Markdown
Contributor Author

Really OpenSSL shouldn't be probing for support like this on any platform. It's very unreliable in big.LITTLE situations. See #14838 (comment)

I don't think it's even exclusive to big.LITTLE platforms. I've seen a crash on a MediaTek T31-based device which appears to be a single cluster of 4 Cortex-A55 cores.

Although it doesn't look like the feature OpenSSL wants here even has a getauxval value. So I'd also suggest revisiting uses of the feature in the first place.

We could just remove the probe entirely and require users to set ARMV7_TICK in OPENSSL_armcap for that functionality to be enabled. Either approach is fine with me.

@kroeckx

kroeckx commented Jul 26, 2022 via email

Copy link
Copy Markdown
Member

Detection of this feature is unreliable so only use it if requested.
@cgutman cgutman changed the title armcap: skip probing _armv7_tick() on AArch32 Android armcap: skip probing _armv7_tick() Jul 26, 2022
@cgutman

cgutman commented Jul 26, 2022

Copy link
Copy Markdown
Contributor Author

I suggest we just never probe for it.

Sounds good to me. I removed the probe entirely in my latest push.

@davidben

Copy link
Copy Markdown
Contributor

Agreed that's the right change, but note that, since OPENSSL_armcap_P is not public API, this amounts to removing use of the ARMV7_TICK feature from OpenSSL. (Which I also think is correct.)

@cgutman

cgutman commented Jul 26, 2022

Copy link
Copy Markdown
Contributor Author

OPENSSL_armcap_P can't be accessed directly, but if set, the OPENSSL_armcap environment variable is used to initialize OPENSSL_armcap_P. That overrides OpenSSL's feature detection and allows use of the ARMV7_TICK feature.

@davidben

Copy link
Copy Markdown
Contributor

Ah fair. Unclear to me whether that code is worth carrying given that, but okay. :-)

@paulidale paulidale closed this Jul 27, 2022
@paulidale paulidale reopened this Jul 27, 2022
@t8m

t8m commented Jul 27, 2022

Copy link
Copy Markdown
Member

Unfortunately there is no way to set individual bits with OPENSSL_armcap not overriding also the other bits. That makes the ARMV7_TICK code fairly useless.

@cgutman cgutman closed this Jul 28, 2022
@cgutman cgutman reopened this Jul 28, 2022
@openssl-machine openssl-machine removed the hold: cla required The contributor needs to submit a license agreement. label Jul 28, 2022
@cgutman

cgutman commented Jul 28, 2022

Copy link
Copy Markdown
Contributor Author

Unfortunately there is no way to set individual bits with OPENSSL_armcap not overriding also the other bits. That makes the ARMV7_TICK code fairly useless.

Okay, is the preference then to just nuke _armv7_tick() entirely?

If so, should we keep that ARMV7_TICK bit reserved for backwards compatibility with older applications/scripts that may set OPENSSL_armcap manually?

@paulidale

Copy link
Copy Markdown
Contributor

Yes, nuke it. It's only uses as a very low quality entropy source. We should be able to live without it.

As a fallback, perhaps introduce a configuration option that enables/allows it. My rationale is that some embedded platforms are quite lacking in entropy and this clock might help.

@cgutman

cgutman commented Jul 28, 2022

Copy link
Copy Markdown
Contributor Author

Yes, nuke it. It's only uses as a very low quality entropy source. We should be able to live without it.

As a fallback, perhaps introduce a configuration option that enables/allows it. My rationale is that some embedded platforms are quite lacking in entropy and this clock might help.

Could that configuration option just be setting the OPENSSL_armcap environment variable? On an embedded device, one could reasonably know the capabilities ahead of time and enable the use of this feature (and others) if the CPU and kernel supported it. That use case would work with the PR as it is now.

@paulidale

Copy link
Copy Markdown
Contributor

I'd prefer a build time option but an environment variable might work. The former is less risky.

@openssl/otc ??

@github-actions github-actions Bot added the severity: fips change The pull request changes FIPS provider sources label Jul 28, 2022
@davidben

Copy link
Copy Markdown
Contributor

As a fallback, perhaps introduce a configuration option that enables/allows it. My rationale is that some embedded platforms are quite lacking in entropy and this clock might help.

Is even that necessary? PRNG-wise, looks like this goes into get_timer_bits which rightfully says it is not considered a trusted entropy source. If the embedded platform lacks sufficient entropy, this won't change things (CVE-2008-0166). If it does, this is unnecessary.

It also goes into ossl_method_cache_flush_some, which has no other entropy source. But given this feature cannot actually be enabled without crashes, perhaps that component should be redesigned to not use this in the first place.

@paulidale

Copy link
Copy Markdown
Contributor

It also goes into ossl_method_cache_flush_some, which has no other entropy source. But given this feature cannot actually be enabled without crashes, perhaps that component should be redesigned to not use this in the first place.

This path shouldn't need changing. It doesn't require a good RNG or entropy. A completely deterministic PRNG will achieve the desired result. I was attempting to mitigate a theoretical DoS attack where the same cache elements are flushed each time. I doubt it's possible to do anything useful but attackers have proven time and again to be rather resourceful.

@davidben

Copy link
Copy Markdown
Contributor

If you just remove ARMV7_TICK, your "deterministic" RNG will be return 0. Dunno if that's good enough for your purposes. :-)

@paulidale

Copy link
Copy Markdown
Contributor

It checks for the zero timer and seeds with a 1 in that case 😄

@davidben

Copy link
Copy Markdown
Contributor

Oh, I see. I missed that the value goes into an xorshift thing.

@openssl-machine

Copy link
Copy Markdown
Collaborator

This PR is in a state where it requires action by @openssl/committers but the last update was 30 days ago

@openssl-machine

Copy link
Copy Markdown
Collaborator

This PR is in a state where it requires action by @openssl/committers but the last update was 30 days ago

@paulidale

Copy link
Copy Markdown
Contributor

ping @openssl/otc for second review

@beldmit beldmit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

But the test failure looks suspicious

@beldmit beldmit added approval: done This pull request has the required number of approvals and removed approval: review pending This pull request needs review by a committer labels Sep 29, 2022
@t8m t8m closed this Sep 29, 2022
@t8m t8m reopened this Sep 29, 2022
@t8m t8m removed the branch: 1.1.1 Applies to OpenSSL_1_1_1-stable branch (EOL) label Sep 29, 2022
@github-actions github-actions Bot removed the severity: fips change The pull request changes FIPS provider sources label Sep 29, 2022
@openssl-machine openssl-machine added approval: ready to merge The 24 hour grace period has passed, ready to merge and removed approval: done This pull request has the required number of approvals labels Sep 30, 2022
@openssl-machine

Copy link
Copy Markdown
Collaborator

This pull request is ready to merge

@hlandau

hlandau commented Oct 4, 2022

Copy link
Copy Markdown
Member

Merged to master and 3.0. Thank you.

@hlandau hlandau closed this Oct 4, 2022
openssl-machine pushed a commit that referenced this pull request Oct 4, 2022
Detection of this feature is unreliable so only use it if requested.

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from #18852)
openssl-machine pushed a commit that referenced this pull request Oct 4, 2022
Detection of this feature is unreliable so only use it if requested.

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from #18852)

(cherry picked from commit f2ec24c)
beldmit pushed a commit to beldmit/openssl that referenced this pull request Dec 26, 2022
Detection of this feature is unreliable so only use it if requested.

Reviewed-by: Paul Dale <[email protected]>
Reviewed-by: Dmitry Belyavskiy <[email protected]>
Reviewed-by: Hugo Landau <[email protected]>
(Merged from openssl#18852)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approval: ready to merge The 24 hour grace period has passed, ready to merge branch: master Applies to master branch branch: 3.0 Applies to openssl-3.0 branch (EOL) triaged: bug The issue/pr is/fixes a bug

Projects

None yet

8 participants