Skip to content

Commit 2404269

Browse files
thgarnieKAGA-KOKO
authored andcommitted
Revert "arm/syscalls: Check address limit on user-mode return"
This reverts commit 73ac5d6. The work pending loop can call set_fs after addr_limit_user_check removed the _TIF_FSCHECK flag. This may happen at anytime based on how ARM handles alignment exceptions. It leads to an infinite loop condition. After discussion, it has been agreed that the generic approach is not tailored to the ARM architecture and any fix might not be complete. This patch will be replaced by an architecture specific implementation. The work flag approach will be kept for other architectures. Reported-by: Leonard Crestez <[email protected]> Signed-off-by: Thomas Garnier <[email protected]> Signed-off-by: Kees Cook <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Cc: Pratyush Anand <[email protected]> Cc: Dave Martin <[email protected]> Cc: Will Drewry <[email protected]> Cc: Arnd Bergmann <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Will Deacon <[email protected]> Cc: Russell King <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: David Howells <[email protected]> Cc: Dave Hansen <[email protected]> Cc: Al Viro <[email protected]> Cc: [email protected] Cc: Yonghong Song <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected]
1 parent bf29ed1 commit 2404269

File tree

4 files changed

+8
-23
lines changed

4 files changed

+8
-23
lines changed

arch/arm/include/asm/thread_info.h

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,10 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
139139
#define TIF_NEED_RESCHED 1 /* rescheduling necessary */
140140
#define TIF_NOTIFY_RESUME 2 /* callback before returning to user */
141141
#define TIF_UPROBE 3 /* breakpointed or singlestepping */
142-
#define TIF_FSCHECK 4 /* Check FS is USER_DS on return */
143-
#define TIF_SYSCALL_TRACE 5 /* syscall trace active */
144-
#define TIF_SYSCALL_AUDIT 6 /* syscall auditing active */
145-
#define TIF_SYSCALL_TRACEPOINT 7 /* syscall tracepoint instrumentation */
146-
#define TIF_SECCOMP 8 /* seccomp syscall filtering active */
142+
#define TIF_SYSCALL_TRACE 4 /* syscall trace active */
143+
#define TIF_SYSCALL_AUDIT 5 /* syscall auditing active */
144+
#define TIF_SYSCALL_TRACEPOINT 6 /* syscall tracepoint instrumentation */
145+
#define TIF_SECCOMP 7 /* seccomp syscall filtering active */
147146

148147
#define TIF_NOHZ 12 /* in adaptive nohz mode */
149148
#define TIF_USING_IWMMXT 17
@@ -154,7 +153,6 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
154153
#define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
155154
#define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
156155
#define _TIF_UPROBE (1 << TIF_UPROBE)
157-
#define _TIF_FSCHECK (1 << TIF_FSCHECK)
158156
#define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
159157
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
160158
#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
@@ -168,9 +166,8 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
168166
/*
169167
* Change these and you break ASM code in entry-common.S
170168
*/
171-
#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
172-
_TIF_NOTIFY_RESUME | _TIF_UPROBE | \
173-
_TIF_FSCHECK)
169+
#define _TIF_WORK_MASK (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
170+
_TIF_NOTIFY_RESUME | _TIF_UPROBE)
174171

175172
#endif /* __KERNEL__ */
176173
#endif /* __ASM_ARM_THREAD_INFO_H */

arch/arm/include/asm/uaccess.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ static inline void set_fs(mm_segment_t fs)
7070
{
7171
current_thread_info()->addr_limit = fs;
7272
modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
73-
/* On user-mode return, check fs is correct */
74-
set_thread_flag(TIF_FSCHECK);
7573
}
7674

7775
#define segment_eq(a, b) ((a) == (b))

arch/arm/kernel/entry-common.S

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ ret_fast_syscall:
4949
UNWIND(.cantunwind )
5050
disable_irq_notrace @ disable interrupts
5151
ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing
52-
tst r1, #_TIF_SYSCALL_WORK
53-
bne fast_work_pending
54-
tst r1, #_TIF_WORK_MASK
52+
tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
5553
bne fast_work_pending
5654

5755
/* perform architecture specific actions before user return */
@@ -77,15 +75,12 @@ ret_fast_syscall:
7775
str r0, [sp, #S_R0 + S_OFF]! @ save returned r0
7876
disable_irq_notrace @ disable interrupts
7977
ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing
80-
tst r1, #_TIF_SYSCALL_WORK
81-
bne fast_work_pending
82-
tst r1, #_TIF_WORK_MASK
78+
tst r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
8379
beq no_work_pending
8480
UNWIND(.fnend )
8581
ENDPROC(ret_fast_syscall)
8682

8783
/* Slower path - fall through to work_pending */
88-
fast_work_pending:
8984
#endif
9085

9186
tst r1, #_TIF_SYSCALL_WORK

arch/arm/kernel/signal.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <linux/uaccess.h>
1515
#include <linux/tracehook.h>
1616
#include <linux/uprobes.h>
17-
#include <linux/syscalls.h>
1817

1918
#include <asm/elf.h>
2019
#include <asm/cacheflush.h>
@@ -614,10 +613,6 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
614613
* Update the trace code with the current status.
615614
*/
616615
trace_hardirqs_off();
617-
618-
/* Check valid user FS if needed */
619-
addr_limit_user_check();
620-
621616
do {
622617
if (likely(thread_flags & _TIF_NEED_RESCHED)) {
623618
schedule();

0 commit comments

Comments
 (0)