This program accesses the memory below the stack.
I would suggest getting segfault or just nulwhen exiting stack restrictions, but I can see the actual data. (It is assumed that 100kb below the stack pointer is outside the boundaries of the stack)
Or does the system really allow me to see the memory below the stack? Shouldn't there be kernel level protection from this, or does this only apply to allocated memory?
Edit: With a 1024*127lower char pointer, it randomly executes segfaults or starts, so the stack is not fixed 8 MB, and it seems to be a little coincidental too.
#include <stdio.h>
int main(){
char * x;
int a;
for( x = (char *)&x-1024*127; x<(char *)(&x+1); x++){
a = *x & 0xFF;
printf("%p = 0x%02x\n",x,a);
}
}
: . segfaults 1024*127, f , segfault, (All 0x00):
#include <stdio.h>
int main(){
char * x;
int a;
for( x = (char *)(&x); x>(char *)&x-1024*1024; x--){
a = *x & 0xFF;
printf("%p = 0x%02x\n",x,a);
}
}