Page MenuHomeFreeBSD

Stack unwinding robustness fixes for RISC-V.
ClosedPublic

Authored by jhb on Nov 24 2020, 9:48 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 16 2024, 11:18 PM
Unknown Object (File)
Mar 16 2024, 11:17 PM
Unknown Object (File)
Mar 16 2024, 11:17 PM
Unknown Object (File)
Mar 16 2024, 11:17 PM
Unknown Object (File)
Mar 14 2024, 6:56 AM
Unknown Object (File)
Jan 1 2024, 10:14 PM
Unknown Object (File)
Dec 23 2023, 4:10 AM
Unknown Object (File)
Dec 23 2023, 4:10 AM
Subscribers

Details

Summary
  • Push the kstack_contains check down into unwind_frame() so that it is honored by DDB and DTrace.
  • Check that the trapframe for an exception frame is contained in the traced thread's kernel stack for DDB traces.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Nov 24 2020, 9:48 PM
jhb created this revision.
markj added inline comments.
sys/cddl/dev/dtrace/riscv/dtrace_isa.c
93 ↗(On Diff #79953)

This will have the same problem that @andrew mentioned in the arm64 review: nothing prevents one from enabling an FBT probe on unwind_frame().

sys/cddl/dev/dtrace/riscv/dtrace_isa.c
93 ↗(On Diff #79953)

The same is true of dtrace_getpcstack and all manner of other functions, surely? Play stupid games, win stupid prizes, and all that. But in an ideal world we'd tell you to go away if you tried that.

sys/cddl/dev/dtrace/riscv/dtrace_isa.c
93 ↗(On Diff #79953)

fbt_excluded() tries to exclude such cases. If you load DTrace as a set of kernel modules, as opposed to compiling it into the kernel, it is also smart enough to not create probes in its own kernel modules.

This works fine on amd64: you can reliably enable all FBT probes in the kernel. On other platforms I wouldn't trust it to work because of issues like this, but in general you're not supposed to be able to crash the system by enabling arbitrary probes.

  • Add unwind_frame to fbt_excluded
This revision was not accepted when it landed; it landed in state Needs Review.Dec 8 2020, 5:57 PM
This revision was automatically updated to reflect the committed changes.