From: Greg Kroah-Hartman Date: Tue, 28 Aug 2018 06:08:39 +0000 (+0200) Subject: 4.9-stable patches X-Git-Tag: v3.18.121~63 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2c660f283bf5af694f00ccaf3fd9d2b0b584fadc;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: sched-sysctl-check-user-input-value-of-sysctl_sched_time_avg.patch --- diff --git a/queue-4.9/sched-sysctl-check-user-input-value-of-sysctl_sched_time_avg.patch b/queue-4.9/sched-sysctl-check-user-input-value-of-sysctl_sched_time_avg.patch new file mode 100644 index 00000000000..a23242e35fb --- /dev/null +++ b/queue-4.9/sched-sysctl-check-user-input-value-of-sysctl_sched_time_avg.patch @@ -0,0 +1,85 @@ +From 5ccba44ba118a5000cccc50076b0344632459779 Mon Sep 17 00:00:00 2001 +From: Ethan Zhao +Date: Mon, 4 Sep 2017 13:59:34 +0800 +Subject: sched/sysctl: Check user input value of sysctl_sched_time_avg + +From: Ethan Zhao + +commit 5ccba44ba118a5000cccc50076b0344632459779 upstream. + +System will hang if user set sysctl_sched_time_avg to 0: + + [root@XXX ~]# sysctl kernel.sched_time_avg_ms=0 + + Stack traceback for pid 0 + 0xffff883f6406c600 0 0 1 3 R 0xffff883f6406cf50 *swapper/3 + ffff883f7ccc3ae8 0000000000000018 ffffffff810c4dd0 0000000000000000 + 0000000000017800 ffff883f7ccc3d78 0000000000000003 ffff883f7ccc3bf8 + ffffffff810c4fc9 ffff883f7ccc3c08 00000000810c5043 ffff883f7ccc3c08 + Call Trace: + [] ? update_group_capacity+0x110/0x200 + [] ? update_sd_lb_stats+0x109/0x600 + [] ? find_busiest_group+0x47/0x530 + [] ? load_balance+0x194/0x900 + [] ? update_rq_clock.part.83+0x1a/0xe0 + [] ? rebalance_domains+0x152/0x290 + [] ? run_rebalance_domains+0xdc/0x1d0 + [] ? __do_softirq+0xfb/0x320 + [] ? irq_exit+0x125/0x130 + [] ? scheduler_ipi+0x97/0x160 + [] ? smp_reschedule_interrupt+0x29/0x30 + [] ? reschedule_interrupt+0x6e/0x80 + [] ? cpuidle_enter_state+0xcc/0x230 + [] ? cpuidle_enter_state+0x9c/0x230 + [] ? cpuidle_enter+0x17/0x20 + [] ? cpu_startup_entry+0x38c/0x420 + [] ? start_secondary+0x173/0x1e0 + +Because divide-by-zero error happens in function: + +update_group_capacity() + update_cpu_capacity() + scale_rt_capacity() + { + ... + total = sched_avg_period() + delta; + used = div_u64(avg, total); + ... + } + +To fix this issue, check user input value of sysctl_sched_time_avg, keep +it unchanged when hitting invalid input, and set the minimum limit of +sysctl_sched_time_avg to 1 ms. + +Reported-by: James Puthukattukaran +Signed-off-by: Ethan Zhao +Signed-off-by: Peter Zijlstra (Intel) +Cc: Linus Torvalds +Cc: Peter Zijlstra +Cc: Thomas Gleixner +Cc: efault@gmx.de +Cc: ethan.kernel@gmail.com +Cc: keescook@chromium.org +Cc: mcgrof@kernel.org +Cc: +Link: http://lkml.kernel.org/r/1504504774-18253-1-git-send-email-ethan.zhao@oracle.com +Signed-off-by: Ingo Molnar +Cc: Steve Muckle +Signed-off-by: Greg Kroah-Hartman + +--- + kernel/sysctl.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/kernel/sysctl.c ++++ b/kernel/sysctl.c +@@ -345,7 +345,8 @@ static struct ctl_table kern_table[] = { + .data = &sysctl_sched_time_avg, + .maxlen = sizeof(unsigned int), + .mode = 0644, +- .proc_handler = proc_dointvec, ++ .proc_handler = proc_dointvec_minmax, ++ .extra1 = &one, + }, + { + .procname = "sched_shares_window_ns", diff --git a/queue-4.9/series b/queue-4.9/series index a554e4ea50f..11302368c86 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -47,3 +47,4 @@ scsi-fcoe-drop-frames-in-els-logo-error-path.patch scsi-fcoe-clear-fc_rp_started-flags-when-receiving-a-logo.patch scsi-vmw_pvscsi-return-did_reset-for-status-sam_stat_command_terminated.patch mm-memory.c-check-return-value-of-ioremap_prot.patch +sched-sysctl-check-user-input-value-of-sysctl_sched_time_avg.patch