From 7c4961e83c908ee9ba3f1fac08e2599e7beab4a8 Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Mon, 27 May 2019 20:51:27 -0700 Subject: [PATCH] Add basic canary check to BSSL stack thunk (#6156) On return from a BSSL call, check that the last element of the stack is still untouched. If it is modified, print an error and abort(). Will catch problems like #6143 many times with an informative error message instead of corrupting the heap and having a random crash sometime later. --- cores/esp8266/StackThunk.cpp | 9 ++++++++- cores/esp8266/StackThunk.h | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cores/esp8266/StackThunk.cpp b/cores/esp8266/StackThunk.cpp index fe2ffcd79..68e80278d 100644 --- a/cores/esp8266/StackThunk.cpp +++ b/cores/esp8266/StackThunk.cpp @@ -36,7 +36,7 @@ uint32_t *stack_thunk_top = NULL; uint32_t *stack_thunk_save = NULL; /* Saved A1 while in BearSSL */ uint32_t stack_thunk_refcnt = 0; -#define _stackSize (5750/4) +#define _stackSize (5748/4) #define _stackPaint 0xdeadbeef /* Add a reference, and allocate the stack if necessary */ @@ -124,4 +124,11 @@ void stack_thunk_dump_stack() ets_printf("<<