PyMemoryView_FromBuffer discards owner reference from Py_buffer
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 35.9k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
Bug description:
This means that if you use PyMemoryView_FromBuffer with a buffer that requires an owner to be kept alive, you get a UAF hazard here.
This is not mentioned in the documentation: https://docs.python.org/3/c-api/memoryview.html#c.PyMemoryView_FromBuffer
An extremely cursory didn't find any vulnerable callers within CPython itself, however this was discovered in the process of implementing https://github.com/PyO3/pyo3/pull/5937 where it definitely would have been an issue.
It seems like there's two possible choices here:
- Change this to keep
owneraround -- potentially breaks existing callers? - Document this, and introduce a new API with clearer semantics here.
CPython versions tested on:
CPython main branch
Operating systems tested on:
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Objects/memoryobject.c のリンクされた PyMemoryView_FromBuffer 実装から始め、PyMemoryView_FromBuffer C-API のドキュメントを読んでください。PyO3 の pull request #5937 を確認して owner のライフタイム要件を理解し、その後、owner を保持する場合と新しい API を導入する場合の互換性への影響を比較してください。ownership のセマンティクスが決定され、文書化され、適切な CPython テストでカバーされていれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, python
- 領域
- api
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 38/100