From patchwork Wed Apr 13 03:59:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 992 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:48:05 -0000 Delivered-To: patches@linaro.org Received: by 10.68.59.138 with SMTP id z10cs267791pbq; Tue, 12 Apr 2011 20:59:40 -0700 (PDT) Received: by 10.52.71.97 with SMTP id t1mr500486vdu.246.1302667180192; Tue, 12 Apr 2011 20:59:40 -0700 (PDT) Received: from mail-vx0-f178.google.com ([209.85.220.178]) by mx.google.com with ESMTPS id ez9si99447vbb.52.2011.04.12.20.59.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Apr 2011 20:59:39 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of nicolas.pitre@linaro.org) client-ip=209.85.220.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of nicolas.pitre@linaro.org) smtp.mail=nicolas.pitre@linaro.org Received: by vxc11 with SMTP id 11so214685vxc.37 for ; Tue, 12 Apr 2011 20:59:38 -0700 (PDT) Received: by 10.220.101.92 with SMTP id b28mr2142425vco.25.1302667178466; Tue, 12 Apr 2011 20:59:38 -0700 (PDT) Received: from xanadu.home (modemcable092.28-130-66.mc.videotron.ca [66.130.28.92]) by mx.google.com with ESMTPS id u10sm31923vcr.25.2011.04.12.20.59.37 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 12 Apr 2011 20:59:37 -0700 (PDT) Date: Tue, 12 Apr 2011 23:59:36 -0400 (EDT) From: Nicolas Pitre X-X-Sender: nico@xanadu.home To: patches@arm.linux.org.uk cc: patches@linaro.org Subject: fix personality flag propagation across an exec Message-ID: User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 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 PATCH FOLLOWS KernelVersion: v2.6.39-rc1 diff --git a/arch/arm/kernel/elf.c b/arch/arm/kernel/elf.c index d4a0da1..9b05c6a 100644 --- a/arch/arm/kernel/elf.c +++ b/arch/arm/kernel/elf.c @@ -40,15 +40,22 @@ 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 & ~PER_MASK; + + /* + * We only support Linux ELF executables, so always set the + * personality to LINUX. + */ + personality |= PER_LINUX; /* * 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 &= ~ADDR_LIMIT_32BIT; + else + personality |= ADDR_LIMIT_32BIT; set_personality(personality);