For exceptions where we are just going to abort the current thread, we need to exit handler mode properly so that PendSV can run and perform a context switch. For ARM architecture this means that the fatal error handling code path can indeed return if we were 1) in handler mode and 2) only wish to abort the current thread. Fixes a very long-standing bug where a thread that generates an exception, and should only abort the thread, instead takes down the entire system. Issue: ZEP-2052 Change-Id: Ib356a34a6fda2e0f8aff39c4b3270efceb81e54d Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
/*
|
|
* Copyright (c) 2012-2014 Wind River Systems, Inc.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @file
|
|
* @brief Compiler stack protection (kernel part)
|
|
*
|
|
* This module provides functions to support compiler stack protection
|
|
* using canaries. This feature is enabled with configuration
|
|
* CONFIG_STACK_CANARIES=y.
|
|
*
|
|
* When this feature is enabled, the compiler generated code refers to
|
|
* function __stack_chk_fail and global variable __stack_chk_guard.
|
|
*/
|
|
|
|
#include <toolchain.h> /* compiler specific configurations */
|
|
|
|
#include <kernel_structs.h>
|
|
#include <toolchain.h>
|
|
#include <sections.h>
|
|
|
|
/**
|
|
*
|
|
* @brief Stack canary error handler
|
|
*
|
|
* This function is invoked when a stack canary error is detected.
|
|
*
|
|
* @return Does not return
|
|
*/
|
|
void FUNC_NORETURN _StackCheckHandler(void)
|
|
{
|
|
/* Stack canary error is a software fatal condition; treat it as such.
|
|
*/
|
|
|
|
_NanoFatalErrorHandler(_NANO_ERR_STACK_CHK_FAIL, &_default_esf);
|
|
CODE_UNREACHABLE;
|
|
}
|
|
|
|
/* Global variable */
|
|
|
|
/*
|
|
* Symbol referenced by GCC compiler generated code for canary value.
|
|
* The canary value gets initialized in _Cstart().
|
|
*/
|
|
void __noinit *__stack_chk_guard;
|
|
|
|
/**
|
|
*
|
|
* @brief Referenced by GCC compiler generated code
|
|
*
|
|
* This routine is invoked when a stack canary error is detected, indicating
|
|
* a buffer overflow or stack corruption problem.
|
|
*/
|
|
FUNC_ALIAS(_StackCheckHandler, __stack_chk_fail, void);
|