Where does the stack of each program begin in memory?
I understand that there is randomize address space option which will randomly choose an address. If the option is disabled, does each program start from the same address?
What if we open two terminals and run two programs concurrently; will the system use same beginning address for the stacks of the two programs (by overwriting the the previous program's stack and loading the current program's stack in the same location during context switch)?
What if I run a program by calling an exec()
-family function like in the following example; will there be different stack for this program and a different stack for "vulnerable" program? Or there will just be a different stack frame for vulnerable on top of the calling program's stack?
int main(int argc, char *argv[]) {
char *buff, *ptr;
int i;
bsize = atoi(argv[1]);
if (!(buff = malloc(bsize))) {
printf("Can't allocate memory.\n");
exit(0);
}
for (i = 0; i < bsize; i+=4)
buff[i] = '0';
execl("/home/amulya/Desktop/CMPE209/HWs/HW2/vulnerable","vulnerable", buff, NULL);
return(-1);
}