Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c51e67b authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'x86-syscall-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull syscall updates from Ingo Molnar:
 "Improve the security of set_fs(): we now check the address limit on a
  number of key platforms (x86, arm, arm64) before returning to
  user-space - without adding overhead to the typical system call fast
  path"

* 'x86-syscall-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  arm64/syscalls: Check address limit on user-mode return
  arm/syscalls: Check address limit on user-mode return
  x86/syscalls: Check address limit on user-mode return
parents e0a195b5 cf7de27a
Loading
Loading
Loading
Loading
+9 −6
Original line number Diff line number Diff line
@@ -139,10 +139,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
#define TIF_NEED_RESCHED	1	/* rescheduling necessary */
#define TIF_NOTIFY_RESUME	2	/* callback before returning to user */
#define TIF_UPROBE		3	/* breakpointed or singlestepping */
#define TIF_SYSCALL_TRACE	4	/* syscall trace active */
#define TIF_SYSCALL_AUDIT	5	/* syscall auditing active */
#define TIF_SYSCALL_TRACEPOINT	6	/* syscall tracepoint instrumentation */
#define TIF_SECCOMP		7	/* seccomp syscall filtering active */
#define TIF_FSCHECK		4	/* Check FS is USER_DS on return */
#define TIF_SYSCALL_TRACE	5	/* syscall trace active */
#define TIF_SYSCALL_AUDIT	6	/* syscall auditing active */
#define TIF_SYSCALL_TRACEPOINT	7	/* syscall tracepoint instrumentation */
#define TIF_SECCOMP		8	/* seccomp syscall filtering active */

#define TIF_NOHZ		12	/* in adaptive nohz mode */
#define TIF_USING_IWMMXT	17
@@ -153,6 +154,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
#define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
#define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
#define _TIF_UPROBE		(1 << TIF_UPROBE)
#define _TIF_FSCHECK		(1 << TIF_FSCHECK)
#define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
#define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
#define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
@@ -167,7 +169,8 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
 * Change these and you break ASM code in entry-common.S
 */
#define _TIF_WORK_MASK		(_TIF_NEED_RESCHED | _TIF_SIGPENDING |	\
				 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
				 _TIF_NOTIFY_RESUME | _TIF_UPROBE |	\
				 _TIF_FSCHECK)

#endif /* __KERNEL__ */
#endif /* __ASM_ARM_THREAD_INFO_H */
+2 −0
Original line number Diff line number Diff line
@@ -70,6 +70,8 @@ static inline void set_fs(mm_segment_t fs)
{
	current_thread_info()->addr_limit = fs;
	modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
	/* On user-mode return, check fs is correct */
	set_thread_flag(TIF_FSCHECK);
}

#define segment_eq(a, b)	((a) == (b))
+7 −2
Original line number Diff line number Diff line
@@ -41,7 +41,9 @@ ret_fast_syscall:
 UNWIND(.cantunwind	)
	disable_irq_notrace			@ disable interrupts
	ldr	r1, [tsk, #TI_FLAGS]		@ re-check for syscall tracing
	tst	r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
	tst	r1, #_TIF_SYSCALL_WORK
	bne	fast_work_pending
	tst	r1, #_TIF_WORK_MASK
	bne	fast_work_pending

	/* perform architecture specific actions before user return */
@@ -67,12 +69,15 @@ ret_fast_syscall:
	str	r0, [sp, #S_R0 + S_OFF]!	@ save returned r0
	disable_irq_notrace			@ disable interrupts
	ldr	r1, [tsk, #TI_FLAGS]		@ re-check for syscall tracing
	tst	r1, #_TIF_SYSCALL_WORK | _TIF_WORK_MASK
	tst	r1, #_TIF_SYSCALL_WORK
	bne	fast_work_pending
	tst	r1, #_TIF_WORK_MASK
	beq	no_work_pending
 UNWIND(.fnend		)
ENDPROC(ret_fast_syscall)

	/* Slower path - fall through to work_pending */
fast_work_pending:
#endif

	tst	r1, #_TIF_SYSCALL_WORK
+5 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@
#include <linux/uaccess.h>
#include <linux/tracehook.h>
#include <linux/uprobes.h>
#include <linux/syscalls.h>

#include <asm/elf.h>
#include <asm/cacheflush.h>
@@ -613,6 +614,10 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
	 * Update the trace code with the current status.
	 */
	trace_hardirqs_off();

	/* Check valid user FS if needed */
	addr_limit_user_check();

	do {
		if (likely(thread_flags & _TIF_NEED_RESCHED)) {
			schedule();
+3 −1
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ struct thread_info {
#define TIF_NOTIFY_RESUME	2	/* callback before returning to user */
#define TIF_FOREIGN_FPSTATE	3	/* CPU's FP state is not current's */
#define TIF_UPROBE		4	/* uprobe breakpoint or singlestep */
#define TIF_FSCHECK		5	/* Check FS is USER_DS on return */
#define TIF_NOHZ		7
#define TIF_SYSCALL_TRACE	8
#define TIF_SYSCALL_AUDIT	9
@@ -107,11 +108,12 @@ struct thread_info {
#define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
#define _TIF_SECCOMP		(1 << TIF_SECCOMP)
#define _TIF_UPROBE		(1 << TIF_UPROBE)
#define _TIF_FSCHECK		(1 << TIF_FSCHECK)
#define _TIF_32BIT		(1 << TIF_32BIT)

#define _TIF_WORK_MASK		(_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
				 _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE | \
				 _TIF_UPROBE)
				 _TIF_UPROBE | _TIF_FSCHECK)

#define _TIF_SYSCALL_WORK	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
				 _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
Loading