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

test_crypt segfaults when using libxcrypt instead of libcrypt #76816

Closed
stratakis mannequin opened this issue Jan 23, 2018 · 10 comments
Closed

test_crypt segfaults when using libxcrypt instead of libcrypt #76816

stratakis mannequin opened this issue Jan 23, 2018 · 10 comments
Labels
3.7 (EOL) end of life extension-modules C modules in the Modules dir

Comments

@stratakis
Copy link
Mannequin

stratakis mannequin commented Jan 23, 2018

BPO 32635
Nosy @vstinner, @tiran, @benjaminp, @stratakis, @geofft
PRs
  • bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. #5284
  • [2.7] bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) #5295
  • [3.6] bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) #5296
  • Files
  • 00290-cryptmodule-Include-crypt.h-for-declaration-of-crypt.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2018-01-24.13:30:26.894>
    created_at = <Date 2018-01-23.10:22:06.979>
    labels = ['extension-modules', '3.7']
    title = 'test_crypt segfaults when using libxcrypt instead of libcrypt'
    updated_at = <Date 2021-07-27.21:33:23.914>
    user = 'https://github.com/stratakis'

    bugs.python.org fields:

    activity = <Date 2021-07-27.21:33:23.914>
    actor = 'geofft'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-01-24.13:30:26.894>
    closer = 'cstratak'
    components = ['Extension Modules']
    creation = <Date 2018-01-23.10:22:06.979>
    creator = 'cstratak'
    dependencies = []
    files = ['47402']
    hgrepos = []
    issue_num = 32635
    keywords = ['patch']
    message_count = 10.0
    messages = ['310490', '310503', '310563', '310573', '310575', '310579', '310581', '397959', '398254', '398322']
    nosy_count = 6.0
    nosy_names = ['vstinner', 'christian.heimes', 'benjamin.peterson', 'Arfrever', 'cstratak', 'geofft']
    pr_nums = ['5284', '5295', '5296']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue32635'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7']

    @stratakis
    Copy link
    Mannequin Author

    stratakis mannequin commented Jan 23, 2018

    Currently in Fedora glibc stopped providing libcrypt[0] a change which is slowly being upstreamed as well[1] in favor of the libxcrypt project[2].

    This causes a segfault when importing the crypt module as python assumes that crypt.h is always available.

    Providing a working patch from the libxcrypt maintainer. I'll convert the patch into a PR.

    [0] https://fedoraproject.org/wiki/Changes/Replace_glibc_libcrypt_with_libxcrypt
    [1] https://sourceware.org/ml/libc-alpha/2017-08/msg01257.html
    [2] https://github.com/besser82/libxcrypt

    @stratakis stratakis mannequin added 3.7 (EOL) end of life 3.8 only security fixes extension-modules C modules in the Modules dir labels Jan 23, 2018
    @vstinner
    Copy link
    Member

    New changeset e768c86 by Victor Stinner (stratakis) in branch 'master':
    bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (bpo-5284)
    e768c86

    @benjaminp
    Copy link
    Contributor

    Incidentally, why did this manifest as a segfault rather than a compilation error?

    @vstinner vstinner removed the 3.8 only security fixes label Jan 24, 2018
    @vstinner
    Copy link
    Member

    Charalampos, Christian: are you ok to backport the fix to Python 2.7 and 3.6? (PR 5295 and PR 5296)

    @tiran
    Copy link
    Member

    tiran commented Jan 24, 2018

    yes, go ahead

    @vstinner
    Copy link
    Member

    New changeset 6ccdad7 by Victor Stinner (Miss Islington (bot)) in branch '2.7':
    bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) (bpo-5295)
    6ccdad7

    @vstinner
    Copy link
    Member

    New changeset 8e230e1 by Victor Stinner (Miss Islington (bot)) in branch '3.6':
    bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) (bpo-5296)
    8e230e1

    @stratakis stratakis mannequin closed this as completed Jan 24, 2018
    @geofft
    Copy link
    Mannequin

    geofft mannequin commented Jul 21, 2021

    Sorry to bump an old thread, but - does <crypt.h> need to be in the public Python.h header? Or would it be enough to be in _cryptmodule.c, which is the code that uses crypt_r()?

    I can provide a quick patch to change that if that seems sound.

    @Arfrever
    Copy link
    Mannequin

    Arfrever mannequin commented Jul 26, 2021

    Geoffrey Thomas:
    I agree that including crypt.h only where required is better.
    Can you file new bug with patch?

    Benjamin Peterson:
    I suspect that with crypt.h not included in _cryptmodule.c, crypt() was treated by compiler as implicitly declared function (returning 'int'), however real crypt() function returns 'char*'.

    @geofft
    Copy link
    Mannequin

    geofft mannequin commented Jul 27, 2021

    Opened bpo-44751 and #27394 .

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life extension-modules C modules in the Modules dir
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants