PyMemoryView_FromBuffer discards owner reference from Py_buffer
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia da Objects/memoryobject.c, nell’implementazione collegata di PyMemoryView_FromBuffer, e leggi la documentazione della C-API PyMemoryView_FromBuffer. Esamina la pull request #5937 di PyO3 per comprendere il requisito relativo alla durata dell’owner, quindi confronta le implicazioni di compatibilità del mantenimento dell’owner con quelle dell’introduzione di una nuova API. Il lavoro è completo quando la semantica dell’ownership è stata decisa, documentata e coperta da test CPython appropriati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, python
- Ambito
- api
- Tipo di issue
- Bug
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100