From patchwork Fri Apr 8 02:52:53 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 935 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:47:32 -0000 Delivered-To: patches@linaro.org Received: by 10.68.52.132 with SMTP id t4cs134021pbo; Thu, 7 Apr 2011 19:52:56 -0700 (PDT) Received: by 10.224.76.9 with SMTP id a9mr1334836qak.7.1302231175903; Thu, 07 Apr 2011 19:52:55 -0700 (PDT) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by mx.google.com with ESMTP id p13si4467344qcu.94.2011.04.07.19.52.54; Thu, 07 Apr 2011 19:52:54 -0700 (PDT) Received-SPF: neutral (google.com: 24.201.245.36 is neither permitted nor denied by best guess record for domain of nico@fluxnic.net) client-ip=24.201.245.36; Authentication-Results: mx.google.com; spf=neutral (google.com: 24.201.245.36 is neither permitted nor denied by best guess record for domain of nico@fluxnic.net) smtp.mail=nico@fluxnic.net MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: TEXT/PLAIN; charset=US-ASCII Received: from xanadu.home ([66.130.28.92]) by vl-mh-mrz21.ip.videotron.ca (Sun Java(tm) System Messaging Server 6.3-8.01 (built Dec 16 2008; 32bit)) with ESMTP id <0LJB00GWIBZASV90@vl-mh-mrz21.ip.videotron.ca> for patches@linaro.org; Thu, 07 Apr 2011 22:52:22 -0400 (EDT) Date: Thu, 07 Apr 2011 22:52:53 -0400 (EDT) From: Nicolas Pitre X-X-Sender: nico@xanadu.home To: linux-arm-kernel@lists.infradead.org Cc: patches@linaro.org Subject: [PATCH 2/2] ARM: fix personality flag propagation across an exec Message-id: User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) Our SET_PERSONALITY() implementation was overwriting all existing personality flags, including ADDR_NO_RANDOMIZE, making them unavailable to processes being exec'd after a call to personality() in user space. This prevents the gdb test suite from running successfully. Signed-off-by: Nicolas Pitre --- arch/arm/kernel/elf.c | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/arch/arm/kernel/elf.c b/arch/arm/kernel/elf.c index d4a0da1..8524d09 100644 --- a/arch/arm/kernel/elf.c +++ b/arch/arm/kernel/elf.c @@ -40,16 +40,23 @@ EXPORT_SYMBOL(elf_check_arch); void elf_set_personality(const struct elf32_hdr *x) { unsigned int eflags = x->e_flags; - unsigned int personality = PER_LINUX_32BIT; + unsigned int personality = current->personality; /* + * Inherit most personality flags from parent, except for those + * we're about to choose. Beware: PER_LINUX_32BIT carries flag bits + * outside of PER_MASK. + */ + personality &= ~(PER_MASK | PER_LINUX | PER_LINUX_32BIT); + + /* * APCS-26 is only valid for OABI executables */ - if ((eflags & EF_ARM_EABI_MASK) == EF_ARM_EABI_UNKNOWN) { - if (eflags & EF_ARM_APCS_26) - personality = PER_LINUX; - } - + if ((eflags & EF_ARM_EABI_MASK) == EF_ARM_EABI_UNKNOWN && + (eflags & EF_ARM_APCS_26)) + personality |= PER_LINUX; + else + personality |= PER_LINUX_32BIT; set_personality(personality); /*