Description
In ARM architecture, MPU-based stack protection works, briefly, as follows:
- a Guard area at the bottom of supervisor thread is given Read-Only access
- thread stack overflow eventually attempts to push into the guard, triggering an MPU fault (Data Access Violation)
- the MPU fault triggers the MemManage exception, which leads to, a synchronous MPU stacking error, since the MemManage exception attempts to stack an exception stack frame.
When building without FLOAT, the length of the exception frame is 8 words, which matches exactly the length of the guard. Therefore, no stack corruption in the area beyond the stack can occur due to a thread stack overflow.
However, when building with CONFIG_FLOAT the FP context may be active at the time of a stack overflow. The MemManage exception will attempt to stack an "extended" exception frame that includes the FP-context (18 additional words).
In that scenario we still get a MemManage Stacking Error (Note: when Lazy-Stacking is disabled, which, currently, is the default) but the area beyond the end of the guard area is corrupted!
Therefore, we need larger Guard areas when building with FLOAT to prevent stack corruption.