Dump stack if memwipe() check fails
This commit is contained in:
@@ -150,13 +150,23 @@ static bool equals(char *a, char *b)
|
|||||||
return streq(a, b);
|
return streq(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of words we write and memwipe() in memwipe check
|
||||||
|
*/
|
||||||
|
#define MEMWIPE_WIPE_WORDS 16
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of words we check stack for memwiped magic
|
||||||
|
*/
|
||||||
|
#define MEMWIPE_CHECK_WORDS (MEMWIPE_WIPE_WORDS * 2)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write magic to memory, and try to clear it with memwipe()
|
* Write magic to memory, and try to clear it with memwipe()
|
||||||
*/
|
*/
|
||||||
__attribute__((noinline))
|
__attribute__((noinline))
|
||||||
static void do_magic(int magic, int **stack)
|
static void do_magic(int magic, int **stack)
|
||||||
{
|
{
|
||||||
int buf[32], i;
|
int buf[MEMWIPE_WIPE_WORDS], i;
|
||||||
|
|
||||||
/* tell caller where callee stack is (but don't point to buf) */
|
/* tell caller where callee stack is (but don't point to buf) */
|
||||||
*stack = &i;
|
*stack = &i;
|
||||||
@@ -184,11 +194,18 @@ static bool check_memwipe()
|
|||||||
{ /* stack grows down */
|
{ /* stack grows down */
|
||||||
stackdir = -1;
|
stackdir = -1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < 128; i++)
|
for (i = 0; i < MEMWIPE_CHECK_WORDS; i++)
|
||||||
{
|
{
|
||||||
ptr = ptr + stackdir;
|
ptr = ptr + stackdir;
|
||||||
if (*ptr == magic)
|
if (*ptr == magic)
|
||||||
{
|
{
|
||||||
|
ptr = &magic + stackdir;
|
||||||
|
if (stackdir == -1)
|
||||||
|
{
|
||||||
|
ptr -= MEMWIPE_CHECK_WORDS;
|
||||||
|
}
|
||||||
|
DBG1(DBG_LIB, "memwipe() check failed: stackdir: %d %b",
|
||||||
|
stackdir, ptr, (u_int)(MEMWIPE_CHECK_WORDS * sizeof(int)));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -268,7 +285,6 @@ bool library_init(char *settings)
|
|||||||
|
|
||||||
if (!check_memwipe())
|
if (!check_memwipe())
|
||||||
{
|
{
|
||||||
DBG1(DBG_LIB, "memwipe() check failed");
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user