• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0-or-later
3# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved.
4# Author: Xiao Yang <yangx.jy@cn.fujitsu.com>
5#
6# This is a regression test for invalid value of sysctl_sched_time_avg.
7# System will hang if user set sysctl_sched_time_avg to 0 on buggy kernel.
8#
9# The kernel bug has been fixed in kernel:
10# '5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")'
11
12TST_TESTFUNC=sysctl_test
13TST_NEEDS_ROOT=1
14TST_NEEDS_CMDS="sysctl"
15
16. tst_test.sh
17
18sysctl_test()
19{
20	# With commit d00535d, sched_time_avg was renamed as sched_time_avg_ms
21	local dir="/proc/sys/kernel/"
22	[ -e "$dir""sched_time_avg_ms" ] && local name="sched_time_avg_ms"
23	[ -e "$dir""sched_time_avg" ] && local name="sched_time_avg"
24	[ -z "$name" ] && tst_brk TCONF \
25		"sched_time_avg(_ms) was not supported"
26
27	local orig_value=$(cat "$dir""$name")
28
29	sysctl -w "kernel.""$name"=0 >/dev/null 2>&1
30
31	local test_value=$(cat "$dir""$name")
32
33	if [ ${test_value} -eq ${orig_value} ]; then
34		tst_res TPASS "Setting $name failed"
35	else
36		tst_res TFAIL "Setting $name succeeded"
37		sysctl -w "kernel.""$name"=${orig_value} >/dev/null 2>&1
38	fi
39}
40
41tst_run
42