Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 341271 - app-emulation/virt-what fails to build with the hardened toolchain
Summary: app-emulation/virt-what fails to build with the hardened toolchain
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: x86 Linux
: High major (vote)
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
Depends on: 409237
Blocks:
  Show dependency tree
 
Reported: 2010-10-16 12:40 UTC by Faustus
Modified: 2013-01-08 16:12 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
0001-Preserve-ebx-across-CPUID-when-using-PIE-thanks-Faus.patch (0001-Preserve-ebx-across-CPUID-when-using-PIE-thanks-Faus.patch,1.10 KB, patch)
2012-03-17 10:55 UTC, Richard Jones
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Faustus 2010-10-16 12:40:40 UTC
True both for the stable gcc 4.3.4 and for unstable gcc 4.4.4-r2 in hardened Gentoo (x86, didn't test on amd64). Perhaps SSP/PIE should be turned off in the ebuild. Builds fine on non-hardened x86/amd64.

CHOST="i686-pc-linux-gnu"
CFLAGS="-Os -march=i686 -mtune=core2 -fomit-frame-pointer -pipe"

>>> Failed to emerge app-emulation/virt-what-1.2, Log file:
>>>  '/var/tmp/portage/app-emulation/virt-what-1.2/temp/build.log'
 * CPV:  app-emulation/virt-what-1.2
 * REPO: gentoo
 * USE:  elibc_glibc kernel_linux userland_GNU x86
 * Applying virt-what-1.2-bin-to-sbin.patch ...                           [ ok ]
 * Applying virt-what-1.2-vmware-cpuid-check.patch ...                    [ ok ]
 * Running eautoreconf in '/var/tmp/portage/app-emulation/virt-what-1.2/work/virt-what-1.2' ...
 * Running aclocal ...                                                    [ ok ]
 * Running autoconf ...                                                   [ ok ]
 * Running autoheader ...                                                 [ ok ]
 * Running automake --add-missing --copy --foreign ...                    [ ok ]
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for style of include used by make... GNU
checking for i686-pc-linux-gnu-gcc... i686-pc-linux-gnu-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether i686-pc-linux-gnu-gcc accepts -g... yes
checking for i686-pc-linux-gnu-gcc option to accept ISO C89... none needed
checking dependency style of i686-pc-linux-gnu-gcc... gcc3
checking for i686-pc-linux-gnu-gcc option to accept ISO C99... -std=gnu99
checking for i686-pc-linux-gnu-gcc -std=gnu99 option to accept ISO Standard C... (cached) -std=gnu99
checking how to run the C preprocessor... i686-pc-linux-gnu-gcc -std=gnu99 -E
checking for function prototypes... yes
checking whether i686-pc-linux-gnu-gcc -std=gnu99 and cc understand -c and -o together... yes
configure: creating ./config.status
config.status: creating virt-what
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
make  all-am
make[1]: Entering directory `/var/tmp/portage/app-emulation/virt-what-1.2/work/virt-what-1.2'
i686-pc-linux-gnu-gcc -std=gnu99 -DHAVE_CONFIG_H -I.  -Wall   -Os -march=i686 -mtune=core2 -fomit-frame-pointer -pipe -MT virt-what-cpuid-helper.o -MD -MP -MF .deps/virt-what-cpuid-helper.Tpo -c -o virt-what-cpuid-helper.o virt-what-cpuid-helper.c
pod2man -c "Virtualization Support" --release "virt-what-1.2" \
	  virt-what.pod > virt-what.1
virt-what-cpuid-helper.c: In function ‘cpu_sig’:
virt-what-cpuid-helper.c:32: error: can't find a register in class ‘BREG’ while reloading ‘asm’
virt-what-cpuid-helper.c:32: error: ‘asm’ operand has impossible constraints
make[1]: *** [virt-what-cpuid-helper.o] Error 1
make[1]: *** Waiting for unfinished jobs....
virt-what.pod:1: Unknown command paragraph "=encoding utf8"
make[1]: Leaving directory `/var/tmp/portage/app-emulation/virt-what-1.2/work/virt-what-1.2'
make: *** [all] Error 2
 * ERROR: app-emulation/virt-what-1.2 failed:
 *   emake failed
 * 
 * Call stack:
 *     ebuild.sh, line   54:  Called src_compile
 *   environment, line 2797:  Called _eapi2_src_compile
 *     ebuild.sh, line  646:  Called die
 * The specific snippet of code:
 *   		emake || die "emake failed"
 * 
 * If you need support, post the output of 'emerge --info =app-emulation/virt-what-1.2',
 * the complete build log and the output of 'emerge -pqv =app-emulation/virt-what-1.2'.
 * The complete build log is located at '/var/tmp/portage/app-emulation/virt-what-1.2/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/app-emulation/virt-what-1.2/temp/environment'.
 * S: '/var/tmp/portage/app-emulation/virt-what-1.2/work/virt-what-1.2'
Comment 1 Faustus 2011-04-05 14:28:38 UTC
Apparently, same issue as with bug 362167 - same ways to fix, too.
Comment 2 taaroa 2011-04-05 16:35:20 UTC
 * Messages for package app-emulation/virt-what-1.2:

 * Package:    app-emulation/virt-what-1.2
 * Repository: gentoo
 * Maintainer: cardoe@gentoo.org
 * USE:        amd64 elibc_glibc kernel_linux userland_GNU
 * FEATURES:   fakeroot preserve-libs sandbox suidctl usersandbox
 * Package:    app-emulation/virt-what-1.2
 * Repository: gentoo
 * Maintainer: cardoe@gentoo.org
 * USE:        amd64 elibc_glibc kernel_linux userland_GNU
 * FEATURES:   fakeroot preserve-libs sandbox suidctl usersandbox
 * Applying virt-what-1.2-bin-to-sbin.patch ...
 * Applying virt-what-1.2-vmware-cpuid-check.patch ...
 * Running eautoreconf in '/var/tmp/portage/app-emulation/virt-what-1.2/work/virt-what-1.2' ...
 * Running aclocal ...
 * Running autoconf ...
 * Running autoheader ...
 * Running automake --add-missing --copy --foreign ...

p.s. 
% eix virt-what
[I] app-emulation/virt-what
     Available versions:  (~)1.0[1] (~)1.2{tbz2}
     Installed versions:  1.2{tbz2}(00:28:25 06.04.2011)
     Homepage:            http://people.redhat.com/~rjones/virt-what/
     Description:         Detects if the current machine is running in a virtual machine
p.p.s.
Portage 2.2.0_alpha29 (hardened/linux/amd64/no-multilib, gcc-4.5.2, glibc-2.13-r2, 2.6.38-hardened x86_64)
Comment 3 Faustus 2011-04-05 19:51:11 UTC
Portage 2.1.9.42 (hardened/linux/x86, gcc-4.4.5, glibc-2.11.3-r0,
2.6.32-gentoo-r7 i686)
=================================================================
                        System Settings
=================================================================
Timestamp of tree: Tue, 05 Apr 2011 00:45:01 +0000
app-shells/bash:     4.1_p9
dev-lang/python:     2.6.6-r2
dev-util/cmake:      2.8.1-r2
sys-apps/baselayout: 1.12.14-r1
sys-apps/sandbox:    2.4
sys-devel/autoconf:  2.65-r1
sys-devel/automake:  1.10.3, 1.11.1
sys-devel/binutils:  2.20.1-r1
sys-devel/gcc:       4.4.5
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.10
sys-devel/make:      3.81-r2
virtual/os-headers:  2.6.36.1 (sys-kernel/linux-headers)
ACCEPT_KEYWORDS="x86"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-Os -march=i686 -mtune=core2 -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CXXFLAGS="-Os -march=i686 -mtune=core2 -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="assume-digests binpkg-logs collision-protect distlocks fixlafiles
fixpackages news parallel-fetch protect-owned sandbox sfperms strict
unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv
usersandbox usersync"
FFLAGS=""
LDFLAGS="-Wl,--as-needed"
Comment 4 Faustus 2011-09-26 14:44:15 UTC
The bug persists in gcc-4.5.3-r1 and virt-what-1.11.
Comment 5 Richard Jones 2012-03-17 09:25:19 UTC
Does cpuid actually clobber %ebx?  I'll have to have a look
at the Intel PRM later on.
Comment 6 Faustus 2012-03-17 10:15:54 UTC
(In reply to comment #5)
> Does cpuid actually clobber %ebx?

Yes, for nearly all parameters.
https://en.wikipedia.org/wiki/CPUID
Comment 7 Richard Jones 2012-03-17 10:23:14 UTC
Upstream bug report:
https://bugzilla.redhat.com/show_bug.cgi?id=804282
Comment 8 Richard Jones 2012-03-17 10:55:43 UTC
Created attachment 305683 [details, diff]
0001-Preserve-ebx-across-CPUID-when-using-PIE-thanks-Faus.patch

I'd be greatful if someone on Gentoo could try the attached
patch, both that it fixes the compiler error, and (more importantly)
that virt-what still works afterwards.
Comment 9 Anthony Basile gentoo-dev 2012-03-17 11:52:40 UTC
The patch looks sane (tries to shield ebx on pie system) and it works on my kvm i686 guest as well as non-hardened.

hard-thirtytwo virt-what # virt-what 
kvm

@cardoe.  Its probably safe to apply this patch unconditionally, but if you want, you can apply condition on use hardened.
Comment 10 Faustus 2012-03-17 11:56:01 UTC
It also compiles fine here, and I will test shortly in QEMU w/ and w/o KVM, and VMware.
Comment 11 Faustus 2012-03-17 12:34:52 UTC
Seems to work fine, thanks!
Comment 12 Anthony Basile gentoo-dev 2012-03-17 13:07:33 UTC
> @cardoe.  Its probably safe to apply this patch unconditionally, but if you
> want, you can apply condition on use hardened.

Actually Zorry pointed out that its really the pic flag we want on x86.
Comment 13 Richard Jones 2012-03-17 13:22:43 UTC
Thanks for testing.  I'm going to push this patch
upstream shortly, and make a new version of virt-what (1.12)
which contains the fix.
Comment 14 Richard Jones 2012-03-17 13:26:58 UTC
New version is here:
http://people.redhat.com/~rjones/virt-what/files/
Comment 15 Faustus 2012-07-11 11:11:03 UTC
Hi, is it possible to add the fixed virt-what-1.12 to the tree? Bump request is #409237 (filed 4 months ago).
Comment 16 Faustus 2013-01-08 16:12:50 UTC
New version is now in tree.