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

possible null pointer dereference in pystate.c #78589

Closed
pablogsal opened this issue Aug 14, 2018 · 7 comments
Closed

possible null pointer dereference in pystate.c #78589

pablogsal opened this issue Aug 14, 2018 · 7 comments
Labels
3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@pablogsal
Copy link
Member

BPO 34408
Nosy @vstinner, @markshannon, @ericsnowcurrently, @pablogsal
PRs
  • bpo-34408: Prevent a null pointer derefence and resource leakage in pystate.c #8767
  • [3.7] bpo-34408: Prevent a null pointer dereference and resource leakage in PyInterpreterState_New() (GH-8767) #13237
  • 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 2019-05-10.20:16:48.630>
    created_at = <Date 2018-08-14.20:09:38.710>
    labels = ['interpreter-core', '3.8', 'type-crash']
    title = 'possible null pointer dereference in pystate.c'
    updated_at = <Date 2019-05-10.21:31:16.997>
    user = 'https://github.com/pablogsal'

    bugs.python.org fields:

    activity = <Date 2019-05-10.21:31:16.997>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-05-10.20:16:48.630>
    closer = 'pablogsal'
    components = ['Interpreter Core']
    creation = <Date 2018-08-14.20:09:38.710>
    creator = 'pablogsal'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 34408
    keywords = ['patch']
    message_count = 7.0
    messages = ['323538', '324444', '341780', '342040', '342127', '342128', '342137']
    nosy_count = 4.0
    nosy_names = ['vstinner', 'Mark.Shannon', 'eric.snow', 'pablogsal']
    pr_nums = ['8767', '13237']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue34408'
    versions = ['Python 3.8']

    @pablogsal
    Copy link
    Member Author

    The problem occurs here:

    https://github.com/python/cpython/blob/master/Python/pystate.c#L185

    If _PyRuntime.interpreters.next_id < 0 then interp is set to NULL and it will be dereferenced later:

    interp

    @pablogsal pablogsal added 3.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump labels Aug 14, 2018
    @pablogsal
    Copy link
    Member Author

    New changeset 95d630e by Pablo Galindo in branch 'master':
    bpo-34408: Prevent a null pointer dereference and resource leakage in PyInterpreterState_New() (GH-8767)
    95d630e

    @markshannon
    Copy link
    Member

    Any reason not to close this issue?

    @vstinner
    Copy link
    Member

    Any reason not to close this issue?

    Pablo: Do you want to backport your fix to Python 3.7? Python 3.7 has the same bug, no? (I didn't check.)

    @pablogsal
    Copy link
    Member Author

    New changeset 34ed40f by Pablo Galindo in branch '3.7':
    [3.7] bpo-34408: Prevent a null pointer dereference and resource leakage in PyInterpreterState_New() (GH-8767) (GH-13237)
    34ed40f

    @pablogsal
    Copy link
    Member Author

    I have backported the fix to 3.7 :)

    @vstinner
    Copy link
    Member

    I have backported the fix to 3.7 :)

    Ok, thanks.

    @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.8 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants