Skip to content

ASAN: stack-use-after-scope in grp.getgr{nam,gid} and pwd.getpw{nam,uid} #79342

Closed

Description

@izbyshev
mannequin
BPO 35161
Nosy @vstinner, @berkerpeksag, @serhiy-storchaka, @william-gr, @izbyshev
PRs
  • bpo-35161: Fix stack-use-after-scope in grp.getgr{nam,gid} and pwd.getpw{nam,uid} #10319
  • 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-11-04.15:44:54.656>
    created_at = <Date 2018-11-04.14:26:54.286>
    labels = ['extension-modules', 'type-bug', '3.8']
    title = 'ASAN: stack-use-after-scope in grp.getgr{nam,gid} and pwd.getpw{nam,uid}'
    updated_at = <Date 2018-11-04.15:44:54.655>
    user = 'https://github.com/izbyshev'

    bugs.python.org fields:

    activity = <Date 2018-11-04.15:44:54.655>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-11-04.15:44:54.656>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2018-11-04.14:26:54.286>
    creator = 'izbyshev'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 35161
    keywords = ['patch']
    message_count = 3.0
    messages = ['329230', '329233', '329234']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'berker.peksag', 'serhiy.storchaka', 'wg', 'izbyshev']
    pr_nums = ['10319']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue35161'
    versions = ['Python 3.8']

    Activity

    1. izbyshev commented on Nov 4, 2018

      izbyshevmannequin
      MannequinAuthor

      ==24122==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fffb1c62550 at pc 0x0000006ec66c bp 0x7fffb1c62450 sp 0x7fffb1c62448
      READ of size 8 at 0x7fffb1c62550 thread T0
      #0 0x6ec66b in mkpwent /scratch2/izbyshev/cpython/Modules/pwdmodule.c:79
      #1 0x6ecdc9 in pwd_getpwnam_impl /scratch2/izbyshev/cpython/Modules/pwdmodule.c:260
      #2 0x6ecfee in pwd_getpwnam /scratch2/izbyshev/cpython/Modules/clinic/pwdmodule.c.h:39
      #3 0x454146 in _PyMethodDef_RawFastCallKeywords /scratch2/izbyshev/cpython/Objects/call.c:644
      [======= snip =======]
      Address 0x7fffb1c62550 is located in stack of thread T0 at offset 160 in frame
      #0 0x6eca60 in pwd_getpwnam_impl /scratch2/izbyshev/cpython/Modules/pwdmodule.c:203

      This frame has 3 object(s):
      [32, 40) 'name_chars'
      [96, 104) 'p'
      [160, 208) 'pwd' <== Memory access at offset 160 is inside this variable

      Variables declared in the block scope created with Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS are referred to via a pointer outside of that scope (i.e., after their lifetime ends). The bug was introduced in 23e65b2 .

    2. added
      3.8 (EOL)
      extension-modules
      type-bug
      on Nov 4, 2018
    3. serhiy-storchaka commented on Nov 4, 2018

      @serhiy-storchaka
      Member

      Good catch!

    4. serhiy-storchaka commented on Nov 4, 2018

      @serhiy-storchaka
      Member

      New changeset e359bc2 by Serhiy Storchaka (Alexey Izbyshev) in branch 'master':
      bpo-35161: Fix stack-use-after-scope in grp.getgr{nam,gid} and pwd.getpw{nam,uid}. (GH-10319)
      e359bc2

    5. transferred this issue fromon Apr 10, 2022
    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

      3.8 (EOL)extension-modulestype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions