Re: DRAM data persistence
- From: Jan Panteltje <pNaonStpealmtje@xxxxxxxxx>
- Date: Fri, 06 Jul 2007 14:20:20 GMT
On a sunny day (Fri, 06 Jul 2007 14:34:49 +0100) it happened Iwo Mergler
<Iwo.Mergler@xxxxxxxxxxxxxxxxxxxx> wrote in
<p0t1m4-r6j.ln1@xxxxxxxxxxxxxxxxxxxxxxxxxx>:
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...
That sure is an interesting recursive code :-)
Had to look several times before I understood it.
Yes, it seems you are right, I get all zeros too with it.
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.
Well, there is much talk about buffer overflows, where
the stack for example is used to execute code.
Some picture viewers and even some media players were
(or are?) affected.
Kind regards,
Iwo
Good info, thank you.
Why make so much trouble to read memory, just break in as root[kit or is it kid ;-)]:
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int a, i;
FILE *fptr;
fptr = fopen("/proc/kcore", "r");
if(! fptr)
{
fprintf(stderr, "test3: could not open /proc/kcore for read, aborting.\n");
exit(1);
}
for(i = 0; i < 1000; i++)
{
a = fgetc(fptr);
fprintf(stdout, "%02x ", a);
}
exit(0);
} /* end function main */
Right?
.
- Follow-Ups:
- Re: DRAM data persistence
- From: Iwo Mergler
- 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
- Re: DRAM data persistence
- From: Iwo Mergler
- DRAM data persistence
- Prev by Date: Choosing microprocessor for alarm system
- Next by Date: Re: Reducing EMI
- Previous by thread: Re: DRAM data persistence
- Next by thread: Re: DRAM data persistence
- Index(es):
Relevant Pages
|