Re: DRAM data persistence
- From: Iwo Mergler <Iwo.Mergler@xxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 06 Jul 2007 14:34:49 +0100
Jan Panteltje wrote:
On a sunny day (Thu, 05 Jul 2007 18:29:27 GMT) it happened2c57f2b77cadf3b78f50000010b0f3b7c088e3b7000000008255f2b7ac8204081037f2b7cc51f2b700000000fc53f2b7000000008caff3b705
nico@xxxxxxxxxxx (Nico Coesel) wrote in
<468d36e1.1108693667@xxxxxxxxxxxxxx>:
I have just run the following program:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int a, i;
char *ptr;
char t[1000];
ptr = t;
for(i = 0; i < 1000; i++)
{
a = *ptr & 0xff;
fprintf(stdout, "%02x", a);
ptr++;
}
ptr = t;
for(i = 0; i < 1000; i++)
{
a = *ptr & 0xff;
fprintf(stdout, "%c", a);
ptr++;
}
exit(1);
} /* end function main */
Compiled like this:
gcc -o test test.c
Gives as result:
grml: ~ # ./test
etc etc...
So, pure DRAM, stack space...
And this is one of the latest Linux kernels:
grml: ~ # uname -a
Linux grml 2.6.21 #1 Sat May 5 17:08:45 CEST 2007 i686 GNU/Linux
gcc version 4.0.3 20060104
If you do the same with malloc() you get zeros only (as explained by an
otehr poster). Try it :-)
Hi Jan,
what you see are left over stack frames from the
C-library initialisation. If you extend the stack
into virgin territory you get the same zeros.
Try this:
#include <stdio.h>
void fun(int stage)
{
unsigned char b[1024];
if (stage>0)
fun(stage-1);
else
{
int i;
for (i=0; i<1024; i++)
{
printf("%02X",b[i]);
}
}
}
int main(void)
{
fun(1024);
return 0;
}
It grows the stack by slightly over 1MB and and
forces the mapping of new pages.
$ a.out
000000000000000000000000000000000000000000000000...
However, in both cases (malloc and automatic variables),
the space gets re-used by the runtime system. That is,
only the first ever malloc of a task contains zeros. If
you free that memory again, chances are that it gets
reused und you'll find you old content again in later
mallocs.
Linux protects tasks from each other and the kernel
from all of them. It is not considered a security
problem if a task leaks data to itself.
Kind regards,
Iwo
.
- Follow-Ups:
- Re: DRAM data persistence
- From: Jan Panteltje
- Re: DRAM data persistence
- References:
- DRAM data persistence
- From: Richard Henry
- Re: DRAM data persistence
- From: MooseFET
- Re: DRAM data persistence
- From: Nico Coesel
- Re: DRAM data persistence
- From: Jan Panteltje
- Re: DRAM data persistence
- From: Nico Coesel
- Re: DRAM data persistence
- From: Jan Panteltje
- Re: DRAM data persistence
- From: Nico Coesel
- Re: DRAM data persistence
- From: MooseFET
- Re: DRAM data persistence
- From: Nico Coesel
- Re: DRAM data persistence
- From: Jan Panteltje
- DRAM data persistence
- Prev by Date: Re: Global scaling theory
- Next by Date: Re: Reducing EMI
- Previous by thread: Re: DRAM data persistence
- Next by thread: Re: DRAM data persistence
- Index(es):
Relevant Pages
|