linux-stable/kernel/sched
Cyril Hrubis e4bc311745 sched/rt: Disallow writing invalid values to sched_rt_period_us
commit 079be8fc63 upstream.

The validation of the value written to sched_rt_period_us was broken
because:

  - the sysclt_sched_rt_period is declared as unsigned int
  - parsed by proc_do_intvec()
  - the range is asserted after the value parsed by proc_do_intvec()

Because of this negative values written to the file were written into a
unsigned integer that were later on interpreted as large positive
integers which did passed the check:

  if (sysclt_sched_rt_period <= 0)
	return EINVAL;

This commit fixes the parsing by setting explicit range for both
perid_us and runtime_us into the sched_rt_sysctls table and processes
the values with proc_dointvec_minmax() instead.

Alternatively if we wanted to use full range of unsigned int for the
period value we would have to split the proc_handler and use
proc_douintvec() for it however even the
Documentation/scheduller/sched-rt-group.rst describes the range as 1 to
INT_MAX.

As far as I can tell the only problem this causes is that the sysctl
file allows writing negative values which when read back may confuse
userspace.

There is also a LTP test being submitted for these sysctl files at:

  http://patchwork.ozlabs.org/project/ltp/patch/20230901144433.2526-1-chrubis@suse.cz/

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20231002115553.3007-2-chrubis@suse.cz
[ pvorel: rebased for 5.15, 5.10 ]
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-03-01 13:16:43 +01:00
..
Makefile
autogroup.c
autogroup.h
clock.c
completion.c
core.c cgroup/cpuset: Free DL BW in case can_attach() fails 2023-08-30 16:23:18 +02:00
cpuacct.c sched/cpuacct: Optimize away RCU read lock 2023-10-10 21:53:33 +02:00
cpudeadline.c
cpudeadline.h
cpufreq.c
cpufreq_schedutil.c cpufreq: schedutil: Use kobject release() method to free sugov_tunables 2021-10-06 15:55:45 +02:00
cpupri.c
cpupri.h
cputime.c cputime, cpuacct: Include guest time in user time in cpuacct.stat 2022-01-27 10:54:25 +01:00
deadline.c sched/deadline: Create DL BW alloc, free & check overflow interface 2023-08-30 16:23:18 +02:00
debug.c sched/debug: Remove mpol_get/put and task_lock/unlock from sched_show_numa 2022-04-08 14:40:03 +02:00
fair.c sched/uclamp: Ignore (util == 0) optimization in feec() when p_util_max = 0 2023-11-20 11:06:43 +01:00
features.h sched,fair: Alternative sched_slice() 2021-05-11 14:47:31 +02:00
idle.c sched/idle: Make the idle timer expire in hard interrupt context 2021-09-26 14:09:02 +02:00
isolation.c
loadavg.c
membarrier.c sched/membarrier: reduce the ability to hammer on sys_membarrier 2024-02-23 08:42:32 +01:00
pelt.c
pelt.h sched/fair: Fix cfs_rq_clock_pelt() for throttled cfs_rq 2022-06-09 10:21:02 +02:00
psi.c sched/psi: Fix use-after-free in ep_remove_wait_queue() 2023-02-22 12:55:56 +01:00
rt.c sched/rt: Disallow writing invalid values to sched_rt_period_us 2024-03-01 13:16:43 +01:00
sched-pelt.h
sched.h sched/deadline: Create DL BW alloc, free & check overflow interface 2023-08-30 16:23:18 +02:00
smp.h
stats.c
stats.h
stop_task.c
swait.c
topology.c sched/topology: Fix sched_domain_topology_level alloc in sched_init_numa() 2022-03-08 19:09:34 +01:00
wait.c wait: add wake_up_pollfree() 2021-12-14 11:32:39 +01:00
wait_bit.c