Created attachment 185948 [details] cam iosched: Add a handler for the quanta sysctl to enforce valid values The attached patch adds a handler for the iosched quanta sysctl to enforce valid values Invalid values can result in devision-by-zero panics and other undesirable behaviour. Example panic: Fatal trap 18: integer divide fault while in kernel mode cpuid = 0; apic id = 00 instruction pointer = 0x20:0xffffffff802998e5 stack pointer = 0x28:0xfffffe01ea3bf8d0 frame pointer = 0x28:0xfffffe01ea3bf900 code segment = base rx0, limit 0xfffff, type 0x1b = DPL 0, pres 1, long 1, def32 0, gran 1 processor eflags = interrupt enabled, resume, IOPL = 0 current process = 12 (swi4: clock (0)) trap number = 18 panic: integer divide fault cpuid = 0 KDB: stack backtrace: db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe01ea3bf510 vpanic() at vpanic+0x186/frame 0xfffffe01ea3bf590 panic() at panic+0x43/frame 0xfffffe01ea3bf5f0 trap_fatal() at trap_fatal+0x322/frame 0xfffffe01ea3bf640 trap() at trap+0x5e/frame 0xfffffe01ea3bf800 calltrap() at calltrap+0x8/frame 0xfffffe01ea3bf800 --- trap 0x12, rip = 0xffffffff802998e5, rsp = 0xfffffe01ea3bf8d0, rbp = 0xfffffe01ea3bf900 --- cam_iosched_ticker() at cam_iosched_ticker+0x25/frame 0xfffffe01ea3bf900 softclock_call_cc() at softclock_call_cc+0x13e/frame 0xfffffe01ea3bf9b0 softclock() at softclock+0xb9/frame 0xfffffe01ea3bf9e0 intr_event_execute_handlers() at intr_event_execute_handlers+0xec/frame 0xfffffe01ea3bfa20 ithread_loop() at ithread_loop+0xd6/frame 0xfffffe01ea3bfa70 fork_exit() at fork_exit+0x85/frame 0xfffffe01ea3bfab0 fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe01ea3bfab0 --- trap 0, rip = 0, rsp = 0, rbp = 0 --- Uptime: 2h29m20s Dumping 1165 out of 8055 MB:..2%..11%..21%..31%..42%..51%..61%..71%..81%..91% Obtained from: ElectroBSD
This looks good except for the kernel printf. Other validation routines don't do that.
A commit references this bug: Author: imp Date: Wed Sep 20 21:19:54 UTC 2017 New revision: 323829 URL: https://svnweb.freebsd.org/changeset/base/323829 Log: cam iosched: Add a handler for the quanta sysctl to enforce valid values Invalid values can result in devision-by-zero panics or other undefined behaviour so lets not allow them. PR: 221957 Obtained from: ElectroBSD Submitted by: Fabian Keil Differential Revision: https://reviews.freebsd.org/D12351 Changes: head/sys/cam/cam_iosched.c
A commit references this bug: Author: sbruno Date: Fri May 25 23:18:06 UTC 2018 New revision: 334229 URL: https://svnweb.freebsd.org/changeset/base/334229 Log: MFC r323829 cam iosched: Add a handler for the quanta sysctl to enforce valid values MFC r323831 cam iosched: Schedule cam_iosched_ticker() quanta times per second PR: 221956 221957 Submitted by: imp Approved by: re (marius) Changes: _U stable/11/ stable/11/sys/cam/cam_iosched.c