All of
 help / color / mirror / Atom feed
From: dimm <>
To: Ingo Molnar <>, Thomas Gleixner <>,
	"H. Peter Anvin" <>
Cc: LKML <>,
	Oleg Nesterov <>,
	Andrew Morton <>,
	Roland McGrath <>
Subject: [PATCH, RFC] endless loop when processing signals for kernel-space tasks
Date: Thu, 22 Mar 2012 21:39:25 +0100	[thread overview]
Message-ID: <1332448765.2299.68.camel@dimm> (raw)

From: Dmitry Adamushko <>

The problem occurs on !CONFIG_VM86 kernels [1] when a kernel-mode task returns from a system call with a pending signal.

A real-life scenario is a child of 'khelper' returning from a failed kernel_execve() in ____call_usermodehelper() [ kernel/kmod.c ].
kernel_execve() fails due to a pending SIGKILL, which is the result of "kill -9 -1" (at least, busybox's init does it upon reboot).

The loop is as follows:

* syscall_exit_work:
 - work_pending:            // start_of_the_loop
 - work_notify_sig:
   - do_notify_resume()
     - do_signal()
       - if (!user_mode(regs)) return;
 - resume_userspace         // TIF_SIGPENDING is still set
 - work_pending             // so we call work_pending => goto 
                            // start_of_the_loop

More information can be found in another LKML thread:,457826

[1] the problem was also seen on MIPS.

Thanks in advance for any feedback!

Signed-off-by: Dmitry Adamushko <>
CC: Oleg Nesterov <>
CC: Ingo Molnar <>
CC: Thomas Gleixner <>
CC: "H. Peter Anvin" <>,
CC: Roland McGrath <>
CC: Andrew Morton <>

diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
index 79d97e6..7b784f4 100644
--- a/arch/x86/kernel/entry_32.S
+++ b/arch/x86/kernel/entry_32.S
@@ -98,12 +98,6 @@
-#ifdef CONFIG_VM86
-#define resume_userspace_sig	check_userspace
-#define resume_userspace_sig	resume_userspace
  * User gs save/restore
@@ -327,10 +321,19 @@ ret_from_exception:
+#ifdef CONFIG_VM86
 	movl PT_EFLAGS(%esp), %eax	# mix EFLAGS and CS
 	movb PT_CS(%esp), %al
 	andl $(X86_EFLAGS_VM | SEGMENT_RPL_MASK), %eax
+	/*
+	 * We can be coming here from a syscall done in the kernel space,
+	 * e.g. a failed kernel_execve().
+	 */
+	movl PT_CS(%esp), %eax
+	andl $SEGMENT_RPL_MASK, %eax
 	cmpl $USER_RPL, %eax
 	jb resume_kernel		# not returning to v8086 or userspace

             reply	other threads:[~2012-03-22 20:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22 20:39 dimm [this message]
2012-03-22 21:27 ` [tip:x86/urgent] x86-32: Fix endless loop when processing signals for kernel tasks tip-bot for Dmitry Adamushko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332448765.2299.68.camel@dimm \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH, RFC] endless loop when processing signals for kernel-space tasks' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.