Fix a soundness bug with PyClassInitializer#4454
Conversation
alex
left a comment
There was a problem hiding this comment.
This LGTM. We still have unsoundness because you can do PyClassInitializer::new(SubClass{}, PyClassInitializer::from(Py::new(py, Baseclass{}))) though :-(
Do you see a good way to deal with that? Maybe PyClassInitializer::new just shouldn't be public, is there a reason to use it?
davidhewitt
left a comment
There was a problem hiding this comment.
The ::new in particular is a bit strange given it's asking for inheritance, I would be ok with removing it (maybe by making it panic immediately for the Existing case and deprecating the symbol, to be at least a little graceful to users).
1749f4c to
fcecffb
Compare
|
@alex Fixed the issue with |
16abef4 to
2159f0f
Compare
From now you cannot initialize a `PyClassInitializer<SubClass>` with `PyClassInitializer::from(Py<BaseClass>).add_subclass(SubClass)`. This was out of bounds write. Now it panics. See details at PyO3#4452.
2159f0f to
01edfde
Compare
|
I cannot reproduce valgrind's failure locally. @davidhewitt can you help with that? |
|
See #4463, I pinned main back, this should merge ok now. |
From now you cannot initialize a `PyClassInitializer<SubClass>` with `PyClassInitializer::from(Py<BaseClass>).add_subclass(SubClass)`. This was out of bounds write. Now it panics. See details at #4452.
From now you cannot initialize a `PyClassInitializer<SubClass>` with `PyClassInitializer::from(Py<BaseClass>).add_subclass(SubClass)`. This was out of bounds write. Now it panics. See details at #4452.
From now you cannot initialize a `PyClassInitializer<SubClass>` with `PyClassInitializer::from(Py<BaseClass>).add_subclass(SubClass)`. This was out of bounds write. Now it panics. See details at #4452.
From now you cannot initialize a
PyClassInitializer<SubClass>withPyClassInitializer::from(Py<BaseClass>).add_subclass(SubClass).This was out of bounds write. Now it panics. See details at #4452.
This is a short-term fix for #4452.
Long-term, we probably want to forbid that at compile time, but that will be a breaking change.