pyca / cryptography

cryptography is a package designed to expose cryptographic primitives and recipes to Python developers.
https://cryptography.io
Other
6.54k stars 1.5k forks source link

_rust.abi3.so: failed to map segment from shared object #7318

Closed SpellignError closed 2 years ago

SpellignError commented 2 years ago

I've installed cyptography with pip install -U cryptography and attempted a simple script:

import cryptography.hazmat.bindings._rust
print(cryptography.hazmat.bindings._rust)

This returns the error:

$ python 4.py 
Traceback (most recent call last):
  File "/home/redacted/timpi-signups/4.py", line 1, in <module>
    import cryptography.hazmat.bindings._rust
ImportError: /home/redacted/.local/lib/python3.10/site-packages/cryptography/hazmat/bindings/_rust.abi3.so: failed to map segment from shared object

The file permisions do allow execution: $ ls -l /home/redacted/.local/lib/python3.10/site-packages/cryptography/hazmat/bindings/_rust.abi3.so

-rwxr-xr-x 1 redacted redacted 3495968 Jun  7 07:22 /home/redacted/.local/lib/python3.10/site-packages/cryptography/hazmat/bindings/_rust.abi3.so

and my filesystem is mounted with exec privs:

$ cat /etc/fstab | grep -i home
# /dev/mapper/home
UUID=ab6b21bd-3b3e-4354-84c6-a07fd772f8d6       /home           ext4            rw,noatime,discard,nodev,loud,sync,nosuid,noiversion,commit=60,user   0 2

Can anyone assist with where to begin looking into this issue?

Operating system: Arch Linux uname -a: Linux gg 5.17.12-hardened2-1-hardened #1 SMP PREEMPT Mon, 30 May 2022 18:35:40 +0000 x86_64 GNU/Linux pip list: http://0x0.st/oM2-.txt pip -V: pip 21.0 from /usr/lib/python3.10/site-packages/pip (python 3.10) python -V: Python 3.10.4

alex commented 2 years ago

Can you provide us some instructions to reproduce from a clean environment? I haven't seen this error before which strongly suggests it's something about your environment and not a bug in cryptography.

In terms of debugging this, my suggestion would be to run the script under strace and see what syscall is failing, and with what error.

SpellignError commented 2 years ago

instructions to reproduce from a clean environment? Install arch Linux (I used Linode) pacman -Syu python-pip Create new user, and login as user pip install -U cryptography 1.py:

import cryptography.hazmat.bindings._rust
print(cryptography.hazmat.bindings._rust)

python 1.py

<module 'cryptography.hazmat.bindings._rust' from '/usr/lib/python3.10/site-packages/cryptography/hazmat/bindings/_rust.abi3.so'>

pip list: https://0x0.st/oM2Z.txt

This time the _rust.abi3.so isn't found within /usr/lib/python3.10/site-packages/cryptography/hazmat/bindings/_rust.abi3.so or ~/.local/...

I believe this could be a packing error, rather than a bug. I will go to the repos if you don't have any other suggestion

my suggestion would be to run the script under strace and see what syscall is failing, and with what error. Thank you for the suggestion, I will attempt this

SpellignError commented 2 years ago

You were correct, it was an environment issue. My filesystem was mounted with noexec, despite being remounted after boot and systemctl daemon-reload. After rebooting, the issue is resolved. Thanks for your assistance

alex commented 2 years ago

Glad you got it resolved.

On Tue, Jun 7, 2022 at 10:15 AM SpellignError @.***> wrote:

You were correct, it was an environment issue. My filesystem was mounted with noexec, despite being remounted after boot and systemctl daemon-reload. After rebooting, the issue is resolved. Thanks for your assistance

— Reply to this email directly, view it on GitHub https://github.com/pyca/cryptography/issues/7318#issuecomment-1148735672, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAAGBAY2HDAPEV5IC25LCTVN5KPVANCNFSM5YC2EKIA . You are receiving this because you commented.Message ID: @.***>

-- All that is necessary for evil to succeed is for good people to do nothing.