[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YsfqFp+IkhvXPoDl@myrica>
Date: Fri, 8 Jul 2022 09:25:58 +0100
From: Jean-Philippe Brucker <jean-philippe@...aro.org>
To: Xu Kuohai <xukuohai@...wei.com>
Cc: bpf@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
Mark Rutland <mark.rutland@....com>,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Alexei Starovoitov <ast@...nel.org>,
Zi Shen Lim <zlim.lnx@...il.com>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
"David S . Miller" <davem@...emloft.net>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
David Ahern <dsahern@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>, x86@...nel.org,
"H . Peter Anvin" <hpa@...or.com>,
Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>,
Russell King <rmk+kernel@...linux.org.uk>,
James Morse <james.morse@....com>,
Hou Tao <houtao1@...wei.com>,
Jason Wang <wangborong@...rlc.com>
Subject: Re: [PATCH bpf-next v6 3/4] bpf, arm64: Impelment
bpf_arch_text_poke() for arm64
On Fri, Jul 08, 2022 at 10:41:46AM +0800, Xu Kuohai wrote:
> >> +/* generated prologue:
> >> + * bti c // if CONFIG_ARM64_BTI_KERNEL
> >> + * mov x9, lr
> >> + * nop // POKE_OFFSET
> >> + * paciasp // if CONFIG_ARM64_PTR_AUTH_KERNEL
> >
> > Any reason for the change regarding BTI and pointer auth? We used to put
> > 'bti c' at the function entry if (BTI && !PA), or 'paciasp' if (BTI && PA),
> > because 'paciasp' is an implicit BTI.
> >
>
> Assuming paciasp is the first instruction if (BTI && PA), when a
> trampoline with BPF_TRAMP_F_CALL_ORIG flag attached, we'll encounter the
> following scenario.
>
> bpf_prog:
> paciasp // LR1
> mov x9, lr
> bl <trampoline> ----> trampoline:
> ....
> mov x10, <entry_for_CALL_ORIG>
> blr x10
> |
> CALL_ORIG_entry: |
> bti c <------------------|
> stp x29, lr, [sp, #- 16]!
> ...
> autiasp // LR2
> ret
>
> Because LR1 and LR2 are not equal, the autiasp will fail!
>
> To make this scenario work properly, the first instruction should be
> 'bti c'.
Right my mistake, this layout is also what GCC generates for normal kernel
functions when (BTI && PA), so it makes sense to use the same
Thanks,
Jean
Powered by blists - more mailing lists