Skip to content

UBSan: misaligned memory loads in Objects/dictobject.c #127563

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

Closed
encukou opened this issue Dec 3, 2024 · 5 comments
Closed

UBSan: misaligned memory loads in Objects/dictobject.c #127563

encukou opened this issue Dec 3, 2024 · 5 comments
Assignees
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@encukou
Copy link
Member

encukou commented Dec 3, 2024

Bug report

clang 18+'s undefined behavior sanitizer reports two cases of misaligned load:

Objects/unicodeobject.c:5088:24: runtime error: load of misaligned address 0x0000008b74be for type 'const size_t' (aka 'const unsigned long'), which requires 8 byte alignment
0x0000008b74be: note: pointer points here
 20 25 73 2e 5f 5f  72 65 70 72 5f 5f 00 72  61 77 20 73 74 72 65 61  6d 20 68 61 73 20 62 65  65 6e
             ^ 

and

Objects/dictobject.c:2015:40: runtime error: load of misaligned address 0x5f7d064233d1 for type 'PyDictUnicodeEntry *', which requires 8 byte alignment
0x5f7d064233d1: note: pointer points here
 00 00 00  ff ff ff ff ff ff ff ff  00 00 00 00 00 00 00 00  74 da 0f 06 7d 5f 00 00  df 01 00 00 14
              ^ 

Linked PRs

@encukou encukou added type-bug An unexpected behavior, bug, or error interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Dec 3, 2024
@picnixz picnixz changed the title UBSan: misaligned memory loads UBSan: misaligned memory loads in Objects/unicodeobject.c and Objects/dictobject.c Dec 3, 2024
@picnixz picnixz changed the title UBSan: misaligned memory loads in Objects/unicodeobject.c and Objects/dictobject.c UBSan: misaligned memory loads in Objects/{dictobject,unicodeobject}.c Dec 3, 2024
@picnixz
Copy link
Member

picnixz commented Dec 3, 2024

@encukou Are you planning to fix them now?

@encukou
Copy link
Member Author

encukou commented Dec 3, 2024

Looking at my queue, I'll probably get to them next week. Feel free to take them now if you want.

@picnixz picnixz self-assigned this Dec 3, 2024
@picnixz picnixz added 3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes labels Dec 3, 2024
@picnixz
Copy link
Member

picnixz commented Dec 3, 2024

I'll fix the issue in unicodeobject.c as part of #126024 instead and the dictobject.c as part of this issue.

@picnixz picnixz changed the title UBSan: misaligned memory loads in Objects/{dictobject,unicodeobject}.c UBSan: misaligned memory loads in Objects/dictobject.c Dec 3, 2024
@picnixz
Copy link
Member

picnixz commented Dec 3, 2024

For the unicodeobject UBSan failure: #127566.

encukou pushed a commit that referenced this issue Dec 10, 2024
This fixes a UBSan failure (unaligned zero-size memcpy) in `dictobject.c`.
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 10, 2024
…-127568)

This fixes a UBSan failure (unaligned zero-size memcpy) in `dictobject.c`.
(cherry picked from commit 9af96f4)

Co-authored-by: Bénédikt Tran <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 10, 2024
…-127568)

This fixes a UBSan failure (unaligned zero-size memcpy) in `dictobject.c`.
(cherry picked from commit 9af96f4)

Co-authored-by: Bénédikt Tran <[email protected]>
encukou pushed a commit that referenced this issue Dec 11, 2024
…) (GH-127798)

This fixes a UBSan failure (unaligned zero-size memcpy) in `dictobject.c`.
(cherry picked from commit 9af96f4)

Co-authored-by: Bénédikt Tran <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Dec 11, 2024
…-127568)

This fixes a UBSan failure (unaligned zero-size memcpy) in `dictobject.c`.
(cherry picked from commit 9af96f4)

Co-authored-by: Bénédikt Tran <[email protected]>
encukou pushed a commit that referenced this issue Dec 12, 2024
…) (GH-127813)

This fixes a UBSan failure (unaligned zero-size memcpy) in `dictobject.c`.
(cherry picked from commit 9af96f4)

Co-authored-by: Bénédikt Tran <[email protected]>
@picnixz
Copy link
Member

picnixz commented Dec 13, 2024

Closing since completed and backported.

@picnixz picnixz closed this as completed Dec 13, 2024
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this issue Jan 8, 2025
…-127568)

This fixes a UBSan failure (unaligned zero-size memcpy) in `dictobject.c`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes 3.13 bugs and security fixes 3.14 bugs and security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants