diff mbox series

[bpf-next,v2,3/8] bpf: Abstract out functions to check sleepable helpers

Message ID 20221108074104.263145-1-yhs@fb.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series bpf: Add bpf_rcu_read_lock() support | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-VM_Test-1 pending Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-5 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-6 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-14 fail Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-7 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-11 fail Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs_no_alu32_parallel on s390x with gcc
bpf/vmtest-bpf-next-PR fail PR summary
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_parallel on s390x with gcc
netdev/tree_selection success Clearly marked for bpf-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 1516 this patch: 1516
netdev/cc_maintainers warning 11 maintainers not CCed: sdf@google.com kpsingh@kernel.org haoluo@google.com jackmanb@chromium.org revest@chromium.org jolsa@kernel.org rostedt@goodmis.org martin.lau@linux.dev mhiramat@kernel.org song@kernel.org john.fastabend@gmail.com
netdev/build_clang success Errors and warnings before: 266 this patch: 266
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
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: 1584 this patch: 1584
netdev/checkpatch warning CHECK: Please use a blank line after function/struct/union/enum declarations WARNING: line length of 83 exceeds 80 columns WARNING: line length of 84 exceeds 80 columns WARNING: line length of 87 exceeds 80 columns WARNING: line length of 88 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Yonghong Song Nov. 8, 2022, 7:41 a.m. UTC
Abstract out two functions to check whether a particular helper
is sleepable or not for bpf_lsm and bpf_trace. These two
functions will be used later to check whether a helper is
sleepable or not in verifier. There is no functionality
change.

Signed-off-by: Yonghong Song <yhs@fb.com>
---
 include/linux/bpf_lsm.h      |  6 ++++++
 include/linux/trace_events.h |  8 ++++++++
 kernel/bpf/bpf_lsm.c         | 20 ++++++++++++++++----
 kernel/trace/bpf_trace.c     | 22 ++++++++++++++++++----
 4 files changed, 48 insertions(+), 8 deletions(-)

Comments

kernel test robot Nov. 8, 2022, 10:43 a.m. UTC | #1
Hi Yonghong,

I love your patch! Perhaps something to improve:

[auto build test WARNING on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Yonghong-Song/bpf-Add-bpf_rcu_read_lock-support/20221108-155529
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20221108074104.263145-1-yhs%40fb.com
patch subject: [PATCH bpf-next v2 3/8] bpf: Abstract out functions to check sleepable helpers
config: arm-neponset_defconfig
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 463da45892e2d2a262277b91b96f5f8c05dc25d0)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/97528bc3a813d7e2b950063b7a1912672bcae1e7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Yonghong-Song/bpf-Add-bpf_rcu_read_lock-support/20221108-155529
        git checkout 97528bc3a813d7e2b950063b7a1912672bcae1e7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash arch/arm/kernel/ fs/ ipc/ kernel/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from fs/statfs.c:2:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
   include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
>> fs/statfs.c:131:3: warning: 'memcpy' will always overflow; destination buffer has size 64, but size argument is 88 [-Wfortify-source]
                   memcpy(&buf, st, sizeof(*st));
                   ^
   fs/statfs.c:172:3: warning: 'memcpy' will always overflow; destination buffer has size 84, but size argument is 88 [-Wfortify-source]
                   memcpy(&buf, st, sizeof(*st));
                   ^
   2 warnings and 1 error generated.
--
   In file included from fs/aio.c:20:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
   include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   In file included from fs/aio.c:29:
>> include/linux/mman.h:154:9: warning: division by zero is undefined [-Wdivision-by-zero]
                  _calc_vm_trans(flags, MAP_SYNC,       VM_SYNC      ) |
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/mman.h:132:21: note: expanded from macro '_calc_vm_trans'
      : ((x) & (bit1)) / ((bit1) / (bit2))))
                       ^ ~~~~~~~~~~~~~~~~~
   1 warning and 1 error generated.
--
   In file included from ipc/msg.c:35:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
   include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
>> ipc/msg.c:497:20: warning: implicit conversion from 'int' to 'unsigned short' changes value from 32768000 to 0 [-Wconstant-conversion]
           msginfo->msgseg = MSGSEG;
                           ~ ^~~~~~
   include/uapi/linux/msg.h:87:38: note: expanded from macro 'MSGSEG'
   #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
                                        ^~~~~~~~
   include/uapi/linux/msg.h:86:36: note: expanded from macro '__MSGSEG'
   #define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */
                     ~~~~~~~~~~~~~~~~~^~~~~~~~
   1 warning and 1 error generated.
--
   In file included from arch/arm/kernel/sys_arm.c:20:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
   include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   In file included from arch/arm/kernel/sys_arm.c:21:
>> include/linux/mman.h:154:9: warning: division by zero is undefined [-Wdivision-by-zero]
                  _calc_vm_trans(flags, MAP_SYNC,       VM_SYNC      ) |
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/mman.h:132:21: note: expanded from macro '_calc_vm_trans'
      : ((x) & (bit1)) / ((bit1) / (bit2))))
                       ^ ~~~~~~~~~~~~~~~~~
   arch/arm/kernel/sys_arm.c:32:17: warning: no previous prototype for function 'sys_arm_fadvise64_64' [-Wmissing-prototypes]
   asmlinkage long sys_arm_fadvise64_64(int fd, int advice,
                   ^
   arch/arm/kernel/sys_arm.c:32:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
   asmlinkage long sys_arm_fadvise64_64(int fd, int advice,
              ^
              static 
   2 warnings and 1 error generated.


vim +/memcpy +131 fs/statfs.c

c8b91accfa1059 Al Viro 2011-03-12  125  
c8b91accfa1059 Al Viro 2011-03-12  126  static int do_statfs_native(struct kstatfs *st, struct statfs __user *p)
c8b91accfa1059 Al Viro 2011-03-12  127  {
c8b91accfa1059 Al Viro 2011-03-12  128  	struct statfs buf;
7ed1ee6118ae77 Al Viro 2010-03-23  129  
c8b91accfa1059 Al Viro 2011-03-12  130  	if (sizeof(buf) == sizeof(*st))
c8b91accfa1059 Al Viro 2011-03-12 @131  		memcpy(&buf, st, sizeof(*st));
7ed1ee6118ae77 Al Viro 2010-03-23  132  	else {
c8b91accfa1059 Al Viro 2011-03-12  133  		if (sizeof buf.f_blocks == 4) {
c8b91accfa1059 Al Viro 2011-03-12  134  			if ((st->f_blocks | st->f_bfree | st->f_bavail |
c8b91accfa1059 Al Viro 2011-03-12  135  			     st->f_bsize | st->f_frsize) &
7ed1ee6118ae77 Al Viro 2010-03-23  136  			    0xffffffff00000000ULL)
7ed1ee6118ae77 Al Viro 2010-03-23  137  				return -EOVERFLOW;
7ed1ee6118ae77 Al Viro 2010-03-23  138  			/*
7ed1ee6118ae77 Al Viro 2010-03-23  139  			 * f_files and f_ffree may be -1; it's okay to stuff
7ed1ee6118ae77 Al Viro 2010-03-23  140  			 * that into 32 bits
7ed1ee6118ae77 Al Viro 2010-03-23  141  			 */
c8b91accfa1059 Al Viro 2011-03-12  142  			if (st->f_files != -1 &&
c8b91accfa1059 Al Viro 2011-03-12  143  			    (st->f_files & 0xffffffff00000000ULL))
7ed1ee6118ae77 Al Viro 2010-03-23  144  				return -EOVERFLOW;
c8b91accfa1059 Al Viro 2011-03-12  145  			if (st->f_ffree != -1 &&
c8b91accfa1059 Al Viro 2011-03-12  146  			    (st->f_ffree & 0xffffffff00000000ULL))
7ed1ee6118ae77 Al Viro 2010-03-23  147  				return -EOVERFLOW;
7ed1ee6118ae77 Al Viro 2010-03-23  148  		}
7ed1ee6118ae77 Al Viro 2010-03-23  149  
c8b91accfa1059 Al Viro 2011-03-12  150  		buf.f_type = st->f_type;
c8b91accfa1059 Al Viro 2011-03-12  151  		buf.f_bsize = st->f_bsize;
c8b91accfa1059 Al Viro 2011-03-12  152  		buf.f_blocks = st->f_blocks;
c8b91accfa1059 Al Viro 2011-03-12  153  		buf.f_bfree = st->f_bfree;
c8b91accfa1059 Al Viro 2011-03-12  154  		buf.f_bavail = st->f_bavail;
c8b91accfa1059 Al Viro 2011-03-12  155  		buf.f_files = st->f_files;
c8b91accfa1059 Al Viro 2011-03-12  156  		buf.f_ffree = st->f_ffree;
c8b91accfa1059 Al Viro 2011-03-12  157  		buf.f_fsid = st->f_fsid;
c8b91accfa1059 Al Viro 2011-03-12  158  		buf.f_namelen = st->f_namelen;
c8b91accfa1059 Al Viro 2011-03-12  159  		buf.f_frsize = st->f_frsize;
c8b91accfa1059 Al Viro 2011-03-12  160  		buf.f_flags = st->f_flags;
c8b91accfa1059 Al Viro 2011-03-12  161  		memset(buf.f_spare, 0, sizeof(buf.f_spare));
c8b91accfa1059 Al Viro 2011-03-12  162  	}
c8b91accfa1059 Al Viro 2011-03-12  163  	if (copy_to_user(p, &buf, sizeof(buf)))
c8b91accfa1059 Al Viro 2011-03-12  164  		return -EFAULT;
7ed1ee6118ae77 Al Viro 2010-03-23  165  	return 0;
7ed1ee6118ae77 Al Viro 2010-03-23  166  }
7ed1ee6118ae77 Al Viro 2010-03-23  167
kernel test robot Nov. 8, 2022, 2:15 p.m. UTC | #2
Hi Yonghong,

I love your patch! Yet something to improve:

[auto build test ERROR on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Yonghong-Song/bpf-Add-bpf_rcu_read_lock-support/20221108-155529
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20221108074104.263145-1-yhs%40fb.com
patch subject: [PATCH bpf-next v2 3/8] bpf: Abstract out functions to check sleepable helpers
config: arm-neponset_defconfig
compiler: clang version 16.0.0 (https://github.com/llvm/llvm-project 463da45892e2d2a262277b91b96f5f8c05dc25d0)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://github.com/intel-lab-lkp/linux/commit/97528bc3a813d7e2b950063b7a1912672bcae1e7
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Yonghong-Song/bpf-Add-bpf_rcu_read_lock-support/20221108-155529
        git checkout 97528bc3a813d7e2b950063b7a1912672bcae1e7
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   In file included from init/main.c:21:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   init/main.c:772:20: warning: no previous prototype for function 'arch_post_acpi_subsys_init' [-Wmissing-prototypes]
   void __init __weak arch_post_acpi_subsys_init(void) { }
                      ^
   init/main.c:772:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init __weak arch_post_acpi_subsys_init(void) { }
   ^
   static 
   init/main.c:784:20: warning: no previous prototype for function 'mem_encrypt_init' [-Wmissing-prototypes]
   void __init __weak mem_encrypt_init(void) { }
                      ^
   init/main.c:784:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init __weak mem_encrypt_init(void) { }
   ^
   static 
   init/main.c:786:20: warning: no previous prototype for function 'poking_init' [-Wmissing-prototypes]
   void __init __weak poking_init(void) { }
                      ^
   init/main.c:786:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init __weak poking_init(void) { }
   ^
   static 
   3 warnings and 1 error generated.
--
   In file included from init/do_mounts.c:28:
   In file included from init/do_mounts.h:5:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   1 error generated.
--
   In file included from kernel/fork.c:55:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   kernel/fork.c:162:13: warning: no previous prototype for function 'arch_release_task_struct' [-Wmissing-prototypes]
   void __weak arch_release_task_struct(struct task_struct *tsk)
               ^
   kernel/fork.c:162:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __weak arch_release_task_struct(struct task_struct *tsk)
   ^
   static 
   kernel/fork.c:849:20: warning: no previous prototype for function 'arch_task_cache_init' [-Wmissing-prototypes]
   void __init __weak arch_task_cache_init(void) { }
                      ^
   kernel/fork.c:849:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   void __init __weak arch_task_cache_init(void) { }
   ^
   static 
   kernel/fork.c:944:12: warning: no previous prototype for function 'arch_dup_task_struct' [-Wmissing-prototypes]
   int __weak arch_dup_task_struct(struct task_struct *dst,
              ^
   kernel/fork.c:944:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int __weak arch_dup_task_struct(struct task_struct *dst,
   ^
   static 
   3 warnings and 1 error generated.
--
   In file included from kernel/signal.c:30:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   kernel/signal.c:137:37: warning: array index 3 is past the end of the array (that has type 'unsigned long[2]') [-Warray-bounds]
           case 4: ready  = signal->sig[3] &~ blocked->sig[3];
                                              ^            ~
   arch/arm/include/asm/signal.h:17:2: note: array 'sig' declared here
           unsigned long sig[_NSIG_WORDS];
           ^
   kernel/signal.c:137:19: warning: array index 3 is past the end of the array (that has type 'unsigned long[2]') [-Warray-bounds]
           case 4: ready  = signal->sig[3] &~ blocked->sig[3];
                            ^           ~
   arch/arm/include/asm/signal.h:17:2: note: array 'sig' declared here
           unsigned long sig[_NSIG_WORDS];
           ^
   kernel/signal.c:138:30: warning: array index 2 is past the end of the array (that has type 'unsigned long[2]') [-Warray-bounds]
                   ready |= signal->sig[2] &~ blocked->sig[2];
                                              ^            ~
   arch/arm/include/asm/signal.h:17:2: note: array 'sig' declared here
           unsigned long sig[_NSIG_WORDS];
           ^
   kernel/signal.c:138:12: warning: array index 2 is past the end of the array (that has type 'unsigned long[2]') [-Warray-bounds]
                   ready |= signal->sig[2] &~ blocked->sig[2];
                            ^           ~
   arch/arm/include/asm/signal.h:17:2: note: array 'sig' declared here
           unsigned long sig[_NSIG_WORDS];
           ^
   4 warnings and 1 error generated.
--
   In file included from arch/arm/kernel/signal.c:14:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   arch/arm/kernel/signal.c:142:15: warning: variable 'aux' set but not used [-Wunused-but-set-variable]
           char __user *aux;
                        ^
   arch/arm/kernel/signal.c:186:16: warning: no previous prototype for function 'sys_sigreturn' [-Wmissing-prototypes]
   asmlinkage int sys_sigreturn(struct pt_regs *regs)
                  ^
   arch/arm/kernel/signal.c:186:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
   asmlinkage int sys_sigreturn(struct pt_regs *regs)
              ^
              static 
   arch/arm/kernel/signal.c:216:16: warning: no previous prototype for function 'sys_rt_sigreturn' [-Wmissing-prototypes]
   asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
                  ^
   arch/arm/kernel/signal.c:216:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
   asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
              ^
              static 
   arch/arm/kernel/signal.c:601:1: warning: no previous prototype for function 'do_work_pending' [-Wmissing-prototypes]
   do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
   ^
   arch/arm/kernel/signal.c:600:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
   asmlinkage int
              ^
              static 
   4 warnings and 1 error generated.
--
   In file included from arch/arm/kernel/sys_arm.c:20:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   In file included from arch/arm/kernel/sys_arm.c:21:
   include/linux/mman.h:154:9: warning: division by zero is undefined [-Wdivision-by-zero]
                  _calc_vm_trans(flags, MAP_SYNC,       VM_SYNC      ) |
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/mman.h:132:21: note: expanded from macro '_calc_vm_trans'
      : ((x) & (bit1)) / ((bit1) / (bit2))))
                       ^ ~~~~~~~~~~~~~~~~~
   arch/arm/kernel/sys_arm.c:32:17: warning: no previous prototype for function 'sys_arm_fadvise64_64' [-Wmissing-prototypes]
   asmlinkage long sys_arm_fadvise64_64(int fd, int advice,
                   ^
   arch/arm/kernel/sys_arm.c:32:12: note: declare 'static' if the function is not intended to be used outside of this translation unit
   asmlinkage long sys_arm_fadvise64_64(int fd, int advice,
              ^
              static 
   2 warnings and 1 error generated.
--
   In file included from fs/pipe.c:24:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   fs/pipe.c:757:15: warning: no previous prototype for function 'account_pipe_buffers' [-Wmissing-prototypes]
   unsigned long account_pipe_buffers(struct user_struct *user,
                 ^
   fs/pipe.c:757:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   unsigned long account_pipe_buffers(struct user_struct *user,
   ^
   static 
   fs/pipe.c:763:6: warning: no previous prototype for function 'too_many_pipe_buffers_soft' [-Wmissing-prototypes]
   bool too_many_pipe_buffers_soft(unsigned long user_bufs)
        ^
   fs/pipe.c:763:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   bool too_many_pipe_buffers_soft(unsigned long user_bufs)
   ^
   static 
   fs/pipe.c:770:6: warning: no previous prototype for function 'too_many_pipe_buffers_hard' [-Wmissing-prototypes]
   bool too_many_pipe_buffers_hard(unsigned long user_bufs)
        ^
   fs/pipe.c:770:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   bool too_many_pipe_buffers_hard(unsigned long user_bufs)
   ^
   static 
   fs/pipe.c:777:6: warning: no previous prototype for function 'pipe_is_unprivileged_user' [-Wmissing-prototypes]
   bool pipe_is_unprivileged_user(void)
        ^
   fs/pipe.c:777:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   bool pipe_is_unprivileged_user(void)
   ^
   static 
   fs/pipe.c:1253:5: warning: no previous prototype for function 'pipe_resize_ring' [-Wmissing-prototypes]
   int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
       ^
   fs/pipe.c:1253:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int pipe_resize_ring(struct pipe_inode_info *pipe, unsigned int nr_slots)
   ^
   static 
   5 warnings and 1 error generated.
--
   In file included from fs/d_path.c:2:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   fs/d_path.c:317:7: warning: no previous prototype for function 'simple_dname' [-Wmissing-prototypes]
   char *simple_dname(struct dentry *dentry, char *buffer, int buflen)
         ^
   fs/d_path.c:317:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   char *simple_dname(struct dentry *dentry, char *buffer, int buflen)
   ^
   static 
   1 warning and 1 error generated.
--
   In file included from fs/statfs.c:2:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   fs/statfs.c:131:3: warning: 'memcpy' will always overflow; destination buffer has size 64, but size argument is 88 [-Wfortify-source]
                   memcpy(&buf, st, sizeof(*st));
                   ^
   fs/statfs.c:172:3: warning: 'memcpy' will always overflow; destination buffer has size 84, but size argument is 88 [-Wfortify-source]
                   memcpy(&buf, st, sizeof(*st));
                   ^
   2 warnings and 1 error generated.
--
   In file included from fs/aio.c:20:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   In file included from fs/aio.c:29:
   include/linux/mman.h:154:9: warning: division by zero is undefined [-Wdivision-by-zero]
                  _calc_vm_trans(flags, MAP_SYNC,       VM_SYNC      ) |
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/mman.h:132:21: note: expanded from macro '_calc_vm_trans'
      : ((x) & (bit1)) / ((bit1) / (bit2))))
                       ^ ~~~~~~~~~~~~~~~~~
   1 warning and 1 error generated.
--
   In file included from ipc/msg.c:35:
   In file included from include/linux/syscalls.h:88:
   In file included from include/trace/syscall.h:7:
>> include/linux/trace_events.h:801:51: error: variable has incomplete type 'enum bpf_func_id'
   bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
                                                     ^
   include/linux/trace_events.h:20:6: note: forward declaration of 'enum bpf_func_id'
   enum bpf_func_id;
        ^
   ipc/msg.c:497:20: warning: implicit conversion from 'int' to 'unsigned short' changes value from 32768000 to 0 [-Wconstant-conversion]
           msginfo->msgseg = MSGSEG;
                           ~ ^~~~~~
   include/uapi/linux/msg.h:87:38: note: expanded from macro 'MSGSEG'
   #define MSGSEG (__MSGSEG <= 0xffff ? __MSGSEG : 0xffff)
                                        ^~~~~~~~
   include/uapi/linux/msg.h:86:36: note: expanded from macro '__MSGSEG'
   #define __MSGSEG ((MSGPOOL * 1024) / MSGSSZ) /* max no. of segments */
                     ~~~~~~~~~~~~~~~~~^~~~~~~~
   1 warning and 1 error generated.
..


vim +801 include/linux/trace_events.h

   767	
   768	static inline int
   769	perf_event_query_prog_array(struct perf_event *event, void __user *info)
   770	{
   771		return -EOPNOTSUPP;
   772	}
   773	static inline int bpf_probe_register(struct bpf_raw_event_map *btp, struct bpf_prog *p)
   774	{
   775		return -EOPNOTSUPP;
   776	}
   777	static inline int bpf_probe_unregister(struct bpf_raw_event_map *btp, struct bpf_prog *p)
   778	{
   779		return -EOPNOTSUPP;
   780	}
   781	static inline struct bpf_raw_event_map *bpf_get_raw_tracepoint(const char *name)
   782	{
   783		return NULL;
   784	}
   785	static inline void bpf_put_raw_tracepoint(struct bpf_raw_event_map *btp)
   786	{
   787	}
   788	static inline int bpf_get_perf_event_info(const struct perf_event *event,
   789						  u32 *prog_id, u32 *fd_type,
   790						  const char **buf, u64 *probe_offset,
   791						  u64 *probe_addr)
   792	{
   793		return -EOPNOTSUPP;
   794	}
   795	static inline int
   796	bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
   797	{
   798		return -EOPNOTSUPP;
   799	}
   800	static inline const struct bpf_func_proto *
 > 801	bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
   802	{
   803		return NULL;
   804	}
   805	#endif
   806
diff mbox series

Patch

diff --git a/include/linux/bpf_lsm.h b/include/linux/bpf_lsm.h
index 4bcf76a9bb06..d99b1caf118e 100644
--- a/include/linux/bpf_lsm.h
+++ b/include/linux/bpf_lsm.h
@@ -28,6 +28,7 @@  int bpf_lsm_verify_prog(struct bpf_verifier_log *vlog,
 			const struct bpf_prog *prog);
 
 bool bpf_lsm_is_sleepable_hook(u32 btf_id);
+const struct bpf_func_proto *bpf_lsm_sleepable_func_proto(enum bpf_func_id func_id);
 
 static inline struct bpf_storage_blob *bpf_inode(
 	const struct inode *inode)
@@ -50,6 +51,11 @@  static inline bool bpf_lsm_is_sleepable_hook(u32 btf_id)
 {
 	return false;
 }
+static inline const struct bpf_func_proto *
+bpf_lsm_sleepable_func_proto(enum bpf_func_id func_id)
+{
+	return NULL;
+}
 
 static inline int bpf_lsm_verify_prog(struct bpf_verifier_log *vlog,
 				      const struct bpf_prog *prog)
diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h
index 20749bd9db71..ccf046bf253f 100644
--- a/include/linux/trace_events.h
+++ b/include/linux/trace_events.h
@@ -16,6 +16,8 @@  struct tracer;
 struct dentry;
 struct bpf_prog;
 union bpf_attr;
+struct bpf_func_proto;
+enum bpf_func_id;
 
 const char *trace_print_flags_seq(struct trace_seq *p, const char *delim,
 				  unsigned long flags,
@@ -748,6 +750,7 @@  int bpf_get_perf_event_info(const struct perf_event *event, u32 *prog_id,
 			    u32 *fd_type, const char **buf,
 			    u64 *probe_offset, u64 *probe_addr);
 int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *prog);
+const struct bpf_func_proto *bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id);
 #else
 static inline unsigned int trace_call_bpf(struct trace_event_call *call, void *ctx)
 {
@@ -794,6 +797,11 @@  bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *prog)
 {
 	return -EOPNOTSUPP;
 }
+static inline const struct bpf_func_proto *
+bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
+{
+	return NULL;
+}
 #endif
 
 enum {
diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c
index d6c9b3705f24..2f993a003389 100644
--- a/kernel/bpf/bpf_lsm.c
+++ b/kernel/bpf/bpf_lsm.c
@@ -192,6 +192,18 @@  static const struct bpf_func_proto bpf_get_attach_cookie_proto = {
 	.arg1_type	= ARG_PTR_TO_CTX,
 };
 
+const struct bpf_func_proto *bpf_lsm_sleepable_func_proto(enum bpf_func_id func_id)
+{
+	switch (func_id) {
+	case BPF_FUNC_ima_inode_hash:
+		return &bpf_ima_inode_hash_proto;
+	case BPF_FUNC_ima_file_hash:
+		return &bpf_ima_file_hash_proto;
+	default:
+		return NULL;
+	}
+}
+
 static const struct bpf_func_proto *
 bpf_lsm_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 {
@@ -203,6 +215,10 @@  bpf_lsm_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 			return func_proto;
 	}
 
+	func_proto = bpf_lsm_sleepable_func_proto(func_id);
+	if (func_proto)
+		return prog->aux->sleepable ? func_proto : NULL;
+
 	switch (func_id) {
 	case BPF_FUNC_inode_storage_get:
 		return &bpf_inode_storage_get_proto;
@@ -220,10 +236,6 @@  bpf_lsm_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 		return &bpf_spin_unlock_proto;
 	case BPF_FUNC_bprm_opts_set:
 		return &bpf_bprm_opts_set_proto;
-	case BPF_FUNC_ima_inode_hash:
-		return prog->aux->sleepable ? &bpf_ima_inode_hash_proto : NULL;
-	case BPF_FUNC_ima_file_hash:
-		return prog->aux->sleepable ? &bpf_ima_file_hash_proto : NULL;
 	case BPF_FUNC_get_attach_cookie:
 		return bpf_prog_has_trampoline(prog) ? &bpf_get_attach_cookie_proto : NULL;
 #ifdef CONFIG_NET
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index f2d8d070d024..7804fa71d3f1 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -1383,9 +1383,27 @@  static int __init bpf_key_sig_kfuncs_init(void)
 late_initcall(bpf_key_sig_kfuncs_init);
 #endif /* CONFIG_KEYS */
 
+const struct bpf_func_proto *bpf_tracing_sleepable_func_proto(enum bpf_func_id func_id)
+{
+	switch (func_id) {
+	case BPF_FUNC_copy_from_user:
+		return &bpf_copy_from_user_proto;
+	case BPF_FUNC_copy_from_user_task:
+		return &bpf_copy_from_user_task_proto;
+	default:
+		return NULL;
+	}
+}
+
 static const struct bpf_func_proto *
 bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 {
+	const struct bpf_func_proto *func_proto;
+
+	func_proto = bpf_tracing_sleepable_func_proto(func_id);
+	if (func_proto)
+		return prog->aux->sleepable ? func_proto : NULL;
+
 	switch (func_id) {
 	case BPF_FUNC_map_lookup_elem:
 		return &bpf_map_lookup_elem_proto;
@@ -1484,10 +1502,6 @@  bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 		return &bpf_jiffies64_proto;
 	case BPF_FUNC_get_task_stack:
 		return &bpf_get_task_stack_proto;
-	case BPF_FUNC_copy_from_user:
-		return prog->aux->sleepable ? &bpf_copy_from_user_proto : NULL;
-	case BPF_FUNC_copy_from_user_task:
-		return prog->aux->sleepable ? &bpf_copy_from_user_task_proto : NULL;
 	case BPF_FUNC_snprintf_btf:
 		return &bpf_snprintf_btf_proto;
 	case BPF_FUNC_per_cpu_ptr: