]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
arm/unwind: Check stack pointer boundaries before dereferencing
authorMark Johnston <markj@FreeBSD.org>
Thu, 27 Jul 2023 19:44:00 +0000 (15:44 -0400)
committerMark Johnston <markj@FreeBSD.org>
Thu, 27 Jul 2023 19:44:00 +0000 (15:44 -0400)
commit1be56e0bb1e8bd8373e446ff9386bcdd764935aa
treec7201638cf8a1f7e6b1b845409cc1bf5398c66fa
parent81a7ce44047f02049760d70c0cdc74c2751e9bad
arm/unwind: Check stack pointer boundaries before dereferencing

If the unwinder somehow ends up with a stack pointer that lies outside
the stack, then an attempt to dereference can lead to a fault, which
causes the kernel to panic again and unwind the stack, which leads to a
fault...

Add kstack_contains() checks at points where we dereference the stack
pointer.  This avoids the aforementioned infinite loop in one case I hit
where some OpenSSL assembly code apparently confuses the unwinder.

Reviewed by: jhb
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D41210
sys/arm/arm/unwind.c