Util-Linux package development
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: Karel Zak <kzak@redhat.com>
Cc: Ruediger Meier <sweet_f_a@gmx.de>, Petr Uzel <petr.uzel@suse.cz>,
	util-linux@vger.kernel.org
Subject: Re: lscpu VMWARE bdoor patch
Date: Wed, 9 Nov 2016 20:14:10 -0800	[thread overview]
Message-ID: <20161110040953.GB21655@vapier.lan> (raw)
In-Reply-To: <20161103094151.zufg6x2i3dth6nhe@ws.net.home>

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

On 03 Nov 2016 10:41, Karel Zak wrote:
> On Thu, Nov 03, 2016 at 09:04:42AM +0200, Ruediger Meier wrote:
> > On Wednesday 02 November 2016, Karel Zak wrote:
> > > On Fri, Oct 28, 2016 at 12:06:36AM +0200, Ruediger Meier wrote:
> > > > On Thursday 27 October 2016, Karel Zak wrote:
> > > > > this is lscpu output on my machine:
> > > > >
> > > > >     Virtualization:        VT-x
> > > > >     Hypervisor vendor:     VMware
> > > > >     Virtualization type:   full
> > > > >
> > > > >
> > > > > I have nothing like VMWARE. It seem the code (commit b7744730)
> > > > > does not work as expected for non-root users. What about to add
> > > >
> > > > Have you checked whether the original code in b7744730 is alreaday
> > > > broken? Not something about the later PIC/PIE patches?
> > >
> > > It's Mike's PIC/PIE patch :-(
> > >
> > > Maybe we can ifdef more precise and add getuid() check, if I good
> > > understand Mike's commit message then the problem is 32bit system.
> > 
> > BTW vmware runs on 64bit only since a few years. Maybe just disable 
> > bdoor for 32bit if it helps to make it simple.
> 
> but you can use 32bit system (guest) inside vmware. 
> 
> I'll will add getuid() for now. Maybe someone (Mike?:-) will help us
> with a better solution later.

i don't think getuid helps.  seems like if you run it on a system even as
root it'll still fail randomly.

my guess is that when the inl is run, it triggers the segfault (since it
isn't run under vmware) which happens after the ebx/esi exchange.  but the
ebx/esi aren't swapped back, and for some reason the siglongjmp doesn't
make things right (but that doesn't make sense to me either).

if you revert my patch, then you can't build lscpu as PIE on x86, which
means you're worse off than you are now :).

when i trace it in gdb by putting a break on vmware_bdoor, i see:
(gdb) info r
eax            0xa      0xa
ecx            0x5658   0x5658
edx            0x0      0x0
ebx            0x564d5868       0x564d5868
esp            0xffffb540       0xffffb540
ebp            0xffffb548       0xffffb548
esi            0x564d5868       0x564d5868
edi            0xffffd81c       0xffffd81c
eip            0x5655873a       0x5655873a <vmware_bdoor+37>
(gdb) dis
Dump of assembler code from 0x5655873a to 0x5655877a:
=> 0x5655873a <vmware_bdoor+37>:        xchg   %ebx,%esi
   0x5655873c <vmware_bdoor+39>:        in     (%dx),%eax
   0x5655873d <vmware_bdoor+40>:        xchg   %esi,%ebx
(gdb) stepi
0x5655873c      827             __asm__(
(gdb) stepi

Program received signal SIGSEGV, Segmentation fault.
0x5655873c in vmware_bdoor (eax=0xffffb574, ebx=0xffffb578, ecx=0xffffb57c, edx=0xffffb580) at sys-utils/lscpu.c:827
827             __asm__(
(gdb) stepi
segv_handler (sig=0xb, info=0xffffb04c, ignored=0xffffb0cc) at sys-utils/lscpu.c:854
854     {
(gdb) c
Continuing.
Architecture:          i686
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    2
Core(s) per socket:    2
Socket(s):             1
Vendor ID:             AuthenticAMD
CPU family:            21
Model:                 2
Model name:            AMD FX(tm)-4350 Quad-Core Processor
Stepping:              0
CPU MHz:               2000.000
CPU max MHz:           4200.0000
CPU min MHz:           1400.0000
BogoMIPS:              8427.36
Virtualization:        AMD-V
...

so the siglongjmp call hit the sigsetjmp point and made the func
return 0 which means it didn't detect as vmware at all.
-mike

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

      reply	other threads:[~2016-11-10  4:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-27 10:25 lscpu VMWARE bdoor patch Karel Zak
2016-10-27 22:06 ` Ruediger Meier
2016-11-02 12:30   ` Karel Zak
2016-11-03  7:04     ` Ruediger Meier
2016-11-03  9:41       ` Karel Zak
2016-11-10  4:14         ` Mike Frysinger [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=20161110040953.GB21655@vapier.lan \
    --to=vapier@gentoo.org \
    --cc=kzak@redhat.com \
    --cc=petr.uzel@suse.cz \
    --cc=sweet_f_a@gmx.de \
    --cc=util-linux@vger.kernel.org \
    /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