heap uaf in _lsprof via enable()
未關閉
還沒有人認領這個 Issue。
extension-modules
topic-profiling
type-bug
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
在 ASAN 下使用 Python 程式碼片段重現該報告,並檢查 Modules/_lsprof.c,從 ptrace_enter_call 和 _lsprof_Profiler__ccall_callback_impl 路徑開始。閱讀 flush_unmatched 和 _lsprof_Profiler_disable_impl,以追蹤配置與釋放的順序。當重現程式在啟用/停用 profiler 期間不再回報 heap-use-after-free 時,即表示完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c, python
- 領域
- performance, tooling
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100