]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.14/0097-x86-32-Fix-endless-loop-when-processing-signals-for-.patch
linux-ti335x-psp 3.2: update to 3.2.14
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.14 / 0097-x86-32-Fix-endless-loop-when-processing-signals-for-.patch
1 From 37d297b39726f3284da2f83d235c94b0d224e047 Mon Sep 17 00:00:00 2001
2 From: Dmitry Adamushko <dmitry.adamushko@gmail.com>
3 Date: Thu, 22 Mar 2012 21:39:25 +0100
4 Subject: [PATCH 097/147] x86-32: Fix endless loop when processing signals for
5  kernel tasks
7 commit 29a2e2836ff9ea65a603c89df217f4198973a74f upstream.
9 The problem occurs on !CONFIG_VM86 kernels [1] when a kernel-mode task
10 returns from a system call with a pending signal.
12 A real-life scenario is a child of 'khelper' returning from a failed
13 kernel_execve() in ____call_usermodehelper() [ kernel/kmod.c ].
14 kernel_execve() fails due to a pending SIGKILL, which is the result of
15 "kill -9 -1" (at least, busybox's init does it upon reboot).
17 The loop is as follows:
19 * syscall_exit_work:
20  - work_pending:            // start_of_the_loop
21  - work_notify_sig:
22    - do_notify_resume()
23      - do_signal()
24        - if (!user_mode(regs)) return;
25  - resume_userspace         // TIF_SIGPENDING is still set
26  - work_pending             // so we call work_pending => goto
27                             // start_of_the_loop
29 More information can be found in another LKML thread:
30 http://www.serverphorums.com/read.php?12,457826
32 [1] the problem was also seen on MIPS.
34 Signed-off-by: Dmitry Adamushko <dmitry.adamushko@gmail.com>
35 Link: http://lkml.kernel.org/r/1332448765.2299.68.camel@dimm
36 Cc: Oleg Nesterov <oleg@redhat.com>
37 Cc: Roland McGrath <roland@hack.frob.com>
38 Cc: Andrew Morton <akpm@linux-foundation.org>
39 Signed-off-by: H. Peter Anvin <hpa@zytor.com>
40 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
41 ---
42  arch/x86/kernel/entry_32.S |   17 ++++++++++-------
43  1 file changed, 10 insertions(+), 7 deletions(-)
45 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
46 index f3f6f53..bcda816 100644
47 --- a/arch/x86/kernel/entry_32.S
48 +++ b/arch/x86/kernel/entry_32.S
49 @@ -99,12 +99,6 @@
50  #endif
51  .endm
52  
53 -#ifdef CONFIG_VM86
54 -#define resume_userspace_sig   check_userspace
55 -#else
56 -#define resume_userspace_sig   resume_userspace
57 -#endif
58 -
59  /*
60   * User gs save/restore
61   *
62 @@ -328,10 +322,19 @@ ret_from_exception:
63         preempt_stop(CLBR_ANY)
64  ret_from_intr:
65         GET_THREAD_INFO(%ebp)
66 -check_userspace:
67 +resume_userspace_sig:
68 +#ifdef CONFIG_VM86
69         movl PT_EFLAGS(%esp), %eax      # mix EFLAGS and CS
70         movb PT_CS(%esp), %al
71         andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %eax
72 +#else
73 +       /*
74 +        * We can be coming here from a syscall done in the kernel space,
75 +        * e.g. a failed kernel_execve().
76 +        */
77 +       movl PT_CS(%esp), %eax
78 +       andl $SEGMENT_RPL_MASK, %eax
79 +#endif
80         cmpl $USER_RPL, %eax
81         jb resume_kernel                # not returning to v8086 or userspace
82  
83 -- 
84 1.7.9.4