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: <202501100757.HDb5slrv-lkp@intel.com>
Date: Fri, 10 Jan 2025 07:55:22 +0800
From: kernel test robot <lkp@...el.com>
To: Song Liu <song@...nel.org>, bpf@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-security-module@...r.kernel.org
Cc: oe-kbuild-all@...ts.linux.dev, kernel-team@...a.com, andrii@...nel.org,
	ast@...nel.org, daniel@...earbox.net, martin.lau@...ux.dev,
	kpsingh@...nel.org, mattbobrowski@...gle.com, paul@...l-moore.com,
	jmorris@...ei.org, serge@...lyn.com, memxor@...il.com,
	Song Liu <song@...nel.org>
Subject: Re: [PATCH v8 bpf-next 5/7] bpf: Use btf_kfunc_id_set.remap logic
 for bpf_dynptr_from_skb

Hi Song,

kernel test robot noticed the following build errors:

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

url:    https://github.com/intel-lab-lkp/linux/commits/Song-Liu/fs-xattr-bpf-Introduce-security-bpf-xattr-name-prefix/20250109-065503
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20250108225140.3467654-6-song%40kernel.org
patch subject: [PATCH v8 bpf-next 5/7] bpf: Use btf_kfunc_id_set.remap logic for bpf_dynptr_from_skb
config: i386-buildonly-randconfig-005-20250110 (https://download.01.org/0day-ci/archive/20250110/202501100757.HDb5slrv-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250110/202501100757.HDb5slrv-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501100757.HDb5slrv-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

>> net/core/filter.c:12071:1: error: return type defaults to 'int' [-Werror=implicit-int]
   12071 | BTF_HIDDEN_KFUNCS_START(bpf_kfunc_check_hidden_set_skb)
         | ^~~~~~~~~~~~~~~~~~~~~~~
>> net/core/filter.c:12071:1: error: function declaration isn't a prototype [-Werror=strict-prototypes]
   In file included from include/linux/btf.h:10,
                    from include/linux/bpf.h:28,
                    from include/linux/bpf_verifier.h:7,
                    from net/core/filter.c:21:
   net/core/filter.c: In function 'BTF_HIDDEN_KFUNCS_START':
>> net/core/filter.c:12075:18: error: storage class specified for parameter 'bpf_kfunc_check_set_xdp'
   12075 | BTF_KFUNCS_START(bpf_kfunc_check_set_xdp)
         |                  ^~~~~~~~~~~~~~~~~~~~~~~
   include/linux/btf_ids.h:235:73: note: in definition of macro 'BTF_KFUNCS_START'
     235 | #define BTF_KFUNCS_START(name) static struct btf_id_set8 __maybe_unused name = { .flags = BTF_SET8_KFUNCS };
         |                                                                         ^~~~
>> include/linux/btf_ids.h:235:46: error: parameter 'bpf_kfunc_check_set_xdp' is initialized
     235 | #define BTF_KFUNCS_START(name) static struct btf_id_set8 __maybe_unused name = { .flags = BTF_SET8_KFUNCS };
         |                                              ^~~~~~~~~~~
   net/core/filter.c:12075:1: note: in expansion of macro 'BTF_KFUNCS_START'
   12075 | BTF_KFUNCS_START(bpf_kfunc_check_set_xdp)
         | ^~~~~~~~~~~~~~~~
>> net/core/filter.c:12079:18: error: storage class specified for parameter 'bpf_kfunc_check_set_sock_addr'
   12079 | BTF_KFUNCS_START(bpf_kfunc_check_set_sock_addr)
         |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/btf_ids.h:235:73: note: in definition of macro 'BTF_KFUNCS_START'
     235 | #define BTF_KFUNCS_START(name) static struct btf_id_set8 __maybe_unused name = { .flags = BTF_SET8_KFUNCS };
         |                                                                         ^~~~
>> include/linux/btf_ids.h:235:46: error: parameter 'bpf_kfunc_check_set_sock_addr' is initialized
     235 | #define BTF_KFUNCS_START(name) static struct btf_id_set8 __maybe_unused name = { .flags = BTF_SET8_KFUNCS };
         |                                              ^~~~~~~~~~~
   net/core/filter.c:12079:1: note: in expansion of macro 'BTF_KFUNCS_START'
   12079 | BTF_KFUNCS_START(bpf_kfunc_check_set_sock_addr)
         | ^~~~~~~~~~~~~~~~
>> net/core/filter.c:12083:18: error: storage class specified for parameter 'bpf_kfunc_check_set_tcp_reqsk'
   12083 | BTF_KFUNCS_START(bpf_kfunc_check_set_tcp_reqsk)
         |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/btf_ids.h:235:73: note: in definition of macro 'BTF_KFUNCS_START'
     235 | #define BTF_KFUNCS_START(name) static struct btf_id_set8 __maybe_unused name = { .flags = BTF_SET8_KFUNCS };
         |                                                                         ^~~~
>> include/linux/btf_ids.h:235:46: error: parameter 'bpf_kfunc_check_set_tcp_reqsk' is initialized
     235 | #define BTF_KFUNCS_START(name) static struct btf_id_set8 __maybe_unused name = { .flags = BTF_SET8_KFUNCS };
         |                                              ^~~~~~~~~~~
   net/core/filter.c:12083:1: note: in expansion of macro 'BTF_KFUNCS_START'
   12083 | BTF_KFUNCS_START(bpf_kfunc_check_set_tcp_reqsk)
         | ^~~~~~~~~~~~~~~~
>> net/core/filter.c:12087:13: error: storage class specified for parameter 'bpf_dynptr_from_skb_list'
   12087 | BTF_ID_LIST(bpf_dynptr_from_skb_list)
         |             ^~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/btf_ids.h:223:53: note: in definition of macro 'BTF_ID_LIST'
     223 | #define BTF_ID_LIST(name) static u32 __maybe_unused name[64];
         |                                                     ^~~~
>> net/core/filter.c:12092:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   12092 | {
         | ^
>> net/core/filter.c:12122:38: error: storage class specified for parameter 'bpf_kfunc_set_skb'
   12122 | static const struct btf_kfunc_id_set bpf_kfunc_set_skb = {
         |                                      ^~~~~~~~~~~~~~~~~
>> net/core/filter.c:12122:21: error: parameter 'bpf_kfunc_set_skb' is initialized
   12122 | static const struct btf_kfunc_id_set bpf_kfunc_set_skb = {
         |                     ^~~~~~~~~~~~~~~~
>> net/core/filter.c:12125:24: error: 'bpf_kfunc_check_hidden_set_skb' undeclared (first use in this function); did you mean 'bpf_kfunc_check_set_skb'?
   12125 |         .hidden_set = &bpf_kfunc_check_hidden_set_skb,
         |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                        bpf_kfunc_check_set_skb
   net/core/filter.c:12125:24: note: each undeclared identifier is reported only once for each function it appears in
>> net/core/filter.c:12126:19: error: 'bpf_kfunc_set_skb_remap' undeclared (first use in this function); did you mean 'bpf_kfunc_set_skb'?
   12126 |         .remap = &bpf_kfunc_set_skb_remap,
         |                   ^~~~~~~~~~~~~~~~~~~~~~~
         |                   bpf_kfunc_set_skb
>> net/core/filter.c:12129:38: error: storage class specified for parameter 'bpf_kfunc_set_xdp'
   12129 | static const struct btf_kfunc_id_set bpf_kfunc_set_xdp = {
         |                                      ^~~~~~~~~~~~~~~~~
>> net/core/filter.c:12129:21: error: parameter 'bpf_kfunc_set_xdp' is initialized
   12129 | static const struct btf_kfunc_id_set bpf_kfunc_set_xdp = {
         |                     ^~~~~~~~~~~~~~~~
>> net/core/filter.c:12134:38: error: storage class specified for parameter 'bpf_kfunc_set_sock_addr'
   12134 | static const struct btf_kfunc_id_set bpf_kfunc_set_sock_addr = {
         |                                      ^~~~~~~~~~~~~~~~~~~~~~~
>> net/core/filter.c:12134:21: error: parameter 'bpf_kfunc_set_sock_addr' is initialized
   12134 | static const struct btf_kfunc_id_set bpf_kfunc_set_sock_addr = {
         |                     ^~~~~~~~~~~~~~~~
>> net/core/filter.c:12139:38: error: storage class specified for parameter 'bpf_kfunc_set_tcp_reqsk'
   12139 | static const struct btf_kfunc_id_set bpf_kfunc_set_tcp_reqsk = {
         |                                      ^~~~~~~~~~~~~~~~~~~~~~~
>> net/core/filter.c:12139:21: error: parameter 'bpf_kfunc_set_tcp_reqsk' is initialized
   12139 | static const struct btf_kfunc_id_set bpf_kfunc_set_tcp_reqsk = {
         |                     ^~~~~~~~~~~~~~~~
   net/core/filter.c:12145:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   12145 | {
         | ^
   In file included from <command-line>:
   include/linux/compiler.h:189:45: error: storage class specified for parameter '__UNIQUE_ID___addressable_bpf_kfunc_init1505'
     189 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
         |                                             ^~~~~~~~~~~~
   include/linux/compiler_types.h:83:23: note: in definition of macro '___PASTE'
      83 | #define ___PASTE(a,b) a##b
         |                       ^
   include/linux/compiler.h:189:29: note: in expansion of macro '__PASTE'
     189 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
         |                             ^~~~~~~
   include/linux/compiler_types.h:84:22: note: in expansion of macro '___PASTE'
      84 | #define __PASTE(a,b) ___PASTE(a,b)
         |                      ^~~~~~~~
   include/linux/compiler.h:189:37: note: in expansion of macro '__PASTE'
     189 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
         |                                     ^~~~~~~
   include/linux/compiler.h:227:9: note: in expansion of macro '__UNIQUE_ID'
     227 |         __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym;
         |         ^~~~~~~~~~~
   include/linux/compiler.h:229:9: note: in expansion of macro '___ADDRESSABLE'
     229 |         ___ADDRESSABLE(sym, __section(".discard.addressable"))
         |         ^~~~~~~~~~~~~~
   include/linux/init.h:256:9: note: in expansion of macro '__ADDRESSABLE'
     256 |         __ADDRESSABLE(fn)
         |         ^~~~~~~~~~~~~
   include/linux/init.h:261:9: note: in expansion of macro '__define_initcall_stub'
     261 |         __define_initcall_stub(__stub, fn)                      \
         |         ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/init.h:274:9: note: in expansion of macro '____define_initcall'
     274 |         ____define_initcall(fn,                                 \
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/init.h:280:9: note: in expansion of macro '__unique_initcall'
     280 |         __unique_initcall(fn, id, __sec, __initcall_id(fn))
         |         ^~~~~~~~~~~~~~~~~
   include/linux/init.h:282:35: note: in expansion of macro '___define_initcall'
     282 | #define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id)
         |                                   ^~~~~~~~~~~~~~~~~~
   include/linux/init.h:313:41: note: in expansion of macro '__define_initcall'
     313 | #define late_initcall(fn)               __define_initcall(fn, 7)
         |                                         ^~~~~~~~~~~~~~~~~
   net/core/filter.c:12164:1: note: in expansion of macro 'late_initcall'
   12164 | late_initcall(bpf_kfunc_init);
         | ^~~~~~~~~~~~~
   net/core/filter.c:12164:1: error: parameter '__UNIQUE_ID___addressable_bpf_kfunc_init1505' is initialized
   net/core/filter.c:12164:1: warning: 'used' attribute ignored [-Wattributes]
   include/linux/compiler.h:189:45: error: section attribute not allowed for '__UNIQUE_ID___addressable_bpf_kfunc_init1505'
     189 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
         |                                             ^~~~~~~~~~~~
   include/linux/compiler_types.h:83:23: note: in definition of macro '___PASTE'
      83 | #define ___PASTE(a,b) a##b
         |                       ^
   include/linux/compiler.h:189:29: note: in expansion of macro '__PASTE'
     189 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
         |                             ^~~~~~~
   include/linux/compiler_types.h:84:22: note: in expansion of macro '___PASTE'
      84 | #define __PASTE(a,b) ___PASTE(a,b)
         |                      ^~~~~~~~
   include/linux/compiler.h:189:37: note: in expansion of macro '__PASTE'
     189 | #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
         |                                     ^~~~~~~
   include/linux/compiler.h:227:9: note: in expansion of macro '__UNIQUE_ID'
     227 |         __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym;
         |         ^~~~~~~~~~~
   include/linux/compiler.h:229:9: note: in expansion of macro '___ADDRESSABLE'
     229 |         ___ADDRESSABLE(sym, __section(".discard.addressable"))
         |         ^~~~~~~~~~~~~~
   include/linux/init.h:256:9: note: in expansion of macro '__ADDRESSABLE'
     256 |         __ADDRESSABLE(fn)
         |         ^~~~~~~~~~~~~
   include/linux/init.h:261:9: note: in expansion of macro '__define_initcall_stub'
     261 |         __define_initcall_stub(__stub, fn)                      \
         |         ^~~~~~~~~~~~~~~~~~~~~~
   include/linux/init.h:274:9: note: in expansion of macro '____define_initcall'
     274 |         ____define_initcall(fn,                                 \
         |         ^~~~~~~~~~~~~~~~~~~
   include/linux/init.h:280:9: note: in expansion of macro '__unique_initcall'
     280 |         __unique_initcall(fn, id, __sec, __initcall_id(fn))
         |         ^~~~~~~~~~~~~~~~~
   include/linux/init.h:282:35: note: in expansion of macro '___define_initcall'
     282 | #define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id)
         |                                   ^~~~~~~~~~~~~~~~~~
   include/linux/init.h:313:41: note: in expansion of macro '__define_initcall'
     313 | #define late_initcall(fn)               __define_initcall(fn, 7)
         |                                         ^~~~~~~~~~~~~~~~~
   net/core/filter.c:12164:1: note: in expansion of macro 'late_initcall'
   12164 | late_initcall(bpf_kfunc_init);
         | ^~~~~~~~~~~~~
   In file included from arch/x86/include/asm/atomic.h:5,
                    from include/linux/atomic.h:7,
                    from net/core/filter.c:20:
   net/core/filter.c:12164:15: error: 'bpf_kfunc_init' undeclared (first use in this function); did you mean 'bpf_func_info'?
   12164 | late_initcall(bpf_kfunc_init);
         |               ^~~~~~~~~~~~~~
   include/linux/compiler.h:227:72: note: in definition of macro '___ADDRESSABLE'
     227 |         __UNIQUE_ID(__PASTE(__addressable_,sym)) = (void *)(uintptr_t)&sym;


vim +/int +12071 net/core/filter.c

 12070	
 12071	BTF_HIDDEN_KFUNCS_START(bpf_kfunc_check_hidden_set_skb)
 12072	BTF_ID_FLAGS(func, bpf_dynptr_from_skb_rdonly, KF_TRUSTED_ARGS)
 12073	BTF_KFUNCS_END(bpf_kfunc_check_hidden_set_skb)
 12074	
 12075	BTF_KFUNCS_START(bpf_kfunc_check_set_xdp)
 12076	BTF_ID_FLAGS(func, bpf_dynptr_from_xdp)
 12077	BTF_KFUNCS_END(bpf_kfunc_check_set_xdp)
 12078	
 12079	BTF_KFUNCS_START(bpf_kfunc_check_set_sock_addr)
 12080	BTF_ID_FLAGS(func, bpf_sock_addr_set_sun_path)
 12081	BTF_KFUNCS_END(bpf_kfunc_check_set_sock_addr)
 12082	
 12083	BTF_KFUNCS_START(bpf_kfunc_check_set_tcp_reqsk)
 12084	BTF_ID_FLAGS(func, bpf_sk_assign_tcp_reqsk, KF_TRUSTED_ARGS)
 12085	BTF_KFUNCS_END(bpf_kfunc_check_set_tcp_reqsk)
 12086	
 12087	BTF_ID_LIST(bpf_dynptr_from_skb_list)
 12088	BTF_ID(func, bpf_dynptr_from_skb)
 12089	BTF_ID(func, bpf_dynptr_from_skb_rdonly)
 12090	
 12091	static u32 bpf_kfunc_set_skb_remap(const struct bpf_prog *prog, u32 kfunc_id)
 12092	{
 12093		if (kfunc_id != bpf_dynptr_from_skb_list[0])
 12094			return 0;
 12095	
 12096		switch (resolve_prog_type(prog)) {
 12097		/* Program types only with direct read access go here! */
 12098		case BPF_PROG_TYPE_LWT_IN:
 12099		case BPF_PROG_TYPE_LWT_OUT:
 12100		case BPF_PROG_TYPE_LWT_SEG6LOCAL:
 12101		case BPF_PROG_TYPE_SK_REUSEPORT:
 12102		case BPF_PROG_TYPE_FLOW_DISSECTOR:
 12103		case BPF_PROG_TYPE_CGROUP_SKB:
 12104			return bpf_dynptr_from_skb_list[1];
 12105	
 12106		/* Program types with direct read + write access go here! */
 12107		case BPF_PROG_TYPE_SCHED_CLS:
 12108		case BPF_PROG_TYPE_SCHED_ACT:
 12109		case BPF_PROG_TYPE_XDP:
 12110		case BPF_PROG_TYPE_LWT_XMIT:
 12111		case BPF_PROG_TYPE_SK_SKB:
 12112		case BPF_PROG_TYPE_SK_MSG:
 12113		case BPF_PROG_TYPE_CGROUP_SOCKOPT:
 12114			return kfunc_id;
 12115	
 12116		default:
 12117			break;
 12118		}
 12119		return bpf_dynptr_from_skb_list[1];
 12120	}
 12121	
 12122	static const struct btf_kfunc_id_set bpf_kfunc_set_skb = {
 12123		.owner = THIS_MODULE,
 12124		.set = &bpf_kfunc_check_set_skb,
 12125		.hidden_set = &bpf_kfunc_check_hidden_set_skb,
 12126		.remap = &bpf_kfunc_set_skb_remap,
 12127	};
 12128	
 12129	static const struct btf_kfunc_id_set bpf_kfunc_set_xdp = {
 12130		.owner = THIS_MODULE,
 12131		.set = &bpf_kfunc_check_set_xdp,
 12132	};
 12133	
 12134	static const struct btf_kfunc_id_set bpf_kfunc_set_sock_addr = {
 12135		.owner = THIS_MODULE,
 12136		.set = &bpf_kfunc_check_set_sock_addr,
 12137	};
 12138	
 12139	static const struct btf_kfunc_id_set bpf_kfunc_set_tcp_reqsk = {
 12140		.owner = THIS_MODULE,
 12141		.set = &bpf_kfunc_check_set_tcp_reqsk,
 12142	};
 12143	
 12144	static int __init bpf_kfunc_init(void)
 12145	{
 12146		int ret;
 12147	
 12148		ret = register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &bpf_kfunc_set_skb);
 12149		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_ACT, &bpf_kfunc_set_skb);
 12150		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SK_SKB, &bpf_kfunc_set_skb);
 12151		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SOCKET_FILTER, &bpf_kfunc_set_skb);
 12152		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SKB, &bpf_kfunc_set_skb);
 12153		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_LWT_OUT, &bpf_kfunc_set_skb);
 12154		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_LWT_IN, &bpf_kfunc_set_skb);
 12155		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_LWT_XMIT, &bpf_kfunc_set_skb);
 12156		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_LWT_SEG6LOCAL, &bpf_kfunc_set_skb);
 12157		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_NETFILTER, &bpf_kfunc_set_skb);
 12158		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_kfunc_set_skb);
 12159		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_XDP, &bpf_kfunc_set_xdp);
 12160		ret = ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_CGROUP_SOCK_ADDR,
 12161						       &bpf_kfunc_set_sock_addr);
 12162		return ret ?: register_btf_kfunc_id_set(BPF_PROG_TYPE_SCHED_CLS, &bpf_kfunc_set_tcp_reqsk);
 12163	}
 12164	late_initcall(bpf_kfunc_init);
 12165	
 12166	__bpf_kfunc_start_defs();
 12167	
 12168	/* bpf_sock_destroy: Destroy the given socket with ECONNABORTED error code.
 12169	 *
 12170	 * The function expects a non-NULL pointer to a socket, and invokes the
 12171	 * protocol specific socket destroy handlers.
 12172	 *
 12173	 * The helper can only be called from BPF contexts that have acquired the socket
 12174	 * locks.
 12175	 *
 12176	 * Parameters:
 12177	 * @sock: Pointer to socket to be destroyed
 12178	 *
 12179	 * Return:
 12180	 * On error, may return EPROTONOSUPPORT, EINVAL.
 12181	 * EPROTONOSUPPORT if protocol specific destroy handler is not supported.
 12182	 * 0 otherwise
 12183	 */
 12184	__bpf_kfunc int bpf_sock_destroy(struct sock_common *sock)
 12185	{
 12186		struct sock *sk = (struct sock *)sock;
 12187	
 12188		/* The locking semantics that allow for synchronous execution of the
 12189		 * destroy handlers are only supported for TCP and UDP.
 12190		 * Supporting protocols will need to acquire sock lock in the BPF context
 12191		 * prior to invoking this kfunc.
 12192		 */
 12193		if (!sk->sk_prot->diag_destroy || (sk->sk_protocol != IPPROTO_TCP &&
 12194						   sk->sk_protocol != IPPROTO_UDP))
 12195			return -EOPNOTSUPP;
 12196	
 12197		return sk->sk_prot->diag_destroy(sk, ECONNABORTED);
 12198	}
 12199	
 12200	__bpf_kfunc_end_defs();
 12201	
 12202	BTF_KFUNCS_START(bpf_sk_iter_kfunc_ids)
 12203	BTF_ID_FLAGS(func, bpf_sock_destroy, KF_TRUSTED_ARGS)
 12204	BTF_KFUNCS_END(bpf_sk_iter_kfunc_ids)
 12205	
 12206	static int tracing_iter_filter(const struct bpf_prog *prog, u32 kfunc_id)
 12207	{
 12208		if (btf_id_set8_contains(&bpf_sk_iter_kfunc_ids, kfunc_id) &&
 12209		    prog->expected_attach_type != BPF_TRACE_ITER)
 12210			return -EACCES;
 12211		return 0;
 12212	}
 12213	
 12214	static const struct btf_kfunc_id_set bpf_sk_iter_kfunc_set = {
 12215		.owner = THIS_MODULE,
 12216		.set   = &bpf_sk_iter_kfunc_ids,
 12217		.filter = tracing_iter_filter,
 12218	};
 12219	
 12220	static int init_subsystem(void)
 12221	{
 12222		return register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &bpf_sk_iter_kfunc_set);
 12223	}
 12224	late_initcall(init_subsystem);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ