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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 2 Apr 2024 10:09:30 +0300
From: Ard Biesheuvel <ardb@...nel.org>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>
Cc: Ard Biesheuvel <ardb+git@...gle.com>, linux-kernel@...r.kernel.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, 29 Mar 2024 at 20:24, Andrii Nakryiko <andrii.nakryiko@...il.com> wrote:
>
> 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?
>

That shouldn't matter - the linker will not create the symbol unless
an unsatisfied reference to it exists anywhere in the input.

> >         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?
>

Yes, thanks for pointing that out.

> Other than that looks good to me:
>
> Acked-by: Andrii Nakryiko <andrii@...nel.org>
>

Thanks!

>
> >  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