All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Anvin, H Peter" <h.peter.anvin@intel.com>,
	"Ye, Xiaolong" <xiaolong.ye@intel.com>,
	Ingo Molnar <mingo@kernel.org>, Andy Lutomirski <luto@kernel.org>,
	Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"tipbuild@zytor.com" <tipbuild@zytor.com>,
	"lkp@01.org" <lkp@01.org>
Subject: Re: [lkp-robot] [x86/asm] 51bad67ffb: int3:#[##]
Date: Wed, 16 May 2018 00:25:46 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.21.1805160009230.1605@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20180515214337.GA18021@avx2>

On Wed, 16 May 2018, Alexey Dobriyan wrote:

> On Tue, May 15, 2018 at 09:25:53PM +0000, Anvin, H Peter wrote:
> > Why is that a problem?
> > Code: 00 00 00 eb e6 cc cc cc cc cc cc cc cc cc cc cc cc cc fa 8d b6 00 00 00 00 e8 5d e8 8f ff 8b 44 24 34 83 e0 03 83 f8 03 72 28 cc &lt;cc&gt; cc cc cc cc cc cc fa 8d b6 00 00 00 00 e8 3d e8 8f ff 89 e0
> > 
> > EIP: ret_from_intr+0xd/0x14 SS:ESP: 0068:8603bfb4
> > 
> > INT3 slipped through M586 =&gt; X86_ALIGNMENT_16 :-\
> 
> I could make the patch x86_64 only, but!
> 
> It crashed into the middle of the padding.
> 
> 796ef8fc <ret_from_intr>:
> 796ef8fc:       8b 44 24 34             mov    eax,DWORD PTR [esp+0x34]
> 796ef900:       83 e0 03                and    eax,0x3
> 796ef903:       83 f8 03                cmp    eax,0x3
> 796ef906:       72 28                   jb     796ef930 <resume_kernel>
> 796ef908:       cc                      int3
> 796ef909:       cc       <========>     int3

EIP points to the second int3 because that's where a simple return would
return to. do_trap() does not handle int3 special.

>From a quick check that seems to be the only code sequence which has:

     jcc     lbl

ENTRY(foo)

and ENTRY() aligns to a 16 byte boundary. So the simple fix for that is
below. We need objtool support to detect such places ...

Thanks,

	tglx

8<-------------------

--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -338,6 +338,11 @@ END(ret_from_fork)
 	cmpl	$USER_RPL, %eax
 	jb	resume_kernel			# not returning to v8086 or userspace
 
+	/*
+	 * Jump over the alignment padding which is filled with int3 instructions
+	 */
+	jmp	resume_userspace
+
 ENTRY(resume_userspace)
 	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF

WARNING: multiple messages have this Message-ID (diff)
From: Thomas Gleixner <tglx@linutronix.de>
To: lkp@lists.01.org
Subject: Re: [lkp-robot] [x86/asm] 51bad67ffb: int3:#[##]
Date: Wed, 16 May 2018 00:25:46 +0200	[thread overview]
Message-ID: <alpine.DEB.2.21.1805160009230.1605@nanos.tec.linutronix.de> (raw)
In-Reply-To: <20180515214337.GA18021@avx2>

[-- Attachment #1: Type: text/plain, Size: 1776 bytes --]

On Wed, 16 May 2018, Alexey Dobriyan wrote:

> On Tue, May 15, 2018 at 09:25:53PM +0000, Anvin, H Peter wrote:
> > Why is that a problem?
> > Code: 00 00 00 eb e6 cc cc cc cc cc cc cc cc cc cc cc cc cc fa 8d b6 00 00 00 00 e8 5d e8 8f ff 8b 44 24 34 83 e0 03 83 f8 03 72 28 cc &lt;cc&gt; cc cc cc cc cc cc fa 8d b6 00 00 00 00 e8 3d e8 8f ff 89 e0
> > 
> > EIP: ret_from_intr+0xd/0x14 SS:ESP: 0068:8603bfb4
> > 
> > INT3 slipped through M586 =&gt; X86_ALIGNMENT_16 :-\
> 
> I could make the patch x86_64 only, but!
> 
> It crashed into the middle of the padding.
> 
> 796ef8fc <ret_from_intr>:
> 796ef8fc:       8b 44 24 34             mov    eax,DWORD PTR [esp+0x34]
> 796ef900:       83 e0 03                and    eax,0x3
> 796ef903:       83 f8 03                cmp    eax,0x3
> 796ef906:       72 28                   jb     796ef930 <resume_kernel>
> 796ef908:       cc                      int3
> 796ef909:       cc       <========>     int3

EIP points to the second int3 because that's where a simple return would
return to. do_trap() does not handle int3 special.

>From a quick check that seems to be the only code sequence which has:

     jcc     lbl

ENTRY(foo)

and ENTRY() aligns to a 16 byte boundary. So the simple fix for that is
below. We need objtool support to detect such places ...

Thanks,

	tglx

8<-------------------

--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -338,6 +338,11 @@ END(ret_from_fork)
 	cmpl	$USER_RPL, %eax
 	jb	resume_kernel			# not returning to v8086 or userspace
 
+	/*
+	 * Jump over the alignment padding which is filled with int3 instructions
+	 */
+	jmp	resume_userspace
+
 ENTRY(resume_userspace)
 	DISABLE_INTERRUPTS(CLBR_ANY)
 	TRACE_IRQS_OFF


  parent reply	other threads:[~2018-05-15 22:26 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-15  8:00 [lkp-robot] [x86/asm] 51bad67ffb: int3:#[##] kernel test robot
2018-05-15  8:00 ` kernel test robot
2018-05-15 21:07 ` Alexey Dobriyan
2018-05-15 21:07   ` Alexey Dobriyan
2018-05-15 21:25   ` Anvin, H Peter
2018-05-15 21:43     ` Alexey Dobriyan
2018-05-15 21:43       ` Alexey Dobriyan
2018-05-15 22:22       ` Josh Poimboeuf
2018-05-15 22:22         ` Josh Poimboeuf
2018-05-15 22:26         ` Thomas Gleixner
2018-05-15 22:26           ` Thomas Gleixner
2018-05-15 22:28         ` Linus Torvalds
2018-05-15 22:28           ` Linus Torvalds
2018-05-15 22:43           ` Josh Poimboeuf
2018-05-15 22:43             ` Josh Poimboeuf
2018-05-15 22:52             ` Linus Torvalds
2018-05-15 22:52               ` Linus Torvalds
2018-05-15 23:05               ` Linus Torvalds
2018-05-15 23:05                 ` Linus Torvalds
2018-05-16  3:30                 ` Josh Poimboeuf
2018-05-16  3:30                   ` Josh Poimboeuf
2018-05-17 13:49                   ` [PATCH] objtool: Detect assembly code falling through to INT3 padding Josh Poimboeuf
2018-05-17 13:49                     ` Josh Poimboeuf
2018-05-17 14:01                     ` Peter Zijlstra
2018-05-17 14:01                       ` Peter Zijlstra
2018-05-18  7:24                       ` Ingo Molnar
2018-05-18  7:24                         ` Ingo Molnar
2018-05-18  7:18                     ` Ingo Molnar
2018-05-18  7:18                       ` Ingo Molnar
2018-05-18  7:27                       ` H. Peter Anvin
2018-05-18 16:06                         ` Borislav Petkov
2018-05-18 16:06                           ` Borislav Petkov
2018-05-18  7:27                       ` Ingo Molnar
2018-05-18  7:27                         ` Ingo Molnar
2018-05-18 17:51                       ` Alexey Dobriyan
2018-05-18 17:51                         ` Alexey Dobriyan
2018-05-19  8:18                         ` hpa
2018-05-19  7:00                 ` "interesting" entry in hibernation code was Re: [lkp-robot] [x86/asm] 51bad67ffb: int3:#[##] Pavel Machek
2018-05-19  7:00                   ` Pavel Machek
2018-05-19  8:35                   ` Rafael J. Wysocki
2018-05-19  8:35                     ` Rafael J. Wysocki
2018-05-18  7:15               ` Ingo Molnar
2018-05-18  7:15                 ` Ingo Molnar
2018-05-15 22:25       ` Thomas Gleixner [this message]
2018-05-15 22:25         ` Thomas Gleixner
2018-05-15 22:29         ` Andy Lutomirski
2018-05-15 22:29           ` Andy Lutomirski
2018-05-15 22:27       ` Linus Torvalds
2018-05-15 22:27         ` Linus Torvalds
2018-05-15 22:50         ` Alexey Dobriyan
2018-05-15 22:50           ` Alexey Dobriyan
2018-05-15 22:58           ` [PATCH v2] x86/asm: Pad assembly functions with INT3 instructions Alexey Dobriyan
2018-05-15 22:58             ` Alexey Dobriyan
2018-05-15 23:28             ` Linus Torvalds
2018-05-15 23:28               ` Linus Torvalds
2018-05-18  7:36             ` Ingo Molnar
2018-05-18  7:36               ` Ingo Molnar
2018-05-18 13:02               ` Josh Poimboeuf
2018-05-18 13:02                 ` Josh Poimboeuf
2018-05-18 17:34                 ` Alexey Dobriyan
2018-05-18 17:34                   ` Alexey Dobriyan

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.21.1805160009230.1605@nanos.tec.linutronix.de \
    --to=tglx@linutronix.de \
    --cc=adobriyan@gmail.com \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=h.peter.anvin@intel.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@01.org \
    --cc=luto@kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tipbuild@zytor.com \
    --cc=torvalds@linux-foundation.org \
    --cc=xiaolong.ye@intel.com \
    /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 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.