Skip to content

SIGILL in _armv7_tick on ARM when using openssl 1.1.1k #17465

Closed

Description

@mahendra-msp

Hi,

We are using OpenSSL 1.1.1k. Intermittently we see SIGILL crash in _armv7_tick on ARM platform in the RAND_DRBG_bytes path as below.
#4
#5 _armv7_tick () at crypto/armv4cpuid.S:136
#6 0xf57a00e8 in get_timer_bits () at ../openssl-1.1.1k/crypto/rand/rand_unix.c:833
#7 rand_pool_add_additional_data (pool=pool@entry=0xf1c5cd80) at ../openssl-1.1.1k/crypto/rand/rand_unix.c:789
#8 0xf579f46e in rand_drbg_get_additional_data (pool=0xf1c5cd80, pout=pout@entry=0xc8afe1e0) at ../openssl-1.1.1k/crypto/rand/rand_lib.c:289
#9 0xf579ea8e in RAND_DRBG_bytes (drbg=0xf1c6ef50, out=0xc8afe260 "", outlen=4) at ../openssl-1.1.1k/crypto/rand/drbg_lib.c:671

Found similar issues here (#14838, #17009).
Could you please help on how we can resolve this issue ?

Thanks
Mahendra

Activity

  1. bernd-edlinger commented on Jan 11, 2022

    @bernd-edlinger
    Member

    It is interesting that this did not happen when the feature is first probed on startup.
    You could set an environment to prevent this:
    export OPENSSL_armcap=0
    the bits in the armcap are defined like this:

    # define ARMV7_NEON      (1<<0)
    # define ARMV7_TICK      (1<<1)
    # define ARMV8_AES       (1<<2)
    # define ARMV8_SHA1      (1<<3)
    # define ARMV8_SHA256    (1<<4)
    # define ARMV8_PMULL     (1<<5)
    # define ARMV8_SHA512    (1<<6)
    

    so 0 should be safe, but maybe result in less performance.

  2. mahendra-msp commented on Jan 11, 2022

    @mahendra-msp
    Author

    @bernd-edlinger Thank you for the feedback.
    I see that here catboost/catboost@d7c6f1d, setting ARMV7_TICK is avoided. Is this an alternate way to explore? Is there any way to avoid impact on performance?

    Thanks
    Mahendra

  3. bernd-edlinger commented on Jan 11, 2022

    @bernd-edlinger
    Member

    when you encountered that problem, are you sure, that the OPENSSL_armcap was not set ?

  4. dlegaultbbry commented on Jan 11, 2022

    @dlegaultbbry

    This was reported previously if you have a system which uses Big.little where one set of CPUs can support some instructions and others not. See #14838

  5. bernd-edlinger commented on Jan 11, 2022

    @bernd-edlinger
    Member

    @mahendra-msp do you have such a non-symmetric-multi-processor-system, where some cores do support different instruction sets?

  6. paulidale commented on Jan 11, 2022

    @paulidale
    Contributor

    Currently we only access the timer for two purposes:

    1. additional data for the RNG
    2. seeding for the stochastic property cache flush

    Neither of these needs to be fast, so we could add a dynamic check in the two armcap files or wrapper the call in armcap.c with an illegal instruction catcher.

  7. bernd-edlinger commented on Jan 12, 2022

    @bernd-edlinger
    Member

    add a dynamic check in the two armcap files or wrapper the call in armcap.c with an illegal instruction catcher.

    Sorry, but I don't think that is a good idea, since changing the signal handlers affects the whole process, and is
    therefore only acceptable because we do it only once when all the static constructors run (for ARM at least).

  8. bernd-edlinger commented on Jan 12, 2022

    @bernd-edlinger
    Member

    Is there any way to avoid impact on performance?

    You could of course also use my feature branch at #11900
    and set OPENSSL_armcap=0x3d which makes it probe all features except ARMV7_TICK.

  9. paulidale commented on Jan 12, 2022

    @paulidale
    Contributor

    Setting OPENSSL_armcap to the features that are supported on your device should avoid this problem without impacting performance. The timer isn't used for anything critical.

  10. mahendra-msp commented on Jan 12, 2022

    @mahendra-msp
    Author

    Thank you all for the inputs.

    Confirmed that OPENSSL_armcap_P value is not read from environment variable. It is set the end of OPENSSL_cpuid_setup routine to the value 611 (0x263). This value does not get modified during the course of firmware execution.

    @paulidale do you mean, we can reset ARMV7_TICK bit in OPENSSL_armcap_P and keep the rest of the bits unmodified to address this issue?

  11. bernd-edlinger commented on Jan 12, 2022

    @bernd-edlinger
    Member

    It is set the end of OPENSSL_cpuid_setup routine to the value 611 (0x263)

    I don't understand what the bit 0x200 bit means.
    Do you use 1.1.1m or some other version?

  12. mahendra-msp commented on Jan 12, 2022

    @mahendra-msp
    Author

    @bernd-edlinger I am re-checking OPENSSL_armcap_P value. I will confirm here again. We are using openssl 1.1.1k

  13. paulidale commented on Jan 12, 2022

    @paulidale
    Contributor

    @paulidale do you mean, we can reset ARMV7_TICK bit in OPENSSL_armcap_P and keep the rest of the bits unmodified to address this issue?

    You should be able to set the OPENSSL_armcap environment variable to work around this. If this environment variable is defined, it's value is used instead of the probing. You need to match it to your system sans the ARMV7_TICK bit.

  14. mahendra-msp commented on Jan 13, 2022

    @mahendra-msp
    Author

    @bernd-edlinger I could re-check the OPENSSL_armcap_P and is set to 63 (0x3F). So all bits are set in OPENSSL_cpuid_setup()

    @bernd-edlinger @paulidale Can you please give more info on the reason for this SIGILL error ? It would help us to know the issue better.

  15. paulidale commented on Jan 13, 2022

    @paulidale
    Contributor

    You could answer the question above for starters.

    Your processor claims to have the ARMV7_TICK register but then fails to access it.

  16. 7 remaining items

  17. jarkkokoivikko-code-q commented on Jan 24, 2022

    @jarkkokoivikko-code-q

    I think this is the same problem with my application. It happens irregularly. I would be happy to try a fix if one is available.

    : Fatal signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 0xb75ec9a8 in tid 25156 (qtMainLoopThrea), pid 25405 (x)
    : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    : Build fingerprint: 'samsung/gta4xlwifieea/gta4xlwifi:11/RP1A.200720.012/x:user/release-keys'
    : Revision: '7'
    : ABI: 'arm'
    : Processor: '4'
    : Timestamp: 2022-01-19 10:21:11+0200
    : pid: 25405, tid: 25156, name: qtMainLoopThrea  >>> x <<<
    : uid: 10327
    : signal 4 (SIGILL), code 1 (ILL_ILLOPC), fault addr 0xb75ec9a8 (*pc=0xec510f1e)
    :     r0  0000003f  r1  b98e813c  r2  00000030  r3  b78a3050
    :     r4  b77d6418  r5  00000000  r6  c7112eb8  r7  00000000
    :     r8  b7be5a00  r9  b3eb4cc0  r10 b98e82e0  r11 b98e8118
    :     ip  b77b4fc4  sp  b98e80f8  lr  b76fdc7c  pc  b75ec9a8
    : backtrace:
    :       #00 pc 000579a8  /data/app/~~C8YCYg4LdUM3oG9I937aiw==/x-A6levaWv78H5Qvs3p44u-A==/lib/arm/libcrypto_1_1.so
    
  18. davidben commented on Jan 24, 2022

    @davidben
    Contributor

    See #14838 which already includes a diagnosis of this problem for big.little systems. I suspect other folks running into this are running into the same thing.

    The probing stuff OpenSSL does isn't a safe way to detect ARM features and should be removed in favor of supported APIs. Unfortunately, I couldn't find a relevant hwcap value for this instruction (but I may have missed it), so I guess the question is what is OpenSSL doing with it. Perhaps you all can find another way to do it... I see some entropy bits, but there are better sources of entropy, and something in code new to OpenSSL 3.0 to do something odd deep in the property system.

  19. marler8997 commented on Jan 24, 2022

    @marler8997

    Our system isn't big little. We use a cortex A72 which has 4 identical cores. Furthermore, if this was the issue my test app running 5 threads calling the instruction as fast as possible should have reproduced it almost instantly. We do alot of "duration testing" and have only seen this specific problem happen about 2 or 3 times after the device has been running for days going in and out of sleep.

    Also according to this comment someone else has also seen this on homogeneous systems: #14838 (comment)

  20. bernd-edlinger commented on Jan 25, 2022

    @bernd-edlinger
    Member

    That sounds almost like an A72 erratum.
    Have you informed ARM about this?

  21. marler8997 commented on Jan 25, 2022

    @marler8997

    Will do if I can find a way to reliably reproduce it.

  22. added
    branch: 1.1.1
    help wanted
    triaged: bug
    on Feb 10, 2022
  23. Superpengun commented on Mar 15, 2022

    @Superpengun

    From the previous records, the cause of this problem still needs to be investigated............

  24. Nathaniel100 commented on Jul 22, 2022

    @Nathaniel100

    I encountered the same issue,Openssl 1.1.1l,OPPO R15 PACM00,Android 10

  25. added 2 commits that reference this issue on May 4, 2023
    b184fcf
    fc9dfb2
  26. t8m commented on Feb 22, 2024

    @t8m
    Member

    The version 1.1.1 is not supported anymore. Closing. If this is still an issue with currently supported releases, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    branch: 1.1.1help wantedtriaged: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions