x86: vm86 fix and test
cover x86: vm86 fix and test
Calling vm86 and then forking will corrupt things. Fix it.
This is for x86/urgent. It fixes a 4.3 regression.
Andy Lutomirski (2):
selftests/x86: Add a fork() to entry_from_vm86 to catch fork bugs x86/vm86: Set thread.vm86 to NULL on fork/clone
arch/x86/kernel/process.c | 3 +++ tools/testing/selftests/x86/entry_from_vm86.c | 4 ++++ 2 files changed, 7 insertions(+)
Signature · 1 line
2.4.3
PATCH 1/2 selftests/x86: Add a fork() to entry_from_vm86 to catch fork bugs
Mere possession of vm86 state is strange. Make sure that nothing gets corrupted if we fork after calling vm86().
--- tools/testing/selftests/x86/entry_from_vm86.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/x86/entry_from_vm86.c +4 -0
@@ -229,5 +229,9 @@ int main(void) }clearhandler (SIGSEGV ); +/* Make sure nothing explodes if we fork. */ +if (fork () >0 ) +return 0 ; +return (nerrs ==0 ?0 :1 ); }
Signature · 1 line
2.4.3
PATCH 2/2 x86/vm86: Set thread.vm86 to NULL on fork/clone
In reply to Andy Lutomirskithread.vm86 points to per-task information -- the pointer should not be copied on clone.
--- arch/x86/kernel/process.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kernel/process.c +3 -0
@@ -83,6 +83,9 @@ EXPORT_SYMBOL_GPL(idle_notifier_unregister);int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src) {memcpy (dst, src, arch_task_struct_size); +#ifdef CONFIG_VM86 + dst->thread.vm86 =NULL ; +#endif return fpu__copy (&dst->thread.fpu, &src->thread.fpu); }
Signature · 1 line
2.4.3
tip-bot for Andy Lutomirski
merge bot[tip:x86/urgent] selftests/x86: Add a fork() to entry_from_vm86 to catch fork bugs
In reply to Andy Lutomirskiselftests/x86: Add a fork() to entry_from_vm86 to catch fork bugs
Commit-ID: 226f1f729ce277720fab60c91dd1b12574cfe66c Gitweb: http://git.kernel.org/tip/226f1f729ce277720fab60c91dd1b12574cfe66c Author: Andy Lutomirski <[email protected]> AuthorDate: Fri, 30 Oct 2015 22:42:45 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 31 Oct 2015 09:50:25 +0100
selftests/x86: Add a fork() to entry_from_vm86 to catch fork bugs
Mere possession of vm86 state is strange. Make sure that nothing gets corrupted if we fork after calling vm86().
--- tools/testing/selftests/x86/entry_from_vm86.c | 4 ++++ 1 file changed, 4 insertions(+)
tools/testing/selftests/x86/entry_from_vm86.c +4 -0
@@ -230,5 +230,9 @@ int main(void) }clearhandler (SIGSEGV ); +/* Make sure nothing explodes if we fork. */ +if (fork () >0 ) +return 0 ; +return (nerrs ==0 ?0 :1 ); }
tip-bot for Andy Lutomirski
merge bot[tip:x86/urgent] x86/vm86: Set thread.vm86 to NULL on fork/clone
In reply to Andy Lutomirskix86/vm86: Set thread.vm86 to NULL on fork/clone
Commit-ID: 2459ee8651dc5ab72790c2ffa99af288c7641b64 Gitweb: http://git.kernel.org/tip/2459ee8651dc5ab72790c2ffa99af288c7641b64 Author: Andy Lutomirski <[email protected]> AuthorDate: Fri, 30 Oct 2015 22:42:46 -0700 Committer: Thomas Gleixner <[email protected]> CommitDate: Sat, 31 Oct 2015 09:50:25 +0100
x86/vm86: Set thread.vm86 to NULL on fork/clone
thread.vm86 points to per-task information -- the pointer should not be copied on clone.
--- arch/x86/kernel/process.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kernel/process.c +3 -0
@@ -84,6 +84,9 @@ EXPORT_SYMBOL_GPL(idle_notifier_unregister);int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src) {memcpy (dst, src, arch_task_struct_size); +#ifdef CONFIG_VM86 + dst->thread.vm86 =NULL ; +#endif return fpu__copy (&dst->thread.fpu, &src->thread.fpu); }