linux-mips
[Top] [All Lists]

Re: [RFC] User stack pointer randomisation

To: Franck <vagabon.xyz@gmail.com>
Subject: Re: [RFC] User stack pointer randomisation
From: Nigel Stephens <nigel@mips.com>
Date: Thu, 19 Jul 2007 10:43:03 +0100
Cc: Ralf Baechle <ralf@linux-mips.org>, linux-mips <linux-mips@linux-mips.org>
In-reply-to: <469F0E5F.4050005@innova-card.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <469F0E5F.4050005@innova-card.com>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Thunderbird 2.0.0.4 (Windows/20070604)


Franck Bui-Huu wrote:
+/*
+ * Don't forget that the stack pointer must be aligned on a 8 bytes
+ * boundary at least.
+ */
+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 & ~7;
+}

For the 64-bit ABIs (N32 & N64) the stack must be 16 byte aligned.

Nigel


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