lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 10 Apr 2014 19:00:23 +0200
From:	Oleg Nesterov <oleg@...hat.com>
To:	Masami Hiramatsu <masami.hiramatsu.pt@...achi.com>
Cc:	Denys Vlasenko <dvlasenk@...hat.com>,
	Jim Keniston <jkenisto@...ux.vnet.ibm.com>,
	Ingo Molnar <mingo@...e.hu>,
	Srikar Dronamraju <srikar@...ux.vnet.ibm.com>,
	Ananth N Mavinakayanahalli <ananth@...ibm.com>,
	Anton Arapov <aarapov@...hat.com>,
	David Long <dave.long@...aro.org>,
	"Frank Ch. Eigler" <fche@...hat.com>,
	Jonathan Lebon <jlebon@...hat.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [RFC PATCH 4/6] uprobes/x86: Emulate rip-relative call's

On 04/10, Oleg Nesterov wrote:
>
> On 04/10, Masami Hiramatsu wrote:
> >
> > (2014/04/10 22:41), Denys Vlasenko wrote:
> > > There is this monstrosity, "16-bit override for branches" in 64-mode:
> > >
> > > 66 e8 nn nn       callw   <offset16>
> > >
> > > Nobody sane uses it because it truncates instruction pointer.
> >
> > No problem, insn.c can handle that too. :)
>
> Does it?
>
> 	"callw 1f; 1:\n"
> 	"rep; nop\n"
>
> objdump:
>
> 	66 e8 00 00             callw  485 <_init-0x3ffed3>
> 	f3 90                   pause
>
>
> if we probe this "callw", we copy MAX_INSN_BYTES into auprobe->insn,
> and after insn_get_length() (insn_complete() == T)
>
> 	// this is correct
> 	OPCODE1() == e8
>
> 	// this all looks wrong
> 	insn->length == 6
> 	insn->immediate.value == -1863122944
> 	insn->immediate.nbytes == 4
>
> so it seems that lib/insn.c treats the next "pause" insn as the high
> 16 bits of address.

Or perhaps lib/insn.c is fine but objdump is wrong? And everything
should work correctly? Although in this case I do not understand what
this "callw" actually does.

	int main(void)
	{
		asm (
			"nop\n"

			"callw 1f; 1:\n"
			".byte 0\n"
			".byte 0\n"
		);

		return 0;
	}

this runs just fine. With or without gdb. And gdb shows that ->ip is
incremented by 6 after "callw".

	int main(void)
	{
		asm (
			"nop\n"

			"callw 1f; 1:\n"
			".byte 10\n"
			".byte 20\n"
		);

		return 0;
	}

objdump:

	000000000040047c <main>:
	  40047c:       55                      push   %rbp
	  40047d:       48 89 e5                mov    %rsp,%rbp
	  400480:       90                      nop
	  400481:       66 e8 00 00             callw  485 <_init-0x3ffed3>
	  400485:       0a 14 b8                or     (%rax,%rdi,4),%dl
	  400488:       00 00                   add    %al,(%rax)
	  40048a:       00 00                   add    %al,(%rax)
	  40048c:       c9                      leaveq
	  40048d:       c3                      retq

run:

	$ ./t
	Segmentation fault (core dumped)

	$ gdb ./t core.*
	...
	#0  0x00000000144a0487 in ?? ()

0x144a0487 - 0x400481 == 0x140a0006, this matches the additional 2 .bytes treated
as offset.

So I am totally confused.

Oleg.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ