[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQKhpjt0pojdYGXpeyMvJnCUVvyrRKCmHg3cKYjAs-HDmA@mail.gmail.com>
Date: Wed, 22 Nov 2023 16:51:23 -0800
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
Dave Hansen <dave.hansen@...ux.intel.com>,
X86 ML <x86@...nel.org>, "H. Peter Anvin" <hpa@...or.com>,
"David S. Miller" <davem@...emloft.net>,
David Ahern <dsahern@...nel.org>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...gle.com>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
Arnd Bergmann <arnd@...db.de>,
Sami Tolvanen <samitolvanen@...gle.com>,
Kees Cook <keescook@...omium.org>,
Nathan Chancellor <nathan@...nel.org>,
Nick Desaulniers <ndesaulniers@...gle.com>,
linux-riscv <linux-riscv@...ts.infradead.org>,
LKML <linux-kernel@...r.kernel.org>,
Network Development <netdev@...r.kernel.org>,
bpf <bpf@...r.kernel.org>,
linux-arch <linux-arch@...r.kernel.org>,
clang-built-linux <llvm@...ts.linux.dev>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Joao Moreira <joao@...rdrivepizza.com>,
Mark Rutland <mark.rutland@....com>
Subject: Re: [PATCH 2/2] x86/cfi,bpf: Fix BPF JIT call
On Wed, Nov 22, 2023 at 4:41 AM Peter Zijlstra <peterz@...radead.org> wrote:
>
>
> +/*
> + * Emit the various CFI preambles, see the large comment about FineIBT
> + * in arch/x86/kernel/alternative.c
.. and in cfi.h ..
which will have a copy-paste from your other email?
> prog->bpf_func = (void *)image + ctx.prog_offset;
> prog->jited = 1;
> prog->jited_len = proglen - ctx.prog_offset; // XXX?
Just drop XXX.
> --- a/include/linux/bpf.h
> +++ b/include/linux/bpf.h
> @@ -1431,6 +1431,9 @@ struct bpf_prog_aux {
> struct bpf_kfunc_desc_tab *kfunc_tab;
> struct bpf_kfunc_btf_tab *kfunc_btf_tab;
> u32 size_poke_tab;
> +#ifdef CONFIG_FINEIBT
> + struct bpf_ksym ksym_prefix;
> +#endif
> struct bpf_ksym ksym;
> const struct bpf_prog_ops *ops;
> struct bpf_map **used_maps;
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
> @@ -683,6 +683,23 @@ void bpf_prog_kallsyms_add(struct bpf_pr
> fp->aux->ksym.prog = true;
>
> bpf_ksym_add(&fp->aux->ksym);
> +
> +#ifdef CONFIG_FINEIBT
> + /*
> + * When FineIBT, code in the __cfi_foo() symbols can get executed
> + * and hence unwinder needs help.
> + */
I like the idea!
> + if (cfi_mode != CFI_FINEIBT)
> + return;
The cfi_mode var needs to be global along with enum ?
Or some new helper function from arch/x86 ?
> +
> + snprintf(fp->aux->ksym_prefix.name, KSYM_NAME_LEN,
> + "__cfi_%s", fp->aux->ksym.name);
> +
> + prog->aux->ksym_prefix.start = (unsigned long) prog->bpf_func - 16;
> + prog->aux->ksym_prefix.end = (unsigned long) prog->bpf_func;
> +
> + bpf_ksym_add(&fp->aux->ksym_prefix);
> +#endif
> }
>
> void bpf_prog_kallsyms_del(struct bpf_prog *fp)
and handle deletion of ksym_prefix here.
I think it's shaping up nicely.
Pls resend both patches as a set and cc bpf @ vger.
BPF CI will pick it up and test on arm64, x86-64, s390 with gcc and clang.
We don't do CONFIG_*IBT testing automatically, but
I can manually try that after the holidays.
Powered by blists - more mailing lists