Patch "x86/entry/compat: Keep TS_COMPAT set during signal delivery" has been added to the 4.5-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
x86/entry/compat: Keep TS_COMPAT set during signal delivery
to the 4.5-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
x86-entry-compat-keep-ts_compat-set-during-signal-delivery.patch
and it can be found in the queue-4.5 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
4e79e182b419172e35936a47f098509092d69817Mon Sep 17 00:00:00 2001
From: Andy Lutomirski <[email protected]>
Date: Wed, 10 Feb 2016 14:15:27 -0800
Subject: x86/entry/compat: Keep TS_COMPAT set during signal delivery
From: Andy Lutomirski <[email protected]>
commit 4e79e182b419172e35936a47f098509092d69817 upstream.
Signal delivery needs to know the sign of an interrupted syscall's return value in order to detect -ERESTART variants. Normally this works independently of bitness because syscalls internally return long. Under ptrace, however, this can break, and syscall_get_error is supposed to sign-extend regs->ax if needed.
We were clearing TS_COMPAT too early, though, and this prevented sign extension, which subtly broke syscall restart under ptrace.
--- arch/x86/entry/common.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-)
arch/x86/entry/common.c +13 -10
@@ -268,6 +268,7 @@ static void exit_to_usermode_loop(struct/* Called with IRQs disabled. */ __visible inline void prepare_exit_to_usermode(struct pt_regs *regs) { +struct thread_info *ti =pt_regs_to_thread_info (regs);u32 cached_flags;if (IS_ENABLED (CONFIG_PROVE_LOCKING ) &&WARN_ON (!irqs_disabled ()))
@@ -275,12 +276,22 @@ __visible inline void prepare_exit_to_uslockdep_sys_exit (); - cached_flags = -READ_ONCE (pt_regs_to_thread_info (regs)->flags); + cached_flags =READ_ONCE (ti->flags);if (unlikely (cached_flags &EXIT_TO_USERMODE_LOOP_FLAGS ))exit_to_usermode_loop (regs, cached_flags); +#ifdef CONFIG_COMPAT +/* +* Compat syscalls set TS_COMPAT. Make sure we clear it before +* returning to user mode. We need to clear it *after* signal +* handling, because syscall restart has a fixup for compat +* syscalls. The fixup is exercised by the ptrace_syscall_32 +* selftest. +*/ + ti->status &= ~TS_COMPAT ; +#endif +user_enter (); }
@@ -332,14 +343,6 @@ __visible inline void syscall_return_sloif (unlikely (cached_flags &SYSCALL_EXIT_WORK_FLAGS ))syscall_slow_exit_work (regs, cached_flags); -#ifdef CONFIG_COMPAT -/* -* Compat syscalls set TS_COMPAT. Make sure we clear it before -* returning to user mode. -*/ - ti->status &= ~TS_COMPAT ; -#endif -local_irq_disable ();prepare_exit_to_usermode (regs); }
Patches currently in stable-queue which might be from [email protected] are
queue-4.5/x86-entry-compat-keep-ts_compat-set-during-signal-delivery.patch