Re: [PATCH] User stack pointer randomisation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Franck Bui-Huu wrote:
> +/*
> + * Don't forget that the stack pointer must be aligned on a 8 bytes
> + * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
> + */
> +unsigned long arch_align_stack(unsigned long sp)
> +{
> +	if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
> +		sp -= get_random_int() & ~PAGE_MASK;
> +
> +	return sp & ALMASK;
> +}
>   

Hmm, the kernel isn't necessarily built using the same ABI as
applications. While this will in fact do the right thing for O32 apps
running on 64-bit kernels, it's kind of by accident, and suggests some
equivalence which isn't really there. Would it be better to force 16
byte alignment (the maximum alignment required by any ABI) in all cases,
rather than relying on the kernel's ALMASK being correct for user
applications? Just a thought.

Nigel


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux