From: John Hubbard <jhubbard@nvidia.com>
To: Muhammad Usama Anjum <Usama.Anjum@collabora.com>,
Kees Cook <keescook@chromium.org>
Cc: "H . J . Lu" <hjl.tools@gmail.com>,
Chris Kennelly <ckennelly@google.com>,
Eric Biederman <ebiederm@xmission.com>,
Shuah Khan <shuah@kernel.org>, Fangrui Song <maskray@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Yang Yingliang <yangyingliang@huawei.com>, <linux-mm@kvack.org>,
<linux-kselftest@vger.kernel.org>,
Mike Rapoport <rppt@kernel.org>,
"Rui Salvaterra" <rsalvaterra@gmail.com>,
Victor Stinner <vstinner@redhat.com>,
"Jan Palus" <jpalus@fastmail.com>,
Al Viro <viro@zeniv.linux.org.uk>,
"Christian Brauner" <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
<linux-kernel@vger.kernel.org>, <linux-fsdevel@vger.kernel.org>,
<linux-hardening@vger.kernel.org>
Subject: Re: [PATCH 1/3] selftests/exec: Build both static and non-static load_address tests
Date: Mon, 19 Aug 2024 12:41:55 -0700 [thread overview]
Message-ID: <0c6ff7bb-8a22-403d-b015-aa20c907df8f@nvidia.com> (raw)
In-Reply-To: <c2ed3020-f0c7-4077-aa63-648f7cd6bc75@collabora.com>
On 8/18/24 8:55 PM, Muhammad Usama Anjum wrote:
> On 8/7/24 3:22 PM, Muhammad Usama Anjum wrote:
>> On 5/9/24 11:16 AM, Kees Cook wrote:
>>> On Wed, May 08, 2024 at 07:54:13PM -0700, John Hubbard wrote:
>>>> Didn't we learn recently, though, that -static-pie is gcc 8.1+, while the
>>>> kernel's minimum gcc version is 5?
>>>
>>> Yes, that's true. If we encounter anyone trying to build the selftests
>>> with <8.1 I think we'll have to add a compiler version test in the
>>> Makefile to exclude the static pie tests.
>>>
>>> There's also the potential issue with arm64 builds that caused the
>>> original attempt at -static. We'll likely need an exclusion there too.
>>>
>> I'm not getting failures for arm64 instead for arm. I'm trying to find
>> this "rcrt1.o" file. Does anybody have any idea if this error can be
>> resolved by missing file or is it something arm-linux-gnueabihf
>> toolchain doesn't support?
> Do you have any idea?
Yes, I took a closer look just now:
>
>>
>> make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-
>> arm-linux-gnueabihf-gcc -Wall -Wno-nonnull -D_GNU_SOURCE=
>> -Wl,-z,max-page-size=0x1000 \
>> -fPIE -static-pie load_address.c -o
>> /home/usama/repos/kernel/linux_mainline/tools/testing/selftests/exec/load_address.static.0x1000
>> /usr/lib/gcc-cross/arm-linux-gnueabihf/12/../../../../arm-linux-gnueabihf/bin/ld:
>> cannot find rcrt1.o: No such file or directory
>> collect2: error: ld returned 1 exit status
>> make: *** [Makefile:39:
>> /home/usama/repos/kernel/linux_mainline/tools/testing/selftests/exec/load_address.static.0x1000]
>> Error 1
>
This appears to be because that particular cross compiler setup
(the libc part of the installation) fails to include rcrt1.o. I was
able to reproduce this on Ubuntu 23.04, using their standard arm
cross compilation packages for gcc and libc.
Also, -static-pie is what is causing the linker to look for rcrt1.o.
If you change the invocation from "-static-pie" to "-static -pie",
then linking succeeds.
Putting all of this together, I think we were are seeing is that
even though "-static-pie" was added to gcc 8.1+, and even though
the cross-compiler installation here shows gcc 12.3.0, the libc
support for that feature is lagging. In other words, the cross
installation of libc is effectively at something earlier than
gcc 8.1's needs.
So I think this means that we need to fix up the distros'packages,
and meanwhile, fall back to something like "-static-pie" for
selftests.
thanks,
--
John Hubbard
NVIDIA
next prev parent reply other threads:[~2024-08-19 19:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-08 17:31 [PATCH 0/3] binfmt_elf: Honor PT_LOAD alignment for static PIE Kees Cook
2024-05-08 17:31 ` [PATCH 1/3] selftests/exec: Build both static and non-static load_address tests Kees Cook
2024-05-09 2:54 ` John Hubbard
2024-05-09 6:16 ` Kees Cook
2024-08-07 10:22 ` Muhammad Usama Anjum
2024-08-19 3:55 ` Muhammad Usama Anjum
2024-08-19 19:41 ` John Hubbard [this message]
2024-08-19 19:52 ` John Hubbard
2024-05-08 17:31 ` [PATCH 2/3] binfmt_elf: Calculate total_size earlier Kees Cook
2024-05-08 17:31 ` [PATCH 3/3] binfmt_elf: Honor PT_LOAD alignment for static PIE Kees Cook
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=0c6ff7bb-8a22-403d-b015-aa20c907df8f@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=Usama.Anjum@collabora.com \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=ckennelly@google.com \
--cc=ebiederm@xmission.com \
--cc=hjl.tools@gmail.com \
--cc=jack@suse.cz \
--cc=jpalus@fastmail.com \
--cc=keescook@chromium.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maskray@google.com \
--cc=rppt@kernel.org \
--cc=rsalvaterra@gmail.com \
--cc=shuah@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=vstinner@redhat.com \
--cc=yangyingliang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox