summaryrefslogtreecommitdiff
path: root/firmware/thread.c
diff options
context:
space:
mode:
authorMarcin Bukat <marcin.bukat@gmail.com>2014-01-09 21:37:07 +0100
committerMarcin Bukat <marcin.bukat@gmail.com>2014-01-16 10:17:39 +0100
commit7ab237b025cbb4c25d345604da32e894379c1721 (patch)
tree92d147029519c55d57db4273066d57b960ad7158 /firmware/thread.c
parent7f5dce4116bf4e62e0cd3ef16730157e17625e1c (diff)
downloadrockbox-7ab237b025cbb4c25d345604da32e894379c1721.tar.gz
rockbox-7ab237b025cbb4c25d345604da32e894379c1721.zip
buflib: Add crc field protecting buflib cookie integrity
This should catch the case of buffer misuse which results in corrupted cookie of next allocation. The check is performed on move_block() so it may be a bit late. There is buflib_check_valid() provided which checks the integrity of all cookies for given context. On DEBUG build with --sdl-thread this check is carried out for core_ctx on every context switch to catch problems earlier. Change-Id: I999d4576084592394e3dbd3bdf0f32935ff5f601 Reviewed-on: http://gerrit.rockbox.org/711 Reviewed-by: Thomas Martitz <kugel@rockbox.org>
Diffstat (limited to 'firmware/thread.c')
-rw-r--r--firmware/thread.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/firmware/thread.c b/firmware/thread.c
index ce9252ccc6..b687144f4f 100644
--- a/firmware/thread.c
+++ b/firmware/thread.c
@@ -39,6 +39,7 @@
39#ifdef RB_PROFILE 39#ifdef RB_PROFILE
40#include <profile.h> 40#include <profile.h>
41#endif 41#endif
42#include "core_alloc.h"
42#include "gcc_extensions.h" 43#include "gcc_extensions.h"
43 44
44/**************************************************************************** 45/****************************************************************************
@@ -1161,6 +1162,11 @@ void switch_thread(void)
1161 * to this call. */ 1162 * to this call. */
1162 store_context(&thread->context); 1163 store_context(&thread->context);
1163 1164
1165#ifdef DEBUG
1166 /* Check core_ctx buflib integrity */
1167 core_check_valid();
1168#endif
1169
1164 /* Check if the current thread stack is overflown */ 1170 /* Check if the current thread stack is overflown */
1165 if (UNLIKELY(thread->stack[0] != DEADBEEF) && thread->stack_size > 0) 1171 if (UNLIKELY(thread->stack[0] != DEADBEEF) && thread->stack_size > 0)
1166 thread_stkov(thread); 1172 thread_stkov(thread);