bpf.h: fix clang compiler warning with unpriv_ebpf_notify()
PATCH 1/1 bpf.h: fix clang compiler warning with unpriv_ebpf_notify()
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/[email protected]/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
---
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(+)
include/linux/bpf.h +3 -0
@@ -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 ) {
Signature · 1 line
2.35.1
Quoted 32 lines · Luis Chamberlain
The recent commit "bpf: Move BPF sysctls from
kernel/sysctl.cto 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/[email protected]/configAnd 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/bashkernel/bpf/syscall.o
DESCEND objtoolCALL 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__weakunpriv_ebpf_notify(int new_state)
^
staticFixes 2900005ea287 ("bpf: Move BPF sysctls from kernel/sysctl.c to BPF core")Signed-off-by Luis Chamberlain <[email protected]>---
Daniel,
Quoted 8 lines
Given what we did fore
2900005ea287("bpf: Move BPF sysctls fromkernel/sysctl.cto 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.hwas your ideal preference.
After testing this on sysctl-testing without issues going to move this to sysctl-next now.
Luis
Quoted 40 lines · Luis Chamberlain
Quoted 38 lines · Luis Chamberlain
The recent commit "bpf: Move BPF sysctls from
kernel/sysctl.cto 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/[email protected]/configAnd 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/bashkernel/bpf/syscall.o
DESCEND objtoolCALL 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__weakunpriv_ebpf_notify(int new_state)
^
staticFixes 2900005ea287 ("bpf: Move BPF sysctls from kernel/sysctl.c to BPF core")Signed-off-by Luis Chamberlain <[email protected]>---
Daniel,
Given what we did fore
2900005ea287("bpf: Move BPF sysctls fromkernel/sysctl.cto 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.
Quoted 5 lines
Quoted 2 lines
Also, it wasn't clear if putting this forward declaration on
bpf.hwas your ideal preference.After testing this on sysctl-testing without issues going to move this to sysctl-next now.
Hmm. No.
A similar patch should be in tip already. You have to wait for it to go through Linus's tree and back to whatever tree you use.
Borislav,
did you ship it yet?
Quoted 44 lines · Alexei Starovoitov
Quoted 43 lines · Luis Chamberlain
Quoted 40 lines · Luis Chamberlain
The recent commit "bpf: Move BPF sysctls from
kernel/sysctl.cto 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/[email protected]/configAnd 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/bashkernel/bpf/syscall.o
DESCEND objtoolCALL 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__weakunpriv_ebpf_notify(int new_state)
^
staticFixes 2900005ea287 ("bpf: Move BPF sysctls from kernel/sysctl.c to BPF core")Signed-off-by Luis Chamberlain <[email protected]>---
Daniel,
Given what we did fore
2900005ea287("bpf: Move BPF sysctls fromkernel/sysctl.cto 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.hwas your ideal preference.
Quoted 6 lines
Quoted 2 lines
After testing this on sysctl-testing without issues going to move this to sysctl-next now.
Hmm. No.
A similar patch should be in tip already. You have to wait for it to go through Linus's tree and back to whatever tree you use.
I'm a bit confused, the patch in question which my patch fixes should only be in my sysctl-next tree at this point, not in Linus's tree.
Luis
Daniel Borkmann
maintainerQuoted 47 lines · Luis Chamberlain
Quoted 46 lines · Alexei Starovoitov
Quoted 44 lines · Luis Chamberlain
Quoted 32 lines · Luis Chamberlain
The recent commit "bpf: Move BPF sysctls from
kernel/sysctl.cto 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/[email protected]/configAnd 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/bashkernel/bpf/syscall.o
DESCEND objtoolCALL 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__weakunpriv_ebpf_notify(int new_state)
^
staticFixes 2900005ea287 ("bpf: Move BPF sysctls from kernel/sysctl.c to BPF core")Signed-off-by Luis Chamberlain <[email protected]>---
Daniel,
Quoted 8 lines
Given what we did fore
2900005ea287("bpf: Move BPF sysctls fromkernel/sysctl.cto 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.hwas your ideal preference.After testing this on sysctl-testing without issues going to move this to sysctl-next now.
Quoted 6 lines
Quoted 3 lines
Hmm. No.
A similar patch should be in tip already. You have to wait for it to go through Linus's tree and back to whatever tree you use.I'm a bit confused, the patch in question which my patch fixes should only be in my sysctl-next tree at this point, not in Linus's tree.
Borislav was planning to route it via tip tree, maybe confusion was that the fix in the link below is from Josh:
https://lore.kernel.org/bpf/CAADnVQKjfQMG_zFf9F9P7m0UzqESs7XoRy=udqrDSodxa8yBpg@mail.gmail.com/
But I presume this is routed as fix to Linus, so should land in both sysctl and bpf tree at some point after re-sync.
Thanks,
Daniel
Quoted 52 lines · Daniel Borkmann
Quoted 51 lines · Luis Chamberlain
Quoted 49 lines · Alexei Starovoitov
Quoted 39 lines · Luis Chamberlain
Quoted 38 lines · Luis Chamberlain
The recent commit "bpf: Move BPF sysctls from
kernel/sysctl.cto 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/[email protected]/configAnd 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/bashkernel/bpf/syscall.o
DESCEND objtoolCALL 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__weakunpriv_ebpf_notify(int new_state)
^
staticFixes 2900005ea287 ("bpf: Move BPF sysctls from kernel/sysctl.c to BPF core")Signed-off-by Luis Chamberlain <[email protected]>---
Daniel,
Given what we did fore
2900005ea287("bpf: Move BPF sysctls fromkernel/sysctl.cto 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.Quoted 5 lines
Quoted 2 lines
Also, it wasn't clear if putting this forward declaration on
bpf.hwas your ideal preference.After testing this on sysctl-testing without issues going to move this to sysctl-next now.
Hmm. No.
A similar patch should be in tip already. You have to wait for it to go through Linus's tree and back to whatever tree you use.
Quoted 7 lines
Quoted 2 lines
I'm a bit confused, the patch in question which my patch fixes should only be in my sysctl-next tree at this point, not in Linus's tree.
Borislav was planning to route it via tip tree, maybe confusion was that the fix in the link below is from Josh:
https://lore.kernel.org/bpf/CAADnVQKjfQMG_zFf9F9P7m0UzqESs7XoRy=udqrDSodxa8yBpg@mail.gmail.com/
Ah, Josh posted a fix for the same compile warning.
Quoted 2 lines
But I presume this is routed as fix to Linus, so should land in both sysctl and bpf tree at some point after re-sync.
It may be the case indeed that the code in question was triggering a compile warning without the patch I have merged which moves the BPF sysctls ("bpf: Move BPF sysctls from kernel/sysctl.c to BPF core").
So I'll just drop my fix.
Luis
Daniel Borkmann
maintainerQuoted 61 lines · Luis Chamberlain
Quoted 52 lines · Daniel Borkmann
Quoted 51 lines · Luis Chamberlain
Quoted 49 lines · Alexei Starovoitov
Quoted 39 lines · Luis Chamberlain
Quoted 38 lines · Luis Chamberlain
The recent commit "bpf: Move BPF sysctls from
kernel/sysctl.cto 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/[email protected]/configAnd 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/bashkernel/bpf/syscall.o
DESCEND objtool
CALLscripts/atomic/check-atomics.sh
CALLscripts/checksyscalls.sh
CCkernel/bpf/syscall.okernel/bpf/syscall.c:4944:13: warning: no previous prototype for function 'unpriv_ebpf_notify' [-Wmissing-prototypes]
void__weakunpriv_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__weakunpriv_ebpf_notify(int new_state)
^
staticFixes 2900005ea287 ("bpf: Move BPF sysctls from kernel/sysctl.c to BPF core")Signed-off-by Luis Chamberlain <[email protected]>---
Daniel,
Given what we did fore
2900005ea287("bpf: Move BPF sysctls fromkernel/sysctl.cto 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.Quoted 5 lines
Quoted 2 lines
Also, it wasn't clear if putting this forward declaration on
bpf.hwas your ideal preference.After testing this on sysctl-testing without issues going to move this to sysctl-next now.
Hmm. No.
A similar patch should be in tip already. You have to wait for it to go through Linus's tree and back to whatever tree you use.Quoted 7 lines
Quoted 2 lines
I'm a bit confused, the patch in question which my patch fixes should only be in my sysctl-next tree at this point, not in Linus's tree.
Borislav was planning to route it via tip tree, maybe confusion was that the fix in the link below is from Josh:
https://lore.kernel.org/bpf/CAADnVQKjfQMG_zFf9F9P7m0UzqESs7XoRy=udqrDSodxa8yBpg@mail.gmail.com/
Quoted 8 lines
Ah, Josh posted a fix for the same compile warning.
Quoted 2 lines
But I presume this is routed as fix to Linus, so should land in both sysctl and bpf tree at some point after re-sync.
It may be the case indeed that the code in question was triggering a compile warning without the patch I have merged which moves the BPF sysctls ("bpf: Move BPF sysctls from
kernel/sysctl.cto BPF core").
Yes, it was indeed independent of the move.
Quoted 1 line
So I'll just drop my fix.
Agree, that's the best way forward, thanks Luis!
Quoted 6 lines · Daniel Borkmann
Borislav was planning to route it via tip tree, maybe confusion was that the fix in the link below is from Josh:
https://lore.kernel.org/bpf/CAADnVQKjfQMG_zFf9F9P7m0UzqESs7XoRy=udqrDSodxa8yBpg@mail.gmail.com/
But I presume this is routed as fix to Linus,
Yap: https://git.kernel.org/tip/2147c438fde135d6c145a96e373d9348e7076f7f
Will go to Linus in the next merge window.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquette