Bug 221957 - cam iosched: Add a handler for the quanta sysctl to enforce valid values
Summary: cam iosched: Add a handler for the quanta sysctl to enforce valid values
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-scsi
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2017-08-31 10:25 UTC by Fabian Keil
Modified: 2017-09-20 21:20 UTC (History)
3 users (show)

See Also:
fk: mfc-stable11?


Attachments
cam iosched: Add a handler for the quanta sysctl to enforce valid values (3.41 KB, patch)
2017-08-31 10:25 UTC, Fabian Keil
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Keil 2017-08-31 10:25:08 UTC
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
Comment 1 Warner Losh freebsd_committer 2017-09-01 01:04:06 UTC
This looks good except for the kernel printf. Other validation routines don't do that.
Comment 2 commit-hook freebsd_committer 2017-09-20 21:20:46 UTC
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