summaryrefslogtreecommitdiff
path: root/src/core/dbus-execute.c
diff options
context:
space:
mode:
authorLuca Boccassi <bluca@debian.org>2022-10-19 23:52:58 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2022-10-20 14:29:45 +0200
commit40c05a34595ed769ce676206f3c5de874f9a9234 (patch)
treea14cc9cffe994d15b887048ab4fbc183798ef12f /src/core/dbus-execute.c
parent1726ce726f1a317e6badab5e22fa7ea0afb75b8e (diff)
downloadsystemd-40c05a34595ed769ce676206f3c5de874f9a9234.tar.gz
service: do fine-grained validation of CPUSchedulingPriority= at execution time
The precise bounds of the scheduling priority depend on the scheduling policy, so depending on the order in which the two settings are specified the validation might pass or fail. When checking the setting only validate the outer range (valid values in general are 0 to 99), and let the execution fail later if the priority does not match the specified policy (1 to 99 for RR/FIFO, 0 for the rest). Fixes https://github.com/systemd/systemd/issues/20320
Diffstat (limited to 'src/core/dbus-execute.c')
-rw-r--r--src/core/dbus-execute.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index fd73c7bcb7..c5a51bf5cd 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -2718,15 +2718,15 @@ int bus_exec_context_set_transient_property(
return 1;
} else if (streq(name, "CPUSchedulingPriority")) {
- int32_t p, min, max;
+ int32_t p;
r = sd_bus_message_read(message, "i", &p);
if (r < 0)
return r;
- min = sched_get_priority_min(c->cpu_sched_policy);
- max = sched_get_priority_max(c->cpu_sched_policy);
- if (p < min || p > max)
+ /* On Linux RR/FIFO range from 1 to 99 and OTHER/BATCH may only be 0. Policy might be set
+ * later so we do not check the precise range, but only the generic outer bounds. */
+ if (p < 0 || p > 99)
return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid CPU scheduling priority: %i", p);
if (!UNIT_WRITE_FLAGS_NOOP(flags)) {