Commit 8172df5f authored by Catalin Marinas's avatar Catalin Marinas

Do not check the PSR_F_BIT in valid_user_regs

When running Linux in non-secure mode (on ARM1176 for example),
depending on the CP15 secure configuration register, the CPSR.F bit
(6) might only be modified from the secure mode. However, the
valid_user_regs() function checks for this bit being cleared. With
commit a6c61e9d, a SIGSEGV is forced in handle_signal() if the user
registers are not considered valid.

The patch also ensures that the CPSR.A bit is cleared and the USR mode
is set if the CPU does not support the 26bit user mode.
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent a1300f06
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#ifndef __ASM_ARM_PTRACE_H #ifndef __ASM_ARM_PTRACE_H
#define __ASM_ARM_PTRACE_H #define __ASM_ARM_PTRACE_H
#include <asm/hwcap.h>
#define PTRACE_GETREGS 12 #define PTRACE_GETREGS 12
#define PTRACE_SETREGS 13 #define PTRACE_SETREGS 13
...@@ -49,6 +50,7 @@ ...@@ -49,6 +50,7 @@
#define PSR_T_BIT 0x00000020 #define PSR_T_BIT 0x00000020
#define PSR_F_BIT 0x00000040 #define PSR_F_BIT 0x00000040
#define PSR_I_BIT 0x00000080 #define PSR_I_BIT 0x00000080
#define PSR_A_BIT 0x00000100
#define PSR_J_BIT 0x01000000 #define PSR_J_BIT 0x01000000
#define PSR_Q_BIT 0x08000000 #define PSR_Q_BIT 0x08000000
#define PSR_V_BIT 0x10000000 #define PSR_V_BIT 0x10000000
...@@ -130,14 +132,17 @@ struct pt_regs { ...@@ -130,14 +132,17 @@ struct pt_regs {
*/ */
static inline int valid_user_regs(struct pt_regs *regs) static inline int valid_user_regs(struct pt_regs *regs)
{ {
if (user_mode(regs) && if (user_mode(regs) && (regs->ARM_cpsr & PSR_I_BIT) == 0) {
(regs->ARM_cpsr & (PSR_F_BIT|PSR_I_BIT)) == 0) regs->ARM_cpsr &= ~(PSR_F_BIT | PSR_A_BIT);
return 1; return 1;
}
/* /*
* Force CPSR to something logical... * Force CPSR to something logical...
*/ */
regs->ARM_cpsr &= PSR_f | PSR_s | PSR_x | PSR_T_BIT | MODE32_BIT; regs->ARM_cpsr &= PSR_f | PSR_s | (PSR_x & ~PSR_A_BIT) | PSR_T_BIT | MODE32_BIT;
if (!(elf_hwcap & HWCAP_26BIT))
regs->ARM_cpsr |= USR_MODE;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment