-
Notifications
You must be signed in to change notification settings - Fork 778
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a soundness bug with PyClassInitializer
#4454
Fix a soundness bug with PyClassInitializer
#4454
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
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.