[libunwind] Check corrupted return address in unwind_phase2 when CET is enabled.
authorjinge90 <ge.jin@intel.com>
Wed, 9 Nov 2022 06:24:39 +0000 (14:24 +0800)
committerjinge90 <ge.jin@intel.com>
Wed, 9 Nov 2022 06:27:07 +0000 (14:27 +0800)
commit4db687155bc12f31b5ed122ba1086c5f04838a24
treec9a7bff3e0504a71130598753a19c5dd5ee6b24f
parentb17b25dde0693adb157f779b069cf89095446db8
[libunwind] Check corrupted return address in unwind_phase2 when CET is enabled.

If CET shadow stack is enabled, we count the number of stack frames skipped
and adjust CET shadow stack based on the number in libunwind unwind_phase2.
At the same time, we can enhance security via comparing the return address in
normal stack against counterpart in CET shadow stack, if they don't match,
it means the return address stored in normal stack has been corrupted and we
will return _URC_FATAL_PHASE2_ERROR in that case.

Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D136667

Signed-off-by: jinge90 <ge.jin@intel.com>
libunwind/src/UnwindLevel1.c