1#!/bin/sh 2 3# Copyright (c) 2018 FUJITSU LIMITED. All rights reserved. 4# Author: Xiao Yang <yangx.jy@cn.fujitsu.com> 5# 6# This program is free software; you can redistribute it and#or modify 7# it under the terms of the GNU General Public License as published by 8# the Free Software Foundation; either version 2 of the License, or 9# (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, but 12# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14# for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, see <http://www.gnu.org/licenses/>. 18# 19# Description: 20# This is a regression test for invalid value of sysctl_sched_time_avg. 21# System will hang if user set sysctl_sched_time_avg to 0 on buggy kernel. 22# 23# The kernel bug has been fixed in kernel: 24# '5ccba44ba118("sched/sysctl: Check user input value of sysctl_sched_time_avg")' 25 26TST_TESTFUNC=sysctl_test 27TST_NEEDS_ROOT=1 28TST_NEEDS_CMDS="sysctl" 29 30. tst_test.sh 31 32sysctl_test() 33{ 34 # With commit d00535d, sched_time_avg was renamed as sched_time_avg_ms 35 local dir="/proc/sys/kernel/" 36 [ -e "$dir""sched_time_avg_ms" ] && local name="sched_time_avg_ms" 37 [ -e "$dir""sched_time_avg" ] && local name="sched_time_avg" 38 [ -z "$name" ] && tst_brk TCONF \ 39 "sched_time_avg(_ms) was not supported" 40 41 local orig_value=$(cat "$dir""$name") 42 43 sysctl -w "kernel.""$name"=0 >/dev/null 2>&1 44 45 local test_value=$(cat "$dir""$name") 46 47 if [ ${test_value} -eq ${orig_value} ]; then 48 tst_res TPASS "Setting $name failed" 49 else 50 tst_res TFAIL "Setting $name succeeded" 51 sysctl -w "kernel.""$name"=${orig_value} >/dev/null 2>&1 52 fi 53} 54 55tst_run 56