From 3dd56a70e2dd5646db6412dd934b73ecc45f2bef Mon Sep 17 00:00:00 2001
From: Mickael Guene <mickael.guene@st.com>
Date: Fri, 29 May 2015 09:41:21 +0200
Subject: [PATCH 5/5] fdpic: Workaround to fix futex bug on mmu less
See https://bugzilla.kernel.org/show_bug.cgi?id=78881 for description
and test case.
Change-Id: Id87f5aaceabc4226143b146a9613b37eedec22f1
Signed-off-by: Mickael Guene <mickael.guene@st.com>
---
arch/arm/kernel/signal.c | 14 +-------------
arch/arm/kernel/traps.c | 2 +-
fs/binfmt_elf_fdpic.c | 6 +++---
kernel/futex.c | 4 ++++
4 files changed, 9 insertions(+), 17 deletions(-)
@@ -53,19 +53,7 @@ const unsigned long sigreturn_fdpic__thumb_codes[3] = {
0xf000f8dc /* ldr pc, [r12] to jump into restorer */
};
-/*
- * For Thumb syscalls, we pass the syscall number via r7. We therefore
- * need two 16-bit instructions.
- */
-#define SWI_THUMB_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_sigreturn - __NR_SYSCALL_BASE))
-#define SWI_THUMB_RT_SIGRETURN (0xdf00 << 16 | 0x2700 | (__NR_rt_sigreturn - __NR_SYSCALL_BASE))
-
-static const unsigned long sigreturn_codes[7] = {
- MOV_R7_NR_SIGRETURN, SWI_SYS_SIGRETURN, SWI_THUMB_SIGRETURN,
- MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
-};
-
-static unsigned long signal_return_offset;
+unsigned long signal_return_offset;
#ifdef CONFIG_CRUNCH
static int preserve_crunch_context(struct crunch_sigframe __user *frame)
@@ -626,7 +626,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
return 0;
case NR(get_tls):
- return thread->tp_value[0];
+ return current_thread_info()->tp_value[0];
default:
/* Calls 9f00xx..9f07ff are defined to return -ENOSYS
@@ -349,7 +349,7 @@ static int load_elf_fdpic_binary(struct linux_binprm *bprm)
* error_kill */
/* TODO : call SET_PERSONALITY is certainly better .... */
set_personality(PER_LINUX_FDPIC | PER_LINUX_32BIT);
- if (elf_read_implies_exec(&exec_params.hdr, executable_stack))
+ if (elf_read_implies_exec(exec_params.hdr, executable_stack))
current->personality |= READ_IMPLIES_EXEC;
setup_new_exec(bprm);
@@ -813,8 +813,8 @@ static int elf_fdpic_map_file(struct elf_fdpic_params *params,
if (params->hdr.e_entry >= seg->p_vaddr &&
params->hdr.e_entry < seg->p_vaddr + seg->p_memsz) {
params->entry_addr =
- (params->hdr.e_entry - seg->p_vaddr) +
- seg->addr;
+ ((params->hdr.e_entry - seg->p_vaddr) +
+ seg->addr) | 1;
break;
}
}
@@ -494,12 +494,16 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
* Note : We do have to check 'uaddr' is a valid user address,
* but access_ok() should be faster than find_vma()
*/
+#if defined(CONFIG_MMU)
if (!fshared) {
+#endif
key->private.mm = mm;
key->private.address = address;
get_futex_key_refs(key); /* implies MB (B) */
return 0;
+#if defined(CONFIG_MMU)
}
+#endif
again:
/* Ignore any VERIFY_READ mapping (futex common case) */
--
1.9.1