mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Oldeman <bartoldeman@users.sourceforge.net>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org, mingo@elte.hu,
	"K.Prasad" <prasad@linux.vnet.ibm.com>,
	stable@kernel.org
Subject: Re: [PATCH] x86, vm86: fix preemption bug for int3 breakpoint handlers.
Date: Sat, 5 Dec 2009 10:06:39 -0500 (EST)	[thread overview]
Message-ID: <alpine.DEB.2.00.0912050945350.6093@localhost.localdomain> (raw)
In-Reply-To: <alpine.LFD.2.00.0905251225190.3582@localhost.localdomain>

Thomas,

On Mon, 25 May 2009, Thomas Gleixner wrote:
> On Sun, 24 May 2009, Bart Oldeman wrote:
>> --- a/arch/x86/kernel/vm86_32.c
>> +++ b/arch/x86/kernel/vm86_32.c
>> @@ -551,8 +551,12 @@ cannot_handle:
>>  int handle_vm86_trap(struct kernel_vm86_regs *regs, long error_code, int
>> trapno)
>>  {
>>  	if (VMPI.is_vm86pus) {
>> -		if ((trapno == 3) || (trapno == 1))
>> +		if ((trapno == 3) || (trapno == 1)) {
>> +			/* re-enable preemption: return_to_32bit()
>> +			   jumps straight to entry_32.S */
>> +			dec_preempt_count();
>
>  This will break other callers of handle_vm86_trap().

sorry for the late reply, I was just pointed out by someone else about the
existence of this bug again. You are right of course. Below is a new 
patch.

Note that on the linux-2.6-x86.git tree, commit 
08d68323d1f0c34452e614263b212ca556dae47f ("hw-breakpoints: modifying
generic debug exception to use thread-specific debug registers") broke 
vm86 debug exceptions as well again. The trouble is that 
handle_vm86_trap() may jump and change the stack to let the kernel return 
to 32 bit user space, so the handle_vm86_trap() call itself may not 
return.

--
Impact: fix kernel bug such as:
May 22 16:47:47 localhost kernel: note: dosemu.bin[5281] exited with preempt_count 1

Commit be716615fe596ee117292dc615e95f707fb67fd1 ("x86, vm86:
fix preemption bug"), fixed the problem for debug exceptions but not for 
breakpoints. This change also fixes breakpoints.

Cc: stable@kernel.org
Signed-off-by: Bart Oldeman <bartoldeman@users.sourceforge.net>
---
  arch/x86/kernel/traps.c |    7 ++++++-
  1 file changed, 6 insertions(+), 1 deletion(-)

--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -181,9 +181,14 @@ kernel_trap:

  #ifdef CONFIG_X86_32
  vm86_trap:
+	/* reenable preemption: handle_vm86_trap() might sleep */
+	dec_preempt_count();
  	if (handle_vm86_trap((struct kernel_vm86_regs *) regs,
-						error_code, trapnr))
+						error_code, trapnr)) {
+		inc_preempt_count();
  		goto trap_signal;
+	}
+	inc_preempt_count();
  	return;
  #endif
  }

      reply	other threads:[~2009-12-05 15:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-24 22:35 Bart Oldeman
2009-05-25 10:33 ` Thomas Gleixner
2009-12-05 15:06   ` Bart Oldeman [this message]

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=alpine.DEB.2.00.0912050945350.6093@localhost.localdomain \
    --to=bartoldeman@users.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=prasad@linux.vnet.ibm.com \
    --cc=stable@kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®