From: Mark Rutland <mark.rutland@arm.com>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: Marc Zyngier <maz@kernel.org>, Will Deacon <will@kernel.org>,
syzbot <syzbot+908886656a02769af987@syzkaller.appspotmail.com>,
catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>
Subject: Re: [syzbot] [arm?] upstream test error: KASAN: invalid-access Write in setup_arch
Date: Thu, 19 Sep 2024 11:14:45 +0200 [thread overview]
Message-ID: <ZuvrhZjBuKLdJ9N0@J2N7QTR9R3> (raw)
In-Reply-To: <CAMj1kXHHRvWBPOoxOU=S0BY6fkEhs1j1qBvrygBH7pKwnbcJXA@mail.gmail.com>
On Thu, Sep 05, 2024 at 04:25:57PM +0200, Ard Biesheuvel wrote:
> On Thu, 5 Sept 2024 at 16:03, Mark Rutland <mark.rutland@arm.com> wrote:
> > Putting the KASAN issue aside (which I'll handle in a separate thread),
> > I think there is a real issue here with LLVM.
> >
> > What's going on here is that .idmap.text ends up more than 128M away
> > from .head.text, so the 'b primary_entry' at the start of the Image
> > isn't in range:
> >
> > | [mark@lakrids:~/src/linux]% usekorg 14.1.0 aarch64-linux-objdump -t vmlinux | grep -w _text
> > | ffff800080000000 g .head.text 0000000000000000 _text
> > | [mark@lakrids:~/src/linux]% usekorg 14.1.0 aarch64-linux-objdump -t vmlinux | grep -w primary_entry
> > | ffff8000889df0e0 g .rodata.text 000000000000006c primary_entry
> >
> > ... as those are ~128MiB apart.
> >
> > When building with GCC those end up ~101MiB apart:
> >
> > | [mark@lakrids:~/src/linux]% usekorg 14.1.0 aarch64-linux-objdump -t vmlinux | grep -w _text
> > | ffff800080000000 g .head.text 0000000000000000 _text
> > | [mark@lakrids:~/src/linux]% usekorg 14.1.0 aarch64-linux-objdump -t vmlinux | grep -w primary_entry
> > | ffff8000865ae0e0 g .rodata.text 000000000000006c primary_entry
> >
> > When that happens, LLD makes the header branch to a veneer/thunk:
> >
> > | ffff800080000000 <_text>:
> > | ffff800080000000: fa405a4d ccmp x18, #0x0, #0xd, pl // pl = nfrst
> > | ffff800080000004: 14003fff b ffff800080010000 <__AArch64AbsLongThunk_primary_entry>
> >
> > ... and unfortunately, that veneer/thunk uses a literal with the
> > statically-linked TTBR1 address of primary_entry:
> >
> > | ffff800080010000 <__AArch64AbsLongThunk_primary_entry>:
> > | ffff800080010000: 58000050 ldr x16, ffff800080010008 <__AArch64AbsLongThunk_primary_entry+0x8>
> > | ffff800080010004: d61f0200 br x16
> > | ffff800080010008: 889df0e0 .word 0x889df0e0
> > | ffff80008001000c: ffff8000 .word 0xffff8000
> >
> ...
> > LLVM folk, is there any existing option to ask LLD to use ADRP+ADD for
> > the veneer/thunk? ... and if not, would it be possible to add an option
> > for that?
> >
>
> ld.lld takes --pic-veneer, which (from looking at the llvm sources)
> appears to do what we need here.
Ah; now I take another look I see that's in the man page and is also
supported by GNU LD, so I'll spin a patch to use that.
Thanks for the pointer!
Mark.
next prev parent reply other threads:[~2024-09-19 9:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-30 8:35 [syzbot] [arm?] upstream test error: KASAN: invalid-access Write in setup_arch syzbot
2024-08-30 9:52 ` Will Deacon
2024-08-31 17:52 ` Marc Zyngier
2024-09-02 10:03 ` Aleksandr Nogikh
2024-09-03 15:39 ` Alexander Potapenko
2024-09-03 16:05 ` Marc Zyngier
2024-09-03 16:43 ` Samuel Holland
2024-09-04 15:31 ` Alexander Potapenko
2024-09-04 18:26 ` Mark Rutland
2024-09-05 14:03 ` Mark Rutland
2024-09-05 14:25 ` Ard Biesheuvel
2024-09-19 9:14 ` Mark Rutland [this message]
2024-09-23 10:46 ` Mark Rutland
2024-09-23 20:12 ` Andrey Konovalov
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=ZuvrhZjBuKLdJ9N0@J2N7QTR9R3 \
--to=mark.rutland@arm.com \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=justinstitt@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=syzbot+908886656a02769af987@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=will@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