linux-mips
[Top] [All Lists]

Re: [PATCH] User stack pointer randomisation

To: franck.bui-huu@innova-card.com
Subject: Re: [PATCH] User stack pointer randomisation
From: Nigel Stephens <nigel@mips.com>
Date: Thu, 19 Jul 2007 13:20:46 +0100
Cc: Ralf Baechle <ralf@linux-mips.org>, linux-mips <linux-mips@linux-mips.org>
In-reply-to: <469F5345.5010209@innova-card.com>
Organization: MIPS Technologies
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <469F5345.5010209@innova-card.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Thunderbird 1.5.0.2 (X11/20060501)

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

<Prev in Thread] Current Thread [Next in Thread>