Skip to content

[3.12] gh-112334: Restore subprocess's use of vfork() & fix extra_groups=[] behavior (GH-112617) #112731

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 2 commits into from
Dec 4, 2023

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Dec 4, 2023

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 it
would no longer use the fast-path vfork() system call when it could have
due 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 made
in the child process prior to exec().

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.

(cherry picked from commit 9fe7655)

Co-authored-by: Gregory P. Smith [email protected]
Co-authored-by: Serhiy Storchaka [email protected]

The security issue has been assigned CVE-2023-6507.

…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 it
would no longer use the fast-path ``vfork()`` system call when it could have
due 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 made
in the child process prior to ``exec()``.

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.

(cherry picked from commit 9fe7655)

Co-authored-by: Gregory P. Smith <[email protected]>
Co-authored-by: Serhiy Storchaka <[email protected]>
(mentions the assigned CVE number)
@gpshead gpshead enabled auto-merge (squash) December 4, 2023 23:16
@gpshead gpshead merged commit 85bbfa8 into python:3.12 Dec 4, 2023
@gpshead gpshead added the type-security A security issue label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.12 only security fixes release-blocker type-bug An unexpected behavior, bug, or error type-security A security issue
Projects
Development

Successfully merging this pull request may close these issues.

2 participants