public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: ast@kernel.org, daniel@iogearbox.net
Cc: songliubraving@fb.com, bpf@vger.kernel.org,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
	mcgrof@kernel.org
Subject: [PATCH] bpf.h: fix clang compiler warning with unpriv_ebpf_notify()
Date: Mon,  9 May 2022 13:36:23 -0700	[thread overview]
Message-ID: <20220509203623.3856965-1-mcgrof@kernel.org> (raw)

The recent commit "bpf: Move BPF sysctls from kernel/sysctl.c to BPF core"
triggered 0-day to issue an email for what seems to have been an old
clang warning. So this issue should have existed before as well, from
what I can tell. The issue is that clang expects a forward declaration
for routines declared as weak while gcc does not.

This can be reproduced with 0-day's x86_64-randconfig-c007
https://download.01.org/0day-ci/archive/20220424/202204240008.JDntM9cU-lkp@intel.com/config

And using:

COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64 SHELL=/bin/bash kernel/bpf/syscall.o
Compiler will be installed in /home/mcgrof/0day
make --keep-going HOSTCC=/home/mcgrof/0day/clang/bin/clang CC=/home/mcgrof/0day/clang/bin/clang LD=/home/mcgrof/0day/clang/bin/ld.lld HOSTLD=/home/mcgrof/0day/clang/bin/ld.lld AR=llvm-ar NM=llvm-nm STRIP=llvm-strip OBJCOPY=llvm-objcopy OBJDUMP=llvm-objdump OBJSIZE=llvm-size READELF=llvm-readelf HOSTCXX=clang++ HOSTAR=llvm-ar CROSS_COMPILE=x86_64-linux-gnu- --jobs=24 W=1 ARCH=x86_64 SHELL=/bin/bash kernel/bpf/syscall.o
  DESCEND objtool
  CALL    scripts/atomic/check-atomics.sh
  CALL    scripts/checksyscalls.sh
  CC      kernel/bpf/syscall.o
kernel/bpf/syscall.c:4944:13: warning: no previous prototype for function 'unpriv_ebpf_notify' [-Wmissing-prototypes]
void __weak unpriv_ebpf_notify(int new_state)
            ^
kernel/bpf/syscall.c:4944:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void __weak unpriv_ebpf_notify(int new_state)
^
static

Fixes: 2900005ea287 ("bpf: Move BPF sysctls from kernel/sysctl.c to BPF core")
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---

Daniel,

Given what we did fore 2900005ea287 ("bpf: Move BPF sysctls from
kernel/sysctl.c to BPF core") where I had pulled pr/bpf-sysctl a
while ago into sysctl-next and then merged the patch in question,
should I just safely carry this patch onto sysctl-next? Let me know
how you'd like to proceed.

Also, it wasn't clear if putting this forward declaration on
bpf.h was your ideal preference.

  Luis

 include/linux/bpf.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index bdb5298735ce..bd3e17a9f821 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1551,6 +1551,9 @@ bpf_map_alloc_percpu(const struct bpf_map *map, size_t size, size_t align,
 #endif
 
 extern int sysctl_unprivileged_bpf_disabled;
+#ifdef CONFIG_SYSCTL
+void unpriv_ebpf_notify(int new_state);
+#endif
 
 static inline bool bpf_allow_ptr_leaks(void)
 {
-- 
2.35.1


             reply	other threads:[~2022-05-09 20:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-09 20:36 Luis Chamberlain [this message]
2022-05-11 15:58 ` [PATCH] bpf.h: fix clang compiler warning with unpriv_ebpf_notify() Luis Chamberlain
2022-05-11 16:03   ` Alexei Starovoitov
2022-05-11 16:08     ` Luis Chamberlain
2022-05-11 16:17       ` Daniel Borkmann
2022-05-11 16:24         ` Luis Chamberlain
2022-05-11 16:38           ` Daniel Borkmann
2022-05-11 16:45         ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220509203623.3856965-1-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=songliubraving@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox