Page MenuHomeFreeBSD

linuxkpi: Ignore NULL passed to string parametr of kstrdup()

Authored by wulf on Jul 13 2020, 10:04 PM.



linuxkpi: Ignore NULLs passed to string parameter of kstr(n)dup

That is what Linux does. It fixes (or hides?) following panic sporadically occurring on my "HD Graphics 530" with drm-kmod-5.3:

Fatal trap 12: page fault while in kernel mode
cpuid = 6; apic id = 06
fault virtual address = 0x0
fault code = supervisor read data, page not present
instruction pointer = 0x20:0xffffffff806e19cf
stack pointer = 0x28:0xfffffe00b1872440
frame pointer = 0x28:0xfffffe00b1872440
code segment = base 0x0, limit 0xfffff, type 0x1b

= DPL 0, pres 1, long 1, def32 0, gran 1

processor eflags = interrupt enabled, resume, IOPL = 0
current process = 0 (linuxkpi_long_wq_7)
trap number = 12

panic: page fault
cpuid = 6
time = 1594559309
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe00b1872100
vpanic() at vpanic+0x182/frame 0xfffffe00b1872150
panic() at panic+0x43/frame 0xfffffe00b18721b0
trap_fatal() at trap_fatal+0x387/frame 0xfffffe00b1872210
trap_pfault() at trap_pfault+0x4f/frame 0xfffffe00b1872260
trap() at trap+0x271/frame 0xfffffe00b1872370
calltrap() at calltrap+0x8/frame 0xfffffe00b1872370

  • trap 0xc, rip = 0xffffffff806e19cf, rsp = 0xfffffe00b1872440, rbp = 0xfffffe00b1872440 ---

strlen() at strlen+0x1f/frame 0xfffffe00b1872440
kstrdup() at kstrdup+0x18/frame 0xfffffe00b1872470
dup_param() at dup_param+0x3a/frame 0xfffffe00b1872490
i915_params_copy() at i915_params_copy+0x41/frame 0xfffffe00b18724c0
capture_params() at capture_params+0x25/frame 0xfffffe00b18724e0
capture() at capture+0x6c/frame 0xfffffe00b1872500
stop_machine() at stop_machine+0x23/frame 0xfffffe00b1872530
i915_capture_gpu_state() at i915_capture_gpu_state+0xc1/frame 0xfffffe00b1872570
i915_capture_error_state() at i915_capture_error_state+0x5f/frame 0xfffffe00b18725f0
i915_handle_error() at i915_handle_error+0x106/frame 0xfffffe00b18727a0
hangcheck_declare_hang() at hangcheck_declare_hang+0x1f2/frame 0xfffffe00b1872860
i915_hangcheck_elapsed() at i915_hangcheck_elapsed+0x208/frame 0xfffffe00b18729a0
linux_work_fn() at linux_work_fn+0xde/frame 0xfffffe00b1872a00
taskqueue_run_locked() at taskqueue_run_locked+0x181/frame 0xfffffe00b1872a80
taskqueue_thread_loop() at taskqueue_thread_loop+0xac/frame 0xfffffe00b1872ab0
fork_exit() at fork_exit+0x7e/frame 0xfffffe00b1872af0
fork_trampoline() at fork_trampoline+0xe/frame 0xfffffe00b1872af0

  • trap 0, rip = 0, rsp = 0, rbp = 0 ---

KDB: enter: panic

Test Plan

Run drm-kmod-5.3 for several days w/o the panic.

Diff Detail

rS FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

wulf requested review of this revision.Jul 13 2020, 10:04 PM

looks good to me... one might quibble over the extra newline after the if, but it's fine either way imho.

This revision is now accepted and ready to land.Jul 13 2020, 11:08 PM

Don't forget to MFC to 11 and 12 after 1 week!