]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/execute.c
Rework cpu affinity parsing
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 21 May 2019 06:45:19 +0000 (08:45 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 29 May 2019 08:20:42 +0000 (10:20 +0200)
commit0985c7c4e22c8dbbea4398cf3453da45ebf63800
treebbb08300ff3c022617628b8cbff223218b2ebc62
parentb12ef7141648be40fd8c4b0209a742f2151736d9
Rework cpu affinity parsing

The CPU_SET_S api is pretty bad. In particular, it has a parameter for the size
of the array, but operations which take two (CPU_EQUAL_S) or even three arrays
(CPU_{AND,OR,XOR}_S) still take just one size. This means that all arrays must
be of the same size, or buffer overruns will occur. This is exactly what our
code would do, if it received an array of unexpected size over the network.
("Unexpected" here means anything different from what cpu_set_malloc() detects
as the "right" size.)

Let's rework this, and store the size in bytes of the allocated storage area.

The code will now parse any number up to 8191, independently of what the current
kernel supports. This matches the kernel maximum setting for any architecture,
to make things more portable.

Fixes #12605.
14 files changed:
src/core/dbus-execute.c
src/core/execute.c
src/core/execute.h
src/core/load-fragment.c
src/core/main.c
src/nspawn/nspawn-oci.c
src/nspawn/nspawn-settings.c
src/nspawn/nspawn-settings.h
src/nspawn/nspawn.c
src/shared/bus-unit-util.c
src/shared/cpu-set-util.c
src/shared/cpu-set-util.h
src/test/test-cpu-set-util.c
src/test/test-sizeof.c