Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-112334: Restore subprocess's use ofvfork() & fixextra_groups=[] behavior#112617

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
gpshead merged 4 commits intopython:mainfromgpshead:bug/subprocess/112334
Dec 4, 2023

Conversation

@gpshead
Copy link
Member

@gpsheadgpshead commentedDec 2, 2023
edited
Loading

Fixed a performance regression in 3.12'ssubprocess on Linux where it would no longer use the fast-pathvfork() system call when it could have due to a logic bug, instead falling back to the safe but slowerfork().

Also fixed a second 3.12.0 potential security bug. If a value ofextra_groups=[] was passed tosubprocess.Popen or related APIs, the underlyingsetgroups(0, NULL) system call to clear the groups list would not be made in the child process prior toexec().

The security issue was identified via code inspection in the process of fixing the first bug. Thanks to@vain for the detailed report and analysis in the initial bug on Github.

  • A regression test regarding vfork usage is desirable. I'm pondering a test that runs whenstrace is available and permitted which and confirms use ofvfork() vsclone()...
  • A test that will catchsetgroup() not being called is included in this PR. It must be run asroot on Linux. I believe one of our buildbots is configured to run that way.
  • Discuss with Python Security Response team if this is also a noteworthy security fix. It could manifest when a root uid=0 process wants to drop other group memberships while executing a subprocess. Probably security relevant if theuser= andgroup= parameters are also being used to drop privs...

Fixes#112334.

The security issue has been assignedCVE-2023-6507.

…roups=[]`.Fixed a performance regression in 3.12's :mod:`subprocess` on Linux where itwould no longer use the fast-path ``vfork()`` system call when it could havedue to a logic bug, instead falling back to the safe but slower ``fork()``.Also fixed a second 3.12.0 potential security bug.  If a value of``extra_groups=[]`` was passed to :mod:`subprocess.Popen` or related APIs,the underlying ``setgroups(0, NULL)`` system call to clear the groups listwould not be made in the child process prior to ``exec()``.The security issue was identified via code inspection in the process offixing the first bug.  Thanks to@vain for the detailed report andanalysis in the initial bug on Github. * [ ] A regression test is desirable. I'm pondering a test that runs when   `strace` is available and permitted which and confirms use of `vfork()`   vs `clone()`...
@gpsheadgpshead added type-bugAn unexpected behavior, bug, or error 3.12only security fixes needs backport to 3.12only security fixes labelsDec 2, 2023
@gpsheadgpshead self-assigned thisDec 2, 2023
@gpsheadgpshead added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelDec 2, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@gpshead for commit84d060f 🤖

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelDec 2, 2023
@gpsheadgpshead requested a review fromYhg1sDecember 2, 2023 19:08
@vain
Copy link

vain commentedDec 4, 2023

@gpshead Thank you! FWIW, this fixes my test case. :)

gpshead reacted with thumbs up emoji

gpsheadand others added2 commitsDecember 4, 2023 12:36
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Based on Serhiy's code review.  (thanks!)Confirmed it still passes as root and non-root on Linux.
@serhiy-storchakaserhiy-storchaka added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelDec 4, 2023
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@serhiy-storchaka for commitce31462 🤖

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelDec 4, 2023
@gpsheadgpshead merged commit9fe7655 intopython:mainDec 4, 2023
@miss-islington-app
Copy link

Thanks@gpshead for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@gpsheadgpshead deleted the bug/subprocess/112334 branchDecember 4, 2023 23:08
@bedevere-app
Copy link

GH-112731 is a backport of this pull request to the3.12 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull requestDec 4, 2023
…roups=[]` behavior (pythonGH-112617)Restore `subprocess`'s intended use of `vfork()` by default for performance on Linux;also fixes the behavior of `extra_groups=[]` which was unintentionally broken in 3.12.0:Fixed a performance regression in 3.12's :mod:`subprocess` on Linux where itwould no longer use the fast-path ``vfork()`` system call when it could havedue to a logic bug, instead falling back to the safe but slower ``fork()``.Also fixed a security bug introduced in 3.12.0.  If a value of ``extra_groups=[]``was passed to :mod:`subprocess.Popen` or related APIs, the underlying``setgroups(0, NULL)`` system call to clear the groups list would not be madein the child process prior to ``exec()``.The security issue was identified via code inspection in the process offixing the first bug.  Thanks to@vain for the detailed report andanalysis in the initial bug on Github.(cherry picked from commit9fe7655)Co-authored-by: Gregory P. Smith <greg@krypto.org>Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-appbedevere-appbot removed the needs backport to 3.12only security fixes labelDec 4, 2023
@gpshead
Copy link
MemberAuthor

I will add the desired vfork regression test in a followup PR. Merging now to unblock releasing the fix.

gpshead added a commit that referenced this pull requestDec 4, 2023
…groups=[]` behavior (GH-112617) (#112731)Restore `subprocess`'s intended use of `vfork()` by default for performance on Linux;also fixes the behavior of `extra_groups=[]` which was unintentionally broken in 3.12.0:Fixed a performance regression in 3.12's :mod:`subprocess` on Linux where itwould no longer use the fast-path ``vfork()`` system call when it could havedue to a logic bug, instead falling back to the safe but slower ``fork()``.Also fixed a security bug introduced in 3.12.0.  If a value of ``extra_groups=[]``was passed to :mod:`subprocess.Popen` or related APIs, the underlying``setgroups(0, NULL)`` system call to clear the groups list would not be madein the child process prior to ``exec()``.The security issue was identified via code inspection in the process offixing the first bug.  Thanks to@vain for the detailed report andanalysis in the initial bug on Github.(cherry picked from commit9fe7655)+ Reword NEWS for the bugfix/security release. (mentions the assigned CVE number)Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org>Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@gpsheadgpshead added the type-securityA security issue labelDec 8, 2023
aisk pushed a commit to aisk/cpython that referenced this pull requestFeb 11, 2024
…roups=[]` behavior (python#112617)Restore `subprocess`'s intended use of `vfork()` by default for performance on Linux;also fixes the behavior of `extra_groups=[]` which was unintentionally broken in 3.12.0:Fixed a performance regression in 3.12's :mod:`subprocess` on Linux where itwould no longer use the fast-path ``vfork()`` system call when it could havedue to a logic bug, instead falling back to the safe but slower ``fork()``.Also fixed a security bug introduced in 3.12.0.  If a value of ``extra_groups=[]``was passed to :mod:`subprocess.Popen` or related APIs, the underlying``setgroups(0, NULL)`` system call to clear the groups list would not be madein the child process prior to ``exec()``.The security issue was identified via code inspection in the process offixing the first bug.  Thanks to@vain for the detailed report andanalysis in the initial bug on Github.Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Glyphack pushed a commit to Glyphack/cpython that referenced this pull requestSep 2, 2024
…roups=[]` behavior (python#112617)Restore `subprocess`'s intended use of `vfork()` by default for performance on Linux;also fixes the behavior of `extra_groups=[]` which was unintentionally broken in 3.12.0:Fixed a performance regression in 3.12's :mod:`subprocess` on Linux where itwould no longer use the fast-path ``vfork()`` system call when it could havedue to a logic bug, instead falling back to the safe but slower ``fork()``.Also fixed a security bug introduced in 3.12.0.  If a value of ``extra_groups=[]``was passed to :mod:`subprocess.Popen` or related APIs, the underlying``setgroups(0, NULL)`` system call to clear the groups list would not be madein the child process prior to ``exec()``.The security issue was identified via code inspection in the process offixing the first bug.  Thanks to@vain for the detailed report andanalysis in the initial bug on Github.Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@serhiy-storchakaserhiy-storchakaserhiy-storchaka approved these changes

@arhadthedevarhadthedevAwaiting requested review from arhadthedev

@sethmlarsonsethmlarsonAwaiting requested review from sethmlarson

@Yhg1sYhg1sAwaiting requested review from Yhg1s

Assignees

@gpsheadgpshead

Labels

3.12only security fixesrelease-blockertype-bugAn unexpected behavior, bug, or errortype-securityA security issue

Projects

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

subprocess.Popen: Performance regression on Linux since 124af17b6e [CVE-2023-6507]

4 participants

@gpshead@bedevere-bot@vain@serhiy-storchaka

[8]ページ先頭

©2009-2025 Movatter.jp