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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQK6Vh-pv_ewS0RjBBfL5KUsMXpdMNFvv5F0OPWzABEsAw@mail.gmail.com>
Date: Wed, 12 Jun 2024 10:07:09 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Maxwell Bland <mbland@...orola.com>
Cc: "open list:BPF [GENERAL] (Safe Dynamic Programs and Tools)" <bpf@...r.kernel.org>, Catalin Marinas <catalin.marinas@....com>, 
	Will Deacon <will@...nel.org>, Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>, 
	Andrii Nakryiko <andrii@...nel.org>, Martin KaFai Lau <martin.lau@...ux.dev>, 
	Eduard Zingerman <eddyz87@...il.com>, 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>, Zi Shen Lim <zlim.lnx@...il.com>, 
	Mark Rutland <mark.rutland@....com>, Suzuki K Poulose <suzuki.poulose@....com>, 
	Mark Brown <broonie@...nel.org>, 
	linux-arm-kernel <linux-arm-kernel@...ts.infradead.org>, 
	open list <linux-kernel@...r.kernel.org>, Josh Poimboeuf <jpoimboe@...nel.org>, 
	Puranjay Mohan <puranjay12@...il.com>
Subject: Re: [PATCH bpf-next v6 3/3] arm64/cfi,bpf: Use DEFINE_CFI_TYPE in arm64

On Wed, Jun 12, 2024 at 8:32 AM Maxwell Bland <mbland@...orola.com> wrote:
>
> Corrects Puranjay Mohan's commit to adopt Mark Rutland's
> suggestion of using a C CFI type macro in kCFI+BPF.
>
> Signed-off-by: Maxwell Bland <mbland@...orola.com>
> ---
>  arch/arm64/kernel/alternative.c | 46 ++++-----------------------------
>  1 file changed, 5 insertions(+), 41 deletions(-)
>
> diff --git a/arch/arm64/kernel/alternative.c b/arch/arm64/kernel/alternative.c
> index 1715da7df137..d7a58eca7665 100644
> --- a/arch/arm64/kernel/alternative.c
> +++ b/arch/arm64/kernel/alternative.c
> @@ -8,6 +8,7 @@
>
>  #define pr_fmt(fmt) "alternatives: " fmt
>
> +#include <linux/cfi_types.h>
>  #include <linux/init.h>
>  #include <linux/cpu.h>
>  #include <linux/elf.h>
> @@ -302,53 +303,16 @@ EXPORT_SYMBOL(alt_cb_patch_nops);
>
>  #ifdef CONFIG_CFI_CLANG
>  struct bpf_insn;
> -
>  /* Must match bpf_func_t / DEFINE_BPF_PROG_RUN() */
>  extern unsigned int __bpf_prog_runX(const void *ctx,
>                                     const struct bpf_insn *insn);
> -
> -/*
> - * Force a reference to the external symbol so the compiler generates
> - * __kcfi_typid.
> - */
> -__ADDRESSABLE(__bpf_prog_runX);
> -
> -/* u32 __ro_after_init cfi_bpf_hash = __kcfi_typeid___bpf_prog_runX; */
> -asm (
> -"      .pushsection    .data..ro_after_init,\"aw\",@progbits   \n"
> -"      .type   cfi_bpf_hash,@object                            \n"
> -"      .globl  cfi_bpf_hash                                    \n"
> -"      .p2align        2, 0x0                                  \n"
> -"cfi_bpf_hash:                                                 \n"
> -"      .word   __kcfi_typeid___bpf_prog_runX                   \n"
> -"      .size   cfi_bpf_hash, 4                                 \n"
> -"      .popsection                                             \n"
> -);
> -
> +DEFINE_CFI_TYPE(cfi_bpf_hash, __bpf_prog_runX);
>  /* Must match bpf_callback_t */
>  extern u64 __bpf_callback_fn(u64, u64, u64, u64, u64);
> -
> -__ADDRESSABLE(__bpf_callback_fn);
> -
> -/* u32 __ro_after_init cfi_bpf_subprog_hash = __kcfi_typeid___bpf_callback_fn; */
> -asm (
> -"      .pushsection    .data..ro_after_init,\"aw\",@progbits   \n"
> -"      .type   cfi_bpf_subprog_hash,@object                    \n"
> -"      .globl  cfi_bpf_subprog_hash                            \n"
> -"      .p2align        2, 0x0                                  \n"
> -"cfi_bpf_subprog_hash:                                         \n"
> -"      .word   __kcfi_typeid___bpf_callback_fn                 \n"
> -"      .size   cfi_bpf_subprog_hash, 4                         \n"
> -"      .popsection                                             \n"
> -);
> -
> +DEFINE_CFI_TYPE(cfi_bpf_subprog_hash, __bpf_callback_fn);
>  u32 cfi_get_func_hash(void *func)
>  {
> -       u32 hash;
> -
> -       if (get_kernel_nofault(hash, func - cfi_get_offset()))
> -               return 0;
> -
> -       return hash;
> +       u32 *hashp = func - cfi_get_offset();
> +       return READ_ONCE(*hashp);

Please avoid the code churn.
Just squash it into the previous patch.

pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ