-
- Notifications
You must be signed in to change notification settings - Fork 33.5k
bpo-30058: Fixed buffer overflow in select.kqueue.control(). #1095
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
bpo-30058: Fixed buffer overflow in select.kqueue.control(). #1095
Conversation
| @serhiy-storchaka, thanks for your PR! By analyzing the history of the files in this pull request, we identified @tiran, @cf-natali and @akuchling to be potential reviewers. |
Modules/selectmodule.c Outdated
| if (nchanges < 0) { | ||
| goto error; | ||
| } | ||
| nchanges = PySequence_Fast_GET_SIZE(arg); |
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.
PySequence_Fast_GET_SIZE returns a Py_ssize_t. This may trigger a compile warning.
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.
Good point!
Modules/selectmodule.c Outdated
| } | ||
| nchanges = PyObject_Size(ch); | ||
| if (nchanges < 0) { | ||
| if (PySequence_Fast_GET_SIZE(arg) > INT_MAX / sizeof(struct kevent)) { |
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.
arg should be seq, right?
I don't think we need to / sizeof(struct kevent). > INT_MAX is enough. Then there will be a memory error below. Or use PY_SSIZE_T_MAX here, assuming PY_SSIZE_T_MAX / sizeof(struct kevent) <= INT_MAX.
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.
Done.
zhangyangyu left a comment
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.
LGTM from code. But I can't even compile.
louisom left a comment
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.
just a nit typo
Lib/test/test_kqueue.py Outdated
| kq.close() | ||
| | ||
| def test_issue30058(self): | ||
| # chagelist must be an iterable |
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.
typo: chagelist -> changelist
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.
Good catch @lulouie!
| @zhangyangyu why can't you compile? My env compile it well. |
| @lulouie , the code is specialized for BSD. I only have access to Linux. Compiling it on Linux doesn't make any sense. |
| @zhangyangyu ah, It has compiled on Linux, but only the GNU part, not BSD part. |
| Thanks @serhiy-storchaka for the PR 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6. |
| GH-3973 is a backport of this pull request to the 3.6 branch. |
…ythonGH-1095) (cherry picked from commit de07210)
| Sorry, @serhiy-storchaka, I could not cleanly backport this to |
…ythonGH-1095). (cherry picked from commit de07210)
| GH-3976 is a backport of this pull request to the 2.7 branch. |
https://bugs.python.org/issue30058