This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Fix subprocess extra_groups gid conversion
Type: Stage: resolved
Components: Extension Modules Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gregory.p.smith, izbyshev, kulikjak, miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2020-12-16 10:05 by kulikjak, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 23762 merged kulikjak, 2020-12-16 10:05
PR 23997 merged miss-islington, 2020-12-29 12:59
Messages (6)
msg383132 - (view) Author: Jakub Kulik (kulikjak) * Date: 2020-12-16 10:05
C function `subprocess_fork_exec` incorrectly transforms gids from the `extra_groups` argument because it passes `unsigned long*` rather than `pid_t*` into the `_Py_Gid_Converter()`. Assuming that `gid_t` is 32 bit and `unsigned long` is 64 bit (which it often is), `*(gid_t *)p = gid;` then incorrectly overwrites only part of that variable, leaving the other one filled with previous garbage.

I found this on Solaris, but I am pretty sure that this doesn't work correctly on Linux as well, since both use `unsigned int` as `gid_t`.
msg383380 - (view) Author: Alexey Izbyshev (izbyshev) * (Python triager) Date: 2020-12-19 14:38
This bug would have been caught at compile time if `_Py_Gid_Converter()` used `gid_t *` instead of `void *`. I couldn't find any call sites where `void *` would be needed, so probably `_Py_Gid_Converter()` should be fixed too (in a separate PR/issue?). The same applies to `_Py_Uid_Converter()`.
msg383431 - (view) Author: Jakub Kulik (kulikjak) * Date: 2020-12-20 14:29
I checked and indeed there seems to be no reason as for why should we use `void *` rather than `gid_t *` and `uid_t *`. I changed that in the attached PR.
msg383995 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-12-29 12:58
New changeset 0159e5efeebd12b3cf365c8569ca000eac7cb03e by Jakub Kulík in branch 'master':
bpo-42655: Fix subprocess extra_groups gid conversion (GH-23762)
https://github.com/python/cpython/commit/0159e5efeebd12b3cf365c8569ca000eac7cb03e
msg383999 - (view) Author: miss-islington (miss-islington) Date: 2020-12-29 13:22
New changeset 3966e2ea412a5f190dc8655d9aa7a15c08c4e280 by Miss Islington (bot) in branch '3.9':
bpo-42655: Fix subprocess extra_groups gid conversion (GH-23762)
https://github.com/python/cpython/commit/3966e2ea412a5f190dc8655d9aa7a15c08c4e280
msg384004 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2020-12-29 13:41
Thank you for your contribution Jakub.
History
Date User Action Args
2022-04-11 14:59:39adminsetgithub: 86821
2020-12-29 13:41:01serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg384004

stage: patch review -> resolved
2020-12-29 13:22:17miss-islingtonsetmessages: + msg383999
2020-12-29 12:59:10miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request22840
2020-12-29 12:58:39serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg383995
2020-12-20 14:29:06kulikjaksetmessages: + msg383431
2020-12-19 14:38:20izbyshevsetnosy: + gregory.p.smith, izbyshev
messages: + msg383380
2020-12-16 10:05:39kulikjaksetkeywords: + patch
stage: patch review
pull_requests: + pull_request22655
2020-12-16 10:05:22kulikjakcreate