0
0
mirror of https://github.com/python/cpython.git synced 2024-11-27 15:27:06 +01:00
cpython/Lib/multiprocessing
Gregory P. Smith 7191b7662e
gh-97514: Authenticate the forkserver control socket. (GH-99309)
This adds authentication to the forkserver control socket. In the past only filesystem permissions protected this socket from code injection into the forkserver process by limiting access to the same UID, which didn't exist when Linux abstract namespace sockets were used (see issue) meaning that any process in the same system network namespace could inject code. We've since stopped using abstract namespace sockets by default, but protecting our control sockets regardless of type is a good idea.

This reuses the HMAC based shared key auth already used by `multiprocessing.connection` sockets for other purposes.

Doing this is useful so that filesystem permissions are not relied upon and trust isn't implied by default between all processes running as the same UID with access to the unix socket.

### pyperformance benchmarks

No significant changes. Including `concurrent_imap` which exercises `multiprocessing.Pool.imap` in that suite.

### Microbenchmarks

This does _slightly_ slow down forkserver use. How much so appears to depend on the platform. Modern platforms and simple platforms are less impacted. This PR adds additional IPC round trips to the control socket to tell forkserver to spawn a new process. Systems with potentially high latency IPC are naturally impacted more.

Typically a 1-4% slowdown on a very targeted process creation microbenchmark, with a worst case overloaded system slowdown of 20%.  No evidence that these slowdowns appear in practical sense.  See the PR for details.
2024-11-20 08:18:58 -08:00
..
dummy
__init__.py
connection.py gh-97514: Authenticate the forkserver control socket. (GH-99309) 2024-11-20 08:18:58 -08:00
context.py
forkserver.py gh-97514: Authenticate the forkserver control socket. (GH-99309) 2024-11-20 08:18:58 -08:00
heap.py
managers.py gh-71936: Fix race condition in multiprocessing.Pool (GH-124973) 2024-11-13 10:25:10 +01:00
pool.py
popen_fork.py
popen_forkserver.py
popen_spawn_posix.py
popen_spawn_win32.py
process.py
queues.py
reduction.py gh-97514: Authenticate the forkserver control socket. (GH-99309) 2024-11-20 08:18:58 -08:00
resource_sharer.py
resource_tracker.py
shared_memory.py
sharedctypes.py
spawn.py
synchronize.py gh-125679: multiprocessing Lock and RLock - fix invalid representation string on MacOSX. (#125680) 2024-11-07 08:10:57 +00:00
util.py