]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-112334: Restore subprocess's use of `vfork()` & fix `extra_groups=[]` behavior...
authorGregory P. Smith <greg@krypto.org>
Mon, 4 Dec 2023 23:08:19 +0000 (15:08 -0800)
committerGitHub <noreply@github.com>
Mon, 4 Dec 2023 23:08:19 +0000 (15:08 -0800)
commit9fe7655c6ce0b8e9adc229daf681b6d30e6b1610
treeb714c4e7ec1627ee93d10af77dc977d4b2d71ae1
parentc5fa8a54dbdf564d482e2e3857aa3efa61edd329
gh-112334: Restore subprocess's use of `vfork()` & fix `extra_groups=[]` behavior (#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.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/test_subprocess.py
Misc/NEWS.d/next/Library/2023-12-01-21-05-46.gh-issue-112334.DmNXKh.rst [new file with mode: 0644]
Modules/_posixsubprocess.c