Skip to content

gh-115136: Fix possible NULL deref in getpath_joinpath() #115137

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

Merged
merged 6 commits into from
Feb 8, 2024

Conversation

dTenebrae
Copy link
Contributor

@dTenebrae dTenebrae commented Feb 7, 2024

Check return value of PyMem_Malloc() before passing to memset()

Check return value of PyMem_Malloc() before passing to memset()

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
@ghost
Copy link

ghost commented Feb 7, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

@bedevere-app
Copy link

bedevere-app bot commented Feb 7, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

dTenebrae and others added 2 commits February 7, 2024 16:14
Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
@@ -0,0 +1 @@
Check return value of PyMem_Malloc() before passing to memset()
Copy link
Contributor

@aisk aisk Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we can use RST markups here. And maybe we should describe we added the check to which part of the codebase.

Suggested change
Check return value of PyMem_Malloc() before passing to memset()
Check return value of :c:func:`PyMem_Malloc` before passing to :c:func:`memset`
in ``Modules/getpath.c``.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for review, updated entry with your suggestion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I updated the comment after your latest commits. I think we should add a description of which part we add the check to.

Copy link
Member

@Eclips4 Eclips4 Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is no need in a NEWS entry. Otherwise LGTM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @Eclips4, The NEWS entry should contain information understendable and useful for common Python user. The common Python user has no idea what is Modules/getpath.c and how this change affects their code. Should they worry? What code they should avoid? What workaround they should use and what workaround is no longer needed?

This bug has no workaround, but it can happen only in very rare circumstances, and may be shadowed by other bugs. So the common user should not worry about it, not more than about other not yet found bugs or about the OOM killer killing their program.

@bedevere-app
Copy link

bedevere-app bot commented Feb 8, 2024

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Member

@serhiy-storchaka serhiy-storchaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM without a NEWS entry.

@miss-islington-app
Copy link

Thanks @dTenebrae for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 8, 2024
…nGH-115137)

(cherry picked from commit 9e90313)

Co-authored-by: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com>
Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
@bedevere-app
Copy link

bedevere-app bot commented Feb 8, 2024

GH-115157 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Feb 8, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 8, 2024
…nGH-115137)

(cherry picked from commit 9e90313)

Co-authored-by: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com>
Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
@bedevere-app
Copy link

bedevere-app bot commented Feb 8, 2024

GH-115158 is a backport of this pull request to the 3.11 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.11 only security fixes label Feb 8, 2024
serhiy-storchaka pushed a commit that referenced this pull request Feb 8, 2024
…15137) (ПР-115158)

(cherry picked from commit 9e90313)

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Co-authored-by: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com>
serhiy-storchaka pushed a commit that referenced this pull request Feb 8, 2024
…15137) (GH-115157)

(cherry picked from commit 9e90313)

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Co-authored-by: Artem Chernyshev <62871052+dTenebrae@users.noreply.github.com>
fsc-eriker pushed a commit to fsc-eriker/cpython that referenced this pull request Feb 14, 2024
…nGH-115137)

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants