ASLR Entropy Bits for Stack on Linux

Viewed 2358

I am looking at a presentation from MIT where they explain different types of ASLR implementations.

For example, they point out that for static ASLR, stack has 19-bits of entropy. In my understanding, this means the stack base address can only be randomized to take 2^19 different values.

I want to ask how to calculate that the stack has 19-bits of entropy ?

Edit:

After checking online, I found some explanation of stack ASLR on Linux. Learning from another question, the code I thought may be relevant is:

#ifndef STACK_RND_MASK
#define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12))     /* 8MB of VA */
#endif

static unsigned long randomize_stack_top(unsigned long stack_top)
{
    unsigned int random_variable = 0;

    if ((current->flags & PF_RANDOMIZE) &&
            !(current->personality & ADDR_NO_RANDOMIZE)) {
            random_variable = get_random_int() & STACK_RND_MASK;
            random_variable <<= PAGE_SHIFT;
    }
#ifdef CONFIG_STACK_GROWSUP
    return PAGE_ALIGN(stack_top) + random_variable;
#else
    return PAGE_ALIGN(stack_top) - random_variable;
#endif
}

I want to ask if this is the right place to reason about my question ?

1 Answers
Related