]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Make stack_save*() more robust on MIPS.
authorJohn Baldwin <jhb@FreeBSD.org>
Tue, 1 Dec 2020 17:17:22 +0000 (17:17 +0000)
committerJohn Baldwin <jhb@FreeBSD.org>
Tue, 1 Dec 2020 17:17:22 +0000 (17:17 +0000)
commitf2dceb474bf0c74b8111a8b100f4269e6001aed5
tree054432da04e996e8f9b1e0e9181e338ca544d91a
parent5941edfcdc17ed51b65125c25d3fac632bf4cd81
Make stack_save*() more robust on MIPS.

- Validate any stack addresses read from against td_kstack before
  reading.  If an unwind operation would attempt to read outside the
  bounds of td_kstack, abort the unwind instead.

- For stack_save_td(), don't use the PC and SP from the current
  thread, instead read the PC and SP from pcb_context[].

- For stack_save(), use the current PC and SP of the current thread,
  not the values from pcb_regs (the horribly named td_frame of the
  outermost trapframe).  The result was that stack_trace() never
  logged _any_ kernel frames but only the frame from the saved
  userspace registers on entry from the kernel.

- Inline the one use of stack_register_fetch().

- Add a VALID_PC() helper macro and simplify types to remove
  excessive casts in stack_capture().

- Fix stack_capture() to work on compilers written in this century.
  Don't treat function epilogues as function prologues by skipping
  additions to SP when searching for a function start.

- Add some comments to stack_capture() and fix some style bugs.

Reviewed by: arichardson
Obtained from: CheriBSD
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D27358
sys/mips/mips/stack_machdep.c