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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdmhuaLC6=vG2DMFAbhfXoUr74_aemM2DK7me6pQ0obW4g@mail.gmail.com>
Date:   Mon, 6 Nov 2017 10:47:37 -0800
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Masahiro Yamada <yamada.masahiro@...ionext.com>
Cc:     Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
        Michael Davidson <md@...gle.com>,
        Greg Hackmann <ghackmann@...gle.com>,
        Pirama Arumuga Nainar <pirama@...gle.com>,
        Douglas Anderson <dianders@...omium.org>,
        Ingo Molnar <mingo@...nel.org>,
        Matthias Kaehlcke <mka@...omium.org>,
        Arnd Bergmann <arnd@...db.de>,
        Marcin Nowakowski <marcin.nowakowski@...tec.com>,
        Mark Charlebois <charlebm@...il.com>,
        Josh Poimboeuf <jpoimboe@...hat.com>,
        Cao jin <caoj.fnst@...fujitsu.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] kbuild: fix linker feature test macros when cross
 compiling with Clang

Comparing make V=1 with the suggested config before my patch, after my
patch, and after Masahiro's suggestion to add $(LDFLAGS):

before:
...
ld -m elf_i386  -pie    -T arch/x86/boot/compressed/vmlinux.lds ...
...

after my:
...
ld -m elf_i386     -T arch/x86/boot/compressed/vmlinux.lds ...
...

after my+Masahiro:
...
ld -m elf_i386 -pie    -T arch/x86/boot/compressed/vmlinux.lds ...
...

:)

Just to dig into this a little more (though I suspect we've found the issue):

Next is to debug what we're passing to try-run and see what errors
it's masking.  Adding to arch/x86/boot/compressed/Makefile:
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -44,6 +44,10 @@ LDFLAGS := -m elf_$(UTS_MACHINE)
 # Compressed kernel should be built as PIE since it may be loaded at any
 # address by the bootloader.
 ifeq ($(CONFIG_X86_32),y)
+$(info "XXX")
+$(info "KBUILD_CPPFLAGS: ${KBUILD_CPPFLAGS}")
+$(info "CC_OPTION_CFLAGS: ${CC_OPTION_CFLAGS}")
+$(info "LDFLAGS: ${LDFLAGS}")
 LDFLAGS += $(call ld-option, -pie) $(call ld-option, --no-dynamic-linker)
 else
 # To build 64-bit compressed kernel as PIE, we disable relocation

then grepping for XXX in a build output:
"XXX"
"KBUILD_CPPFLAGS: -D__KERNEL__  "
"CC_OPTION_CFLAGS: -m32 -D__KERNEL__ -O2 -fno-strict-aliasing -fPIE
-DDISABLE_BRANCH_PROFILING -march=i386 -mno-mmx -mno-sse
-ffreestanding -fno-stack-protector"
"LD_FLAGS: "

then trying this on the command line:
➜  kernel-all git:(kbuild) ✗ cc -pie -D__KERNEL__ -m32 -D__KERNEL__
-O2 -fno-strict-aliasing -fPIE -DDISABLE_BRANCH_PROFILING -march=i386
-mno-mmx -mno-sse -ffreestanding -fno-stack-protector -x c /dev/null
-c -o temp.o
➜  kernel-all git:(kbuild) ✗ ld -pie temp.o -o temp
ld: i386 architecture of input file `temp.o' is incompatible with
i386:x86-64 output
ld: warning: cannot find entry symbol _start; defaulting to 0000000000000078
➜  kernel-all git:(kbuild) ✗ echo $?
1
➜  kernel-all git:(kbuild) ✗ file temp.o
temp.o: ELF 32-bit LSB  relocatable, Intel 80386, version 1 (SYSV), not stripped

So it looks like without LDFLAGS, we don't tell the linker to link as
32b, causing ld-option to fail to add -pie to LDFLAGS.

➜  kernel-all git:(kbuild) ✗ ld -pie -m elf_i386 temp.o -o temp
ld: warning: cannot find entry symbol _start; defaulting to 0000000000000185
➜  kernel-all git:(kbuild) ✗ echo $?
0

sure enough, just before the call to ld-option from
arch/x86/boot/compressed/Makefile:

 43 LDFLAGS := -m elf_$(UTS_MACHINE)

so looks like Masahiro's suggestion is correct.  Will send a v3.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ