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 16sysctl_test() 17{ 18 # With commit d00535d, sched_time_avg was renamed as sched_time_avg_ms 19 local dir="/proc/sys/kernel/" 20 [ -e "$dir""sched_time_avg_ms" ] && local name="sched_time_avg_ms" 21 [ -e "$dir""sched_time_avg" ] && local name="sched_time_avg" 22 [ -z "$name" ] && tst_brk TCONF \ 23 "sched_time_avg(_ms) was not supported" 24 25 local orig_value=$(cat "$dir""$name") 26 27 sysctl -w "kernel.""$name"=0 >/dev/null 2>&1 28 29 local test_value=$(cat "$dir""$name") 30 31 if [ ${test_value} -eq ${orig_value} ]; then 32 tst_res TPASS "Setting $name failed" 33 else 34 tst_res TFAIL "Setting $name succeeded" 35 sysctl -w "kernel.""$name"=${orig_value} >/dev/null 2>&1 36 fi 37} 38 39. tst_test.sh 40tst_run 41