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: <20211111001359.3v2yjha5nxkdtoju@apollo.localdomain>
Date:   Thu, 11 Nov 2021 05:43:59 +0530
From:   Kumar Kartikeya Dwivedi <memxor@...il.com>
To:     Vinicius Costa Gomes <vinicius.gomes@...el.com>
Cc:     Alexei Starovoitov <alexei.starovoitov@...il.com>,
        bpf <bpf@...r.kernel.org>,
        Network Development <netdev@...r.kernel.org>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Martin KaFai Lau <kafai@...com>,
        Andrii Nakryiko <andrii@...nel.org>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>
Subject: Re: [PATCH net v2] bpf: Fix build when CONFIG_BPF_SYSCALL is disabled

On Thu, Nov 11, 2021 at 05:21:53AM IST, Vinicius Costa Gomes wrote:
> Alexei Starovoitov <alexei.starovoitov@...il.com> writes:
>
> >> Thanks for the fix.
> >>
> >> But instead of moving this to core.c, you can probably make the btf.h
> >> declaration conditional on CONFIG_BPF_SYSCALL, since this is not useful in
> >> isolation (only used by verifier for module kfunc support). For the case of
> >> kfunc_btf_id_list variables, just define it as an empty struct and static
> >> variables, since the definition is still inside btf.c. So it becomes a noop for
> >> !CONFIG_BPF_SYSCALL.
> >>
> >> I am also not sure whether BTF is useful without BPF support, but maybe I'm
> >> missing some usecase.
> >
> > Unlikely. I would just disallow such config instead of sprinkling
> > the code with ifdefs.
>
> Is something like this what you have in mind?
>
> diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
> index 6fdbf9613aec..eae860c86e26 100644
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -316,6 +316,7 @@ config DEBUG_INFO_BTF
>  	bool "Generate BTF typeinfo"
>  	depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
>  	depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
> +	depends on BPF_SYSCALL
>  	help
>  	  Generate deduplicated BTF type information from DWARF debug info.
>  	  Turning this on expects presence of pahole tool, which will convert
>
>

BTW, you will need a little more than that, I suspect the compiler optimizes out
the register/unregister call so we don't see a build failure, but adding a side
effect gives me errors, so something like this should resolve the problem (since
kfunc_btf_id_list variable definition is behind CONFIG_BPF_SYSCALL).

diff --git a/include/linux/btf.h b/include/linux/btf.h
index 203eef993d76..e9881ef9e9aa 100644
--- a/include/linux/btf.h
+++ b/include/linux/btf.h
@@ -254,6 +254,8 @@ void unregister_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
                                 struct kfunc_btf_id_set *s);
 bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist, u32 kfunc_id,
                              struct module *owner);
+extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
+extern struct kfunc_btf_id_list prog_test_kfunc_list;
 #else
 static inline void register_kfunc_btf_id_set(struct kfunc_btf_id_list *l,
                                             struct kfunc_btf_id_set *s)
@@ -268,13 +270,13 @@ static inline bool bpf_check_mod_kfunc_call(struct kfunc_btf_id_list *klist,
 {
        return false;
 }
+struct kfunc_btf_id_list {};
+static struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list __maybe_unused;
+static struct kfunc_btf_id_list prog_test_kfunc_list __maybe_unused;
+
 #endif

 #define DEFINE_KFUNC_BTF_ID_SET(set, name)                                     \
        struct kfunc_btf_id_set name = { LIST_HEAD_INIT(name.list), (set),     \
                                         THIS_MODULE }
-
-extern struct kfunc_btf_id_list bpf_tcp_ca_kfunc_list;
-extern struct kfunc_btf_id_list prog_test_kfunc_list;
-
 #endif

--
Kartikeya

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ