Page MenuHomeFreeBSD

Tighten checks in the x86 stack unwinder.
ClosedPublic

Authored by markj on Aug 2 2018, 8:49 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 11 2023, 12:26 PM
Unknown Object (File)
Nov 9 2023, 2:30 PM
Unknown Object (File)
Nov 4 2023, 2:42 PM
Unknown Object (File)
Oct 10 2023, 11:28 AM
Unknown Object (File)
Oct 8 2023, 1:22 PM
Unknown Object (File)
Oct 3 2023, 2:39 PM
Unknown Object (File)
Sep 29 2023, 2:40 PM
Unknown Object (File)
Sep 22 2023, 10:12 AM
Subscribers

Details

Summary

With the 4/4 split on i386, INKERNEL is always true, and so we do no
validation of the first frame pointer. This pointer will be NULL for a
thread that has been created but was never scheduled, so procstat -kka
reliably panics on i386. Fix the problem by reordering some checks in
the unwind loop: ensure that each frame pointer, including the first,
lies within the bounds of the kernel stack.

Diff Detail

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

Event Timeline

This revision is now accepted and ready to land.Aug 3 2018, 12:04 AM
This revision was automatically updated to reflect the committed changes.

Thanks!

Prior to this change, we could also take a second trap if the traced code used %rbp for a kernel pointer other than a framepointer. E.g., we have some proprietary assembly libraries that (ab)use rbp in this way.

Would it be possible to impose similar stricter requirements on callpc in an inexpensive way? The difficulty is loadable modules, I guess.

In D16572#460051, @cem wrote:

Thanks!

Prior to this change, we could also take a second trap if the traced code used %rbp for a kernel pointer other than a framepointer. E.g., we have some proprietary assembly libraries that (ab)use rbp in this way.

Would it be possible to impose similar stricter requirements on callpc in an inexpensive way? The difficulty is loadable modules, I guess.

On amd64 we require all kernel and module text to live in the last 2GB of KVA, so we could check that.