heap uaf in _lsprof via enable()
Offen
Dieses Issue hat noch niemand übernommen.
extension-modules
topic-profiling
type-bug
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Bug description:
import _lsprof
prof = _lsprof.Profiler()
def _timer():
try:
prof.enable()
except Exception:
pass
return 0
prof.__init__(timer=_timer)
prof.enable()
def foo():
return 1
foo()
prof.disable()
ASAN output (truncated:
==ERROR: AddressSanitizer: heap-use-after-free ... READ of size 8
#0 ptrace_enter_call Modules/_lsprof.c:383
#1 _lsprof_Profiler__ccall_callback_impl Modules/_lsprof.c:733
freed by thread T0 here:
#1 flush_unmatched Modules/_lsprof.c:873
#2 _lsprof_Profiler_disable_impl Modules/_lsprof.c:930
previously allocated by thread T0 here:
#1 ptrace_enter_call Modules/_lsprof.c:388
SUMMARY: AddressSanitizer: heap-use-after-free Modules/_lsprof.c:383 in ptrace_enter_call
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-157648
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere den Bericht mit dem Python-Snippet unter ASAN und untersuche Modules/_lsprof.c, beginnend bei ptrace_enter_call und dem Pfad _lsprof_Profiler__ccall_callback_impl. Lies flush_unmatched und _lsprof_Profiler_disable_impl, um die Sequenz von Allokation und Freigabe nachzuverfolgen. Erledigt ist die Aufgabe, wenn der Reproduzierer während der Aktivierung/Deaktivierung des Profilers keinen heap-use-after-free mehr meldet.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c, python
- Bereich
- performance, tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100