diff mbox series

[bpf-next] bpf: Disable -Wmissing-declarations for globally-linked kfuncs

Message ID 20230816150634.1162838-1-void@manifault.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series [bpf-next] bpf: Disable -Wmissing-declarations for globally-linked kfuncs | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for bpf-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1455 this patch: 1455
netdev/cc_maintainers warning 30 maintainers not CCed: kuba@kernel.org lizefan.x@bytedance.com fw@strlen.de coreteam@netfilter.org davem@davemloft.net dsahern@kernel.org mhiramat@kernel.org mykolal@fb.com corbet@lwn.net alexandre.torgue@foss.st.com pabeni@redhat.com mcoquelin.stm32@gmail.com steffen.klassert@secunet.com pablo@netfilter.org cgroups@vger.kernel.org tj@kernel.org linux-kselftest@vger.kernel.org kadlec@netfilter.org rostedt@goodmis.org linux-doc@vger.kernel.org hannes@cmpxchg.org hawk@kernel.org linux-trace-kernel@vger.kernel.org netfilter-devel@vger.kernel.org netdev@vger.kernel.org herbert@gondor.apana.org.au shuah@kernel.org linux-arm-kernel@lists.infradead.org edumazet@google.com linux-stm32@st-md-mailman.stormreply.com
netdev/build_clang success Errors and warnings before: 1353 this patch: 1353
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 1478 this patch: 1478
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 133 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for veristat
bpf/vmtest-bpf-next-VM_Test-12 fail Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ${{ matrix.test }} on ${{ matrix.arch }} with ${{ matrix.toolchain_full }}
bpf/vmtest-bpf-next-VM_Test-2 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-4 fail Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-7 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-8 success Logs for veristat

Commit Message

David Vernet Aug. 16, 2023, 3:06 p.m. UTC
We recently got an lkp warning about missing declarations, as in e.g.
[0]. This warning is largely redundant with -Wmissing-prototypes, which
we already disable for kfuncs that have global linkage and are meant to
be exported in BTF, and called from BPF programs. Let's also disable
-Wmissing-declarations for kfuncs. For what it's worth, I wasn't able to
reproduce the warning even on W <= 3, so I can't actually be 100% sure
this fixes the issue.

[0]: https://lore.kernel.org/all/202308162115.Hn23vv3n-lkp@intel.com/

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202308162115.Hn23vv3n-lkp@intel.com/
Signed-off-by: David Vernet <void@manifault.com>
---
 Documentation/bpf/kfuncs.rst                          | 4 +++-
 kernel/bpf/bpf_iter.c                                 | 2 ++
 kernel/bpf/cpumask.c                                  | 2 ++
 kernel/bpf/helpers.c                                  | 2 ++
 kernel/bpf/map_iter.c                                 | 2 ++
 kernel/cgroup/rstat.c                                 | 2 ++
 kernel/trace/bpf_trace.c                              | 2 ++
 net/bpf/test_run.c                                    | 2 ++
 net/core/filter.c                                     | 4 ++++
 net/core/xdp.c                                        | 2 ++
 net/ipv4/fou_bpf.c                                    | 2 ++
 net/netfilter/nf_conntrack_bpf.c                      | 2 ++
 net/netfilter/nf_nat_bpf.c                            | 2 ++
 net/xfrm/xfrm_interface_bpf.c                         | 2 ++
 tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 2 ++
 15 files changed, 33 insertions(+), 1 deletion(-)

Comments

Yonghong Song Aug. 17, 2023, 3:38 a.m. UTC | #1
On 8/16/23 8:06 AM, David Vernet wrote:
> We recently got an lkp warning about missing declarations, as in e.g.
> [0]. This warning is largely redundant with -Wmissing-prototypes, which
> we already disable for kfuncs that have global linkage and are meant to
> be exported in BTF, and called from BPF programs. Let's also disable
> -Wmissing-declarations for kfuncs. For what it's worth, I wasn't able to
> reproduce the warning even on W <= 3, so I can't actually be 100% sure
> this fixes the issue.
> 
> [0]: https://lore.kernel.org/all/202308162115.Hn23vv3n-lkp@intel.com/

Okay, I just got a similar email to [0] which complains
   bpf_obj_new_impl, ..., bpf_cast_to_kern_ctx
missing declarations.

In the email, the used compiler is
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0

Unfortunately, I did not have gcc-7 to verify this.
Also, what is the minimum gcc version kernel supports? 5.1?

> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202308162115.Hn23vv3n-lkp@intel.com/
> Signed-off-by: David Vernet <void@manifault.com>
> ---
>   Documentation/bpf/kfuncs.rst                          | 4 +++-
>   kernel/bpf/bpf_iter.c                                 | 2 ++
>   kernel/bpf/cpumask.c                                  | 2 ++
>   kernel/bpf/helpers.c                                  | 2 ++
>   kernel/bpf/map_iter.c                                 | 2 ++
>   kernel/cgroup/rstat.c                                 | 2 ++
>   kernel/trace/bpf_trace.c                              | 2 ++
>   net/bpf/test_run.c                                    | 2 ++
>   net/core/filter.c                                     | 4 ++++
>   net/core/xdp.c                                        | 2 ++
>   net/ipv4/fou_bpf.c                                    | 2 ++
>   net/netfilter/nf_conntrack_bpf.c                      | 2 ++
>   net/netfilter/nf_nat_bpf.c                            | 2 ++
>   net/xfrm/xfrm_interface_bpf.c                         | 2 ++
>   tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c | 2 ++
>   15 files changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/bpf/kfuncs.rst b/Documentation/bpf/kfuncs.rst
> index 0d2647fb358d..62ce5a7b92b4 100644
> --- a/Documentation/bpf/kfuncs.rst
> +++ b/Documentation/bpf/kfuncs.rst
> @@ -36,10 +36,12 @@ prototype in a header for the wrapper kfunc.
>   
>   An example is given below::
>   
> -        /* Disables missing prototype warnings */
> +        /* Disables missing prototypes and declarations warnings */
>           __diag_push();
>           __diag_ignore_all("-Wmissing-prototypes",
>                             "Global kfuncs as their definitions will be in BTF");
> +        __diag_ignore_all("-Wmissing-declarations",
> +                          "Global kfuncs as their definitions will be in BTF");
>   
>           __bpf_kfunc struct task_struct *bpf_find_get_task_by_vpid(pid_t nr)
>           {
> diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c
> index 96856f130cbf..b8def6e4e5e8 100644
> --- a/kernel/bpf/bpf_iter.c
> +++ b/kernel/bpf/bpf_iter.c
> @@ -785,6 +785,8 @@ struct bpf_iter_num_kern {
>   __diag_push();
>   __diag_ignore_all("-Wmissing-prototypes",
>   		  "Global functions as their definitions will be in vmlinux BTF");
> +__diag_ignore_all("-Wmissing-declarations",
> +		  "Global functions as their definitions will be in vmlinux BTF");
>   
>   __bpf_kfunc int bpf_iter_num_new(struct bpf_iter_num *it, int start, int end)
>   {
[...]
Alexei Starovoitov Aug. 17, 2023, 3:48 a.m. UTC | #2
On Wed, Aug 16, 2023 at 8:38 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>
>
>
> On 8/16/23 8:06 AM, David Vernet wrote:
> > We recently got an lkp warning about missing declarations, as in e.g.
> > [0]. This warning is largely redundant with -Wmissing-prototypes, which
> > we already disable for kfuncs that have global linkage and are meant to
> > be exported in BTF, and called from BPF programs. Let's also disable
> > -Wmissing-declarations for kfuncs. For what it's worth, I wasn't able to
> > reproduce the warning even on W <= 3, so I can't actually be 100% sure
> > this fixes the issue.
> >
> > [0]: https://lore.kernel.org/all/202308162115.Hn23vv3n-lkp@intel.com/
>
> Okay, I just got a similar email to [0] which complains
>    bpf_obj_new_impl, ..., bpf_cast_to_kern_ctx
> missing declarations.
>
> In the email, the used compiler is
> compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
>
> Unfortunately, I did not have gcc-7 to verify this.
> Also, what is the minimum gcc version kernel supports? 5.1?

pahole and BTF might be broken in such old GCC too.
Maybe we should add:
config BPF_SYSCALL
        depends on GCC_VERSION >= 90000 || CLANG_VERSION >= 130000
David Vernet Aug. 17, 2023, 4:01 a.m. UTC | #3
On Wed, Aug 16, 2023 at 08:48:16PM -0700, Alexei Starovoitov wrote:
> On Wed, Aug 16, 2023 at 8:38 PM Yonghong Song <yonghong.song@linux.dev> wrote:
> >
> >
> >
> > On 8/16/23 8:06 AM, David Vernet wrote:
> > > We recently got an lkp warning about missing declarations, as in e.g.
> > > [0]. This warning is largely redundant with -Wmissing-prototypes, which
> > > we already disable for kfuncs that have global linkage and are meant to
> > > be exported in BTF, and called from BPF programs. Let's also disable
> > > -Wmissing-declarations for kfuncs. For what it's worth, I wasn't able to
> > > reproduce the warning even on W <= 3, so I can't actually be 100% sure
> > > this fixes the issue.
> > >
> > > [0]: https://lore.kernel.org/all/202308162115.Hn23vv3n-lkp@intel.com/
> >
> > Okay, I just got a similar email to [0] which complains
> >    bpf_obj_new_impl, ..., bpf_cast_to_kern_ctx
> > missing declarations.
> >
> > In the email, the used compiler is
> > compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
> >
> > Unfortunately, I did not have gcc-7 to verify this.
> > Also, what is the minimum gcc version kernel supports? 5.1?
> 
> pahole and BTF might be broken in such old GCC too.
> Maybe we should add:
> config BPF_SYSCALL
>         depends on GCC_VERSION >= 90000 || CLANG_VERSION >= 130000

It seems prudent to formally declare minimum compiler versions. Though
modern gcc and clang also support -Wmissing-declarations, so maybe we
should merge this patch regardless? Just unfortunate to have to add even
more boilerplate just to get the compiler off our backs.
Yonghong Song Aug. 17, 2023, 6:08 a.m. UTC | #4
On 8/16/23 8:48 PM, Alexei Starovoitov wrote:
> On Wed, Aug 16, 2023 at 8:38 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>>
>>
>>
>> On 8/16/23 8:06 AM, David Vernet wrote:
>>> We recently got an lkp warning about missing declarations, as in e.g.
>>> [0]. This warning is largely redundant with -Wmissing-prototypes, which
>>> we already disable for kfuncs that have global linkage and are meant to
>>> be exported in BTF, and called from BPF programs. Let's also disable
>>> -Wmissing-declarations for kfuncs. For what it's worth, I wasn't able to
>>> reproduce the warning even on W <= 3, so I can't actually be 100% sure
>>> this fixes the issue.
>>>
>>> [0]: https://lore.kernel.org/all/202308162115.Hn23vv3n-lkp@intel.com/
>>
>> Okay, I just got a similar email to [0] which complains
>>     bpf_obj_new_impl, ..., bpf_cast_to_kern_ctx
>> missing declarations.
>>
>> In the email, the used compiler is
>> compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
>>
>> Unfortunately, I did not have gcc-7 to verify this.
>> Also, what is the minimum gcc version kernel supports? 5.1?
> 
> pahole and BTF might be broken in such old GCC too.
> Maybe we should add:
> config BPF_SYSCALL
>          depends on GCC_VERSION >= 90000 || CLANG_VERSION >= 130000

Do you remember what kind of issues pahole/BTF have for
< 9.0 gcc and < 13.0 clang?
Daniel Borkmann Aug. 17, 2023, 2:35 p.m. UTC | #5
On 8/17/23 6:01 AM, David Vernet wrote:
> On Wed, Aug 16, 2023 at 08:48:16PM -0700, Alexei Starovoitov wrote:
>> On Wed, Aug 16, 2023 at 8:38 PM Yonghong Song <yonghong.song@linux.dev> wrote:
>>> On 8/16/23 8:06 AM, David Vernet wrote:
>>>> We recently got an lkp warning about missing declarations, as in e.g.
>>>> [0]. This warning is largely redundant with -Wmissing-prototypes, which
>>>> we already disable for kfuncs that have global linkage and are meant to
>>>> be exported in BTF, and called from BPF programs. Let's also disable
>>>> -Wmissing-declarations for kfuncs. For what it's worth, I wasn't able to
>>>> reproduce the warning even on W <= 3, so I can't actually be 100% sure
>>>> this fixes the issue.
>>>>
>>>> [0]: https://lore.kernel.org/all/202308162115.Hn23vv3n-lkp@intel.com/
>>>
>>> Okay, I just got a similar email to [0] which complains
>>>     bpf_obj_new_impl, ..., bpf_cast_to_kern_ctx
>>> missing declarations.
>>>
>>> In the email, the used compiler is
>>> compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
>>>
>>> Unfortunately, I did not have gcc-7 to verify this.
>>> Also, what is the minimum gcc version kernel supports? 5.1?
>>
>> pahole and BTF might be broken in such old GCC too.
>> Maybe we should add:
>> config BPF_SYSCALL
>>          depends on GCC_VERSION >= 90000 || CLANG_VERSION >= 130000
> 
> It seems prudent to formally declare minimum compiler versions. Though
> modern gcc and clang also support -Wmissing-declarations, so maybe we
> should merge this patch regardless? Just unfortunate to have to add even
> more boilerplate just to get the compiler off our backs.

Urgh, to restrict BPF syscall with such `depends on` would be super ugly. Why
can't we just move this boilerplate behind a macro instead of copying this
everywhere? For example the below on top of your patch builds just fine on my
side:

diff --git a/include/linux/btf.h b/include/linux/btf.h
index df64cc642074..6a873a652001 100644
--- a/include/linux/btf.h
+++ b/include/linux/btf.h
@@ -83,6 +83,16 @@
   */
  #define __bpf_kfunc __used noinline

+#define __bpf_kfunc_start	\
+	__diag_push();	\
+	__diag_ignore_all("-Wmissing-prototypes",	\
+			  "Global functions as their definitions will be in vmlinux BTF");	\
+	__diag_ignore_all("-Wmissing-declarations",	\
+			  "Global functions as their definitions will be in vmlinux BTF");
+
+#define __bpf_kfunc_end	\
+	__diag_pop();
+
  /*
   * Return the name of the passed struct, if exists, or halt the build if for
   * example the structure gets renamed. In this way, developers have to revisit
diff --git a/net/core/filter.c b/net/core/filter.c
index c2b32b94c6bd..08dd0dd710dd 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -11724,11 +11724,7 @@ bpf_sk_base_func_proto(enum bpf_func_id func_id)
  	return func;
  }

-__diag_push();
-__diag_ignore_all("-Wmissing-prototypes",
-		  "Global functions as their definitions will be in vmlinux BTF");
-__diag_ignore_all("-Wmissing-declarations",
-		  "Global functions as their definitions will be in vmlinux BTF");
+__bpf_kfunc_start
  __bpf_kfunc int bpf_dynptr_from_skb(struct sk_buff *skb, u64 flags,
  				    struct bpf_dynptr_kern *ptr__uninit)
  {
@@ -11754,7 +11750,7 @@ __bpf_kfunc int bpf_dynptr_from_xdp(struct xdp_buff *xdp, u64 flags,

  	return 0;
  }
-__diag_pop();
+__bpf_kfunc_end

  int bpf_dynptr_from_skb_rdonly(struct sk_buff *skb, u64 flags,
  			       struct bpf_dynptr_kern *ptr__uninit)

Thanks,
Daniel
Anton Protopopov Aug. 17, 2023, 2:45 p.m. UTC | #6
On Thu, Aug 17, 2023 at 04:35:26PM +0200, Daniel Borkmann wrote:
> On 8/17/23 6:01 AM, David Vernet wrote:
> > On Wed, Aug 16, 2023 at 08:48:16PM -0700, Alexei Starovoitov wrote:
> > > On Wed, Aug 16, 2023 at 8:38 PM Yonghong Song <yonghong.song@linux.dev> wrote:
> > > > On 8/16/23 8:06 AM, David Vernet wrote:
> > > > > We recently got an lkp warning about missing declarations, as in e.g.
> > > > > [0]. This warning is largely redundant with -Wmissing-prototypes, which
> > > > > we already disable for kfuncs that have global linkage and are meant to
> > > > > be exported in BTF, and called from BPF programs. Let's also disable
> > > > > -Wmissing-declarations for kfuncs. For what it's worth, I wasn't able to
> > > > > reproduce the warning even on W <= 3, so I can't actually be 100% sure
> > > > > this fixes the issue.
> > > > > 
> > > > > [0]: https://lore.kernel.org/all/202308162115.Hn23vv3n-lkp@intel.com/
> > > > 
> > > > Okay, I just got a similar email to [0] which complains
> > > >     bpf_obj_new_impl, ..., bpf_cast_to_kern_ctx
> > > > missing declarations.
> > > > 
> > > > In the email, the used compiler is
> > > > compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
> > > > 
> > > > Unfortunately, I did not have gcc-7 to verify this.
> > > > Also, what is the minimum gcc version kernel supports? 5.1?
> > > 
> > > pahole and BTF might be broken in such old GCC too.
> > > Maybe we should add:
> > > config BPF_SYSCALL
> > >          depends on GCC_VERSION >= 90000 || CLANG_VERSION >= 130000
> > 
> > It seems prudent to formally declare minimum compiler versions. Though
> > modern gcc and clang also support -Wmissing-declarations, so maybe we
> > should merge this patch regardless? Just unfortunate to have to add even
> > more boilerplate just to get the compiler off our backs.
> 
> Urgh, to restrict BPF syscall with such `depends on` would be super ugly. Why
> can't we just move this boilerplate behind a macro instead of copying this
> everywhere? For example the below on top of your patch builds just fine on my
> side:
> 
> diff --git a/include/linux/btf.h b/include/linux/btf.h
> index df64cc642074..6a873a652001 100644
> --- a/include/linux/btf.h
> +++ b/include/linux/btf.h
> @@ -83,6 +83,16 @@
>   */
>  #define __bpf_kfunc __used noinline
> 
> +#define __bpf_kfunc_start	\
> +	__diag_push();	\
> +	__diag_ignore_all("-Wmissing-prototypes",	\
> +			  "Global functions as their definitions will be in vmlinux BTF");	\
> +	__diag_ignore_all("-Wmissing-declarations",	\
> +			  "Global functions as their definitions will be in vmlinux BTF");
> +

This will not solve the robot's compain, as it fails on gcc7. The
__diag_ignore_all for gcc is defined as

    #if GCC_VERSION >= 80000
    #define __diag_GCC_8(s)         __diag(s)
    #else
    #define __diag_GCC_8(s)
    #endif

    #define __diag_ignore_all(option, comment) \
            __diag_GCC(8, ignore, option)

so adding more __diag_ignore_all's will not do anything.  This is better to
patch __diag_ignore_all to include older gcc versions if anybody needs them.

> +#define __bpf_kfunc_end	\
> +	__diag_pop();
> +
>  /*
>   * Return the name of the passed struct, if exists, or halt the build if for
>   * example the structure gets renamed. In this way, developers have to revisit
> diff --git a/net/core/filter.c b/net/core/filter.c
> index c2b32b94c6bd..08dd0dd710dd 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -11724,11 +11724,7 @@ bpf_sk_base_func_proto(enum bpf_func_id func_id)
>  	return func;
>  }
> 
> -__diag_push();
> -__diag_ignore_all("-Wmissing-prototypes",
> -		  "Global functions as their definitions will be in vmlinux BTF");
> -__diag_ignore_all("-Wmissing-declarations",
> -		  "Global functions as their definitions will be in vmlinux BTF");
> +__bpf_kfunc_start
>  __bpf_kfunc int bpf_dynptr_from_skb(struct sk_buff *skb, u64 flags,
>  				    struct bpf_dynptr_kern *ptr__uninit)
>  {
> @@ -11754,7 +11750,7 @@ __bpf_kfunc int bpf_dynptr_from_xdp(struct xdp_buff *xdp, u64 flags,
> 
>  	return 0;
>  }
> -__diag_pop();
> +__bpf_kfunc_end
> 
>  int bpf_dynptr_from_skb_rdonly(struct sk_buff *skb, u64 flags,
>  			       struct bpf_dynptr_kern *ptr__uninit)
> 
> Thanks,
> Daniel
diff mbox series

Patch

diff --git a/Documentation/bpf/kfuncs.rst b/Documentation/bpf/kfuncs.rst
index 0d2647fb358d..62ce5a7b92b4 100644
--- a/Documentation/bpf/kfuncs.rst
+++ b/Documentation/bpf/kfuncs.rst
@@ -36,10 +36,12 @@  prototype in a header for the wrapper kfunc.
 
 An example is given below::
 
-        /* Disables missing prototype warnings */
+        /* Disables missing prototypes and declarations warnings */
         __diag_push();
         __diag_ignore_all("-Wmissing-prototypes",
                           "Global kfuncs as their definitions will be in BTF");
+        __diag_ignore_all("-Wmissing-declarations",
+                          "Global kfuncs as their definitions will be in BTF");
 
         __bpf_kfunc struct task_struct *bpf_find_get_task_by_vpid(pid_t nr)
         {
diff --git a/kernel/bpf/bpf_iter.c b/kernel/bpf/bpf_iter.c
index 96856f130cbf..b8def6e4e5e8 100644
--- a/kernel/bpf/bpf_iter.c
+++ b/kernel/bpf/bpf_iter.c
@@ -785,6 +785,8 @@  struct bpf_iter_num_kern {
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in vmlinux BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in vmlinux BTF");
 
 __bpf_kfunc int bpf_iter_num_new(struct bpf_iter_num *it, int start, int end)
 {
diff --git a/kernel/bpf/cpumask.c b/kernel/bpf/cpumask.c
index 6983af8e093c..111b0e062e7f 100644
--- a/kernel/bpf/cpumask.c
+++ b/kernel/bpf/cpumask.c
@@ -37,6 +37,8 @@  static bool cpu_valid(u32 cpu)
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global kfuncs as their definitions will be in BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global kfuncs as their definitions will be in BTF");
 
 /**
  * bpf_cpumask_create() - Create a mutable BPF cpumask.
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c
index eb91cae0612a..6d2f84371892 100644
--- a/kernel/bpf/helpers.c
+++ b/kernel/bpf/helpers.c
@@ -1885,6 +1885,8 @@  void bpf_rb_root_free(const struct btf_field *field, void *rb_root,
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in vmlinux BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in vmlinux BTF");
 
 __bpf_kfunc void *bpf_obj_new_impl(u64 local_type_id__k, void *meta__ign)
 {
diff --git a/kernel/bpf/map_iter.c b/kernel/bpf/map_iter.c
index 6fc9dae9edc8..f7c7c5044630 100644
--- a/kernel/bpf/map_iter.c
+++ b/kernel/bpf/map_iter.c
@@ -196,6 +196,8 @@  late_initcall(bpf_map_iter_init);
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in vmlinux BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in vmlinux BTF");
 
 __bpf_kfunc s64 bpf_map_sum_elem_count(const struct bpf_map *map)
 {
diff --git a/kernel/cgroup/rstat.c b/kernel/cgroup/rstat.c
index 2542c21b6b6d..f5231a58ad3c 100644
--- a/kernel/cgroup/rstat.c
+++ b/kernel/cgroup/rstat.c
@@ -162,6 +162,8 @@  static struct cgroup *cgroup_rstat_cpu_pop_updated(struct cgroup *pos,
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "kfuncs which will be used in BPF programs");
+__diag_ignore_all("-Wmissing-declarations",
+		  "kfuncs which will be used in BPF programs");
 
 __weak noinline void bpf_rstat_flush(struct cgroup *cgrp,
 				     struct cgroup *parent, int cpu)
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 792445e1f3f0..1fa197aa428c 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1224,6 +1224,8 @@  static const struct bpf_func_proto bpf_get_func_arg_cnt_proto = {
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "kfuncs which will be used in BPF programs");
+__diag_ignore_all("-Wmissing-declarations",
+		  "kfuncs which will be used in BPF programs");
 
 /**
  * bpf_lookup_user_key - lookup a key by its serial
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
index 57a7a64b84ed..38aedb720a52 100644
--- a/net/bpf/test_run.c
+++ b/net/bpf/test_run.c
@@ -506,6 +506,8 @@  static int bpf_test_finish(const union bpf_attr *kattr,
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in vmlinux BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in vmlinux BTF");
 __bpf_kfunc int bpf_fentry_test1(int a)
 {
 	return a + 1;
diff --git a/net/core/filter.c b/net/core/filter.c
index a094694899c9..c2b32b94c6bd 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -11727,6 +11727,8 @@  bpf_sk_base_func_proto(enum bpf_func_id func_id)
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in vmlinux BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in vmlinux BTF");
 __bpf_kfunc int bpf_dynptr_from_skb(struct sk_buff *skb, u64 flags,
 				    struct bpf_dynptr_kern *ptr__uninit)
 {
@@ -11808,6 +11810,8 @@  late_initcall(bpf_kfunc_init);
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in vmlinux BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in vmlinux BTF");
 
 /* bpf_sock_destroy: Destroy the given socket with ECONNABORTED error code.
  *
diff --git a/net/core/xdp.c b/net/core/xdp.c
index a70670fe9a2d..3d14e7be411d 100644
--- a/net/core/xdp.c
+++ b/net/core/xdp.c
@@ -699,6 +699,8 @@  struct xdp_frame *xdpf_clone(struct xdp_frame *xdpf)
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in vmlinux BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in vmlinux BTF");
 
 /**
  * bpf_xdp_metadata_rx_timestamp - Read XDP frame RX timestamp.
diff --git a/net/ipv4/fou_bpf.c b/net/ipv4/fou_bpf.c
index 3760a14b6b57..2b394703770a 100644
--- a/net/ipv4/fou_bpf.c
+++ b/net/ipv4/fou_bpf.c
@@ -25,6 +25,8 @@  enum bpf_fou_encap_type {
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in BTF");
 
 /* bpf_skb_set_fou_encap - Set FOU encap parameters
  *
diff --git a/net/netfilter/nf_conntrack_bpf.c b/net/netfilter/nf_conntrack_bpf.c
index c7a6114091ae..e24e2e4b2d49 100644
--- a/net/netfilter/nf_conntrack_bpf.c
+++ b/net/netfilter/nf_conntrack_bpf.c
@@ -233,6 +233,8 @@  static int _nf_conntrack_btf_struct_access(struct bpf_verifier_log *log,
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in nf_conntrack BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in nf_conntrack BTF");
 
 /* bpf_xdp_ct_alloc - Allocate a new CT entry
  *
diff --git a/net/netfilter/nf_nat_bpf.c b/net/netfilter/nf_nat_bpf.c
index 141ee7783223..e903a6eb732e 100644
--- a/net/netfilter/nf_nat_bpf.c
+++ b/net/netfilter/nf_nat_bpf.c
@@ -15,6 +15,8 @@ 
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in nf_nat BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in nf_nat BTF");
 
 /* bpf_ct_set_nat_info - Set source or destination nat address
  *
diff --git a/net/xfrm/xfrm_interface_bpf.c b/net/xfrm/xfrm_interface_bpf.c
index d74f3fd20f2b..d40060bcc398 100644
--- a/net/xfrm/xfrm_interface_bpf.c
+++ b/net/xfrm/xfrm_interface_bpf.c
@@ -30,6 +30,8 @@  struct bpf_xfrm_info {
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in xfrm_interface BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in xfrm_interface BTF");
 
 /* bpf_skb_get_xfrm_info - Get XFRM metadata
  *
diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
index cefc5dd72573..201a41cd47e5 100644
--- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
@@ -42,6 +42,8 @@  struct bpf_testmod_struct_arg_4 {
 __diag_push();
 __diag_ignore_all("-Wmissing-prototypes",
 		  "Global functions as their definitions will be in bpf_testmod.ko BTF");
+__diag_ignore_all("-Wmissing-declarations",
+		  "Global functions as their definitions will be in bpf_testmod.ko BTF");
 
 noinline int
 bpf_testmod_test_struct_arg_1(struct bpf_testmod_struct_arg_2 a, int b, int c) {