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]
Date: Fri, 29 Mar 2024 11:24:18 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Ard Biesheuvel <ardb+git@...gle.com>
Cc: linux-kernel@...r.kernel.org, Ard Biesheuvel <ardb@...nel.org>, 
	Masahiro Yamada <masahiroy@...nel.org>, Arnd Bergmann <arnd@...db.de>, 
	Martin KaFai Lau <martin.lau@...ux.dev>, linux-arch@...r.kernel.org, 
	linux-kbuild@...r.kernel.org, bpf@...r.kernel.org
Subject: Re: [PATCH 3/3] btf: Avoid weak external references

On Fri, Mar 29, 2024 at 2:35 AM Ard Biesheuvel <ardb+git@...gle.com> wrote:
>
> From: Ard Biesheuvel <ardb@...nel.org>
>
> If the BTF code is enabled in the build configuration, the start/stop
> BTF markers are guaranteed to exist in the final link but not during the
> first linker pass.
>
> Avoid GOT based relocations to these markers in the final executable by
> providing preliminary definitions that will be used by the first linker
> pass, and superseded by the actual definitions in the subsequent ones.
>
> Signed-off-by: Ard Biesheuvel <ardb@...nel.org>
> ---
>  include/asm-generic/vmlinux.lds.h | 2 ++
>  kernel/bpf/btf.c                  | 4 ++--
>  2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index e8449be62058..141bddb511ee 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -456,6 +456,8 @@
>   * independent code.
>   */
>  #define PRELIMINARY_SYMBOL_DEFINITIONS                                 \
> +       PROVIDE(__start_BTF = .);                                       \
> +       PROVIDE(__stop_BTF = .);                                        \

should this be guarded by CONFIG_DEBUG_INFO_BTF condition?

>         PROVIDE(kallsyms_addresses = .);                                \
>         PROVIDE(kallsyms_offsets = .);                                  \
>         PROVIDE(kallsyms_names = .);                                    \
> diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c
> index 90c4a32d89ff..46a56bf067a8 100644
> --- a/kernel/bpf/btf.c
> +++ b/kernel/bpf/btf.c
> @@ -5642,8 +5642,8 @@ static struct btf *btf_parse(const union bpf_attr *attr, bpfptr_t uattr, u32 uat
>         return ERR_PTR(err);
>  }
>
> -extern char __weak __start_BTF[];
> -extern char __weak __stop_BTF[];
> +extern char __start_BTF[];
> +extern char __stop_BTF[];

kernel/bpf/sysfs_btf.c also defines __weak externs for these symbols,
you probably need to adjust that as well?

Other than that looks good to me:

Acked-by: Andrii Nakryiko <andrii@...nel.org>


>  extern struct btf *btf_vmlinux;
>
>  #define BPF_MAP_TYPE(_id, _ops)
> --
> 2.44.0.478.gd926399ef9-goog
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ