net/smc: Introduce smc_hs_ctrl
Subsystems (9)
D. Wythe
maintainercover net/smc: Introduce smc_hs_ctrl
This patch aims to introduce BPF injection capabilities for SMC and includes a self-test to ensure code stability.
Since the SMC protocol isn't ideal for every situation, especially short-lived ones, most applications can't guarantee the absence of such scenarios. Consequently, applications may need specific strategies to decide whether to use SMC. For example, an application might limit SMC usage to certain IP addresses or ports.
To maintain the principle of transparent replacement, we want applications to remain unaffected even if they need specific SMC strategies. In other words, they should not require recompilation of their code.
Additionally, we need to ensure the scalability of strategy implementation. While using socket options or sysctl might be straightforward, it could complicate future expansions.
Fortunately, BPF addresses these concerns effectively. Users can write their own strategies in eBPF to determine whether to use SMC, and they can easily modify those strategies in the future.
This is a rework of the series from [1]. Changes since [1] are limited to the SMC parts:
1. Rename smc_ops to smc_hs_ctrl and change interface name.
2. Squash SMC patches, removing standalone non-BPF hook capability.
3. Fix typos
[1]: https://lore.kernel.org/bpf/[email protected]/#t
D. Wythe (5):
bpf: export necessary sympols for modules with struct_ops net/smc: fix UAF on smcsk after smc_listen_out() net/smc: bpf: Introduce generic hook for handshake flow
libbpf: fix error when st-prefix_ops and ops from differ btf bpf/selftests: add selftest for bpf_smc_hs_ctrl
include/net/netns/smc.h | 3 + include/net/smc.h | 53 +++ kernel/bpf/bpf_struct_ops.c | 2 + kernel/bpf/syscall.c | 1 + net/ipv4/tcp_output.c | 18 +- net/smc/Kconfig | 12 + net/smc/Makefile | 1 + net/smc/af_smc.c | 14 +- net/smc/smc_hs_bpf.c | 131 ++++++ net/smc/smc_hs_bpf.h | 31 ++ net/smc/smc_sysctl.c | 90 ++++ tools/lib/bpf/libbpf.c | 37 +- tools/testing/selftests/bpf/config | 4 + .../selftests/bpf/prog_tests/test_bpf_smc.c | 396 ++++++++++++++++++ tools/testing/selftests/bpf/progs/bpf_smc.c | 117 ++++++ 15 files changed, 886 insertions(+), 24 deletions(-) create mode 100644 net/smc/smc_hs_bpf.c create mode 100644 net/smc/smc_hs_bpf.h create mode 100644 tools/testing/selftests/bpf/prog_tests/test_bpf_smc.c create mode 100644 tools/testing/selftests/bpf/progs/bpf_smc.c
Signature · 1 line
2.45.0
D. Wythe
maintainerPATCH 5/5 bpf/selftests: add selftest for bpf_smc_hs_ctrl
This tests introduces a tiny smc_hs_ctrl for filtering SMC connections based on IP pairs, and also adds a realistic topology model to verify it.
Also, we can only use SMC loopback under CI test, so an additional configuration needs to be enabled.
Follow the steps below to run this test.
make -C tools/testing/selftests/bpf
cd tools/testing/selftests/bpf
sudo ./test_progs -t smc
Results shows:
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED
--- tools/testing/selftests/bpf/config | 4 + .../selftests/bpf/prog_tests/test_bpf_smc.c | 396 ++++++++++++++++++ tools/testing/selftests/bpf/progs/bpf_smc.c | 117 ++++++ 3 files changed, 517 insertions(+) create mode 100644 tools/testing/selftests/bpf/prog_tests/test_bpf_smc.c create mode 100644 tools/testing/selftests/bpf/progs/bpf_smc.c
tools/testing/selftests/bpf/config +4 -0
@@ -119,3 +119,7 @@ CONFIG_XDP_SOCKETS=y CONFIG_XFRM_INTERFACE=y CONFIG_TCP_CONG_DCTCP=y CONFIG_TCP_CONG_BBR=y +CONFIG_INFINIBAND=y +CONFIG_SMC=y +CONFIG_SMC_HS_CTRL_BPF=y +CONFIG_SMC_LO=y
tools/testing/selftests/bpf/prog_tests/test_bpf_smc.c new file +396 -0
396 lines not on this page · raw message
tools/testing/selftests/bpf/progs/bpf_smc.c new file +117 -0
117 lines not on this page · raw message
Signature · 1 line
2.45.0
D. Wythe
maintainerPATCH 1/5 bpf: export necessary sympols for modules with struct_ops
In reply to D. WytheExports three necessary symbols for implementing struct_ops with tristate subsystem.
To hold or release refcnt of struct_ops refcnt by inline funcs bpf_try_module_get and bpf_module_put which use bpf_struct_ops_get(put) conditionally.
And to copy obj name from one to the other with effective checks by bpf_obj_name_cpy.
--- kernel/bpf/bpf_struct_ops.c | 2 ++ kernel/bpf/syscall.c | 1 + 2 files changed, 3 insertions(+)
kernel/bpf/bpf_struct_ops.c +2 -0
@@ -1162,6 +1162,7 @@ bool bpf_struct_ops_get(const void *kdata) map =__bpf_map_inc_not_zero (&st_map->map, false);return !IS_ERR (map); } +EXPORT_SYMBOL_GPL (bpf_struct_ops_get);void bpf_struct_ops_put (const void *kdata) {
@@ -1173,6 +1174,7 @@ void bpf_struct_ops_put(const void *kdata)bpf_map_put (&st_map->map); } +EXPORT_SYMBOL_GPL (bpf_struct_ops_put);static bool bpf_struct_ops_valid_to_reg (struct bpf_map *map) {
kernel/bpf/syscall.c +1 -0
@@ -1201,6 +1201,7 @@ int bpf_obj_name_cpy(char *dst, const char *src, unsigned int size)return src - orig_src; } +EXPORT_SYMBOL_GPL (bpf_obj_name_cpy); int map_check_no_btf(const struct bpf_map *map, const struct btf *btf,
Signature · 1 line
2.45.0
D. Wythe
maintainerPATCH 2/5 net/smc: fix UAF on smcsk after smc_listen_out()
In reply to D. WytheBPF CI testing report a UAF issue:
[ 16.446633] BUG: kernel NULL pointer dereference, address: 000000000000003 0 [ 16.447134] #PF: supervisor read access in kernel mod e [ 16.447516] #PF: error_code(0x0000) - not-present pag e [ 16.447878] PGD 0 P4D 0 [ 16.448063] Oops: Oops: 0000 [#1] PREEMPT SMP NOPT I [ 16.448409] CPU: 0 UID: 0 PID: 9 Comm: kworker/0:1 Tainted: G OE 6.13.0-rc3-g89e8a75fda73-dirty #4 2 [ 16.449124] Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODUL E [ 16.449502] Hardware name: QEMU Ubuntu 24.04 PC (i440FX + PIIX, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/201 4 [ 16.450201] Workqueue: smc_hs_wq smc_listen_wor k [ 16.450531] RIP: 0010:smc_listen_work+0xc02/0x159 0 [ 16.452158] RSP: 0018:ffffb5ab40053d98 EFLAGS: 0001024 6 [ 16.452526] RAX: 0000000000000001 RBX: 0000000000000002 RCX: 000000000000030 0 [ 16.452994] RDX: 0000000000000280 RSI: 00003513840053f0 RDI: 000000000000000 0 [ 16.453492] RBP: ffffa097808e3800 R08: ffffa09782dba1e0 R09: 000000000000000 5 [ 16.453987] R10: 0000000000000000 R11: 0000000000000000 R12: ffffa0978274640 0 [ 16.454497] R13: 0000000000000000 R14: 0000000000000000 R15: ffffa09782d4092 0 [ 16.454996] FS: 0000000000000000(0000) GS:ffffa097bbc00000(0000) knlGS:000000000000000 0 [ 16.455557] CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003 3 [ 16.455961] CR2: 0000000000000030 CR3: 0000000102788004 CR4: 0000000000770ef 0 [ 16.456459] PKRU: 5555555 4 [ 16.456654] Call Trace : [ 16.456832] <TASK > [ 16.456989] ? __die+0x23/0x7 0 [ 16.457215] ? page_fault_oops+0x180/0x4c 0 [ 16.457508] ? __lock_acquire+0x3e6/0x249 0 [ 16.457801] ? exc_page_fault+0x68/0x20 0 [ 16.458080] ? asm_exc_page_fault+0x26/0x3 0 [ 16.458389] ? smc_listen_work+0xc02/0x159 0 [ 16.458689] ? smc_listen_work+0xc02/0x159 0 [ 16.458987] ? lock_is_held_type+0x8f/0x10 0 [ 16.459284] process_one_work+0x1ea/0x6d 0 [ 16.459570] worker_thread+0x1c3/0x38 0 [ 16.459839] ? __pfx_worker_thread+0x10/0x1 0 [ 16.460144] kthread+0xe0/0x11 0 [ 16.460372] ? __pfx_kthread+0x10/0x1 0 [ 16.460640] ret_from_fork+0x31/0x5 0 [ 16.460896] ? __pfx_kthread+0x10/0x1 0 [ 16.461166] ret_from_fork_asm+0x1a/0x3 0 [ 16.461453] </TASK > [ 16.461616] Modules linked in: bpf_testmod(OE) [last unloaded: bpf_testmod(OE) ] [ 16.462134] CR2: 000000000000003 0 [ 16.462380] ---[ end trace 0000000000000000 ]--- [ 16.462710] RIP: 0010:smc_listen_work+0xc02/0x1590
The direct cause of this issue is that after smc_listen_out_connected(), newclcsock->sk may be NULL since it will releases the smcsk. Therefore, if the application closes the socket immediately after accept, newclcsock->sk can be NULL. A possible execution order could be as follows:
smc_listen_work | userspace
-----------------------------------------------------------------
lock_sock(sk) |
smc_listen_out_connected() |
| \- smc_listen_out |
| | \- release_sock |
| |- sk->sk_data_ready() |
| fd = accept();
| close(fd);
| \- socket->sk = NULL;/* newclcsock->sk is NULL now */
SMC_STAT_SERV_SUCC_INC(sock_net(newclcsock->sk))
Since smc_listen_out_connected() will not fail, simply swapping the order of the code can easily fix this issue.
--- net/smc/af_smc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/smc/af_smc.c +2 -1
@@ -2568,8 +2568,9 @@ static void smc_listen_work(struct work_struct *work) goto out_decl; } -smc_listen_out_connected (new_smc);SMC_STAT_SERV_SUCC_INC (sock_net (newclcsock->sk), ini); +/* smc_listen_out() will release smcsk */ +smc_listen_out_connected (new_smc); goto out_free; out_unlock:
Signature · 1 line
2.45.0
D. Wythe
maintainerPATCH 3/5 net/smc: bpf: Introduce generic hook for handshake flow
In reply to D. WytheThe introduction of IPPROTO_SMC enables eBPF programs to determine whether to use SMC based on the context of socket creation, such as network namespaces, PID and comm name, etc.
As a subsequent enhancement, to introduce a new generic hook that allows decisions on whether to use SMC or not at runtime, including but not limited to local/remote IP address or ports.
User can write their own implememtion via bpf_struct_ops now to choose whether to use SMC or not before TCP 3rd handshake to be comleted.
--- include/net/netns/smc.h | 3 + include/net/smc.h | 53 ++++++++++++++++ net/ipv4/tcp_output.c | 18 ++++-- net/smc/Kconfig | 12 ++++ net/smc/Makefile | 1 + net/smc/af_smc.c | 11 ++++ net/smc/smc_hs_bpf.c | 131 ++++++++++++++++++++++++++++++++++++++++ net/smc/smc_hs_bpf.h | 31 ++++++++++ net/smc/smc_sysctl.c | 90 +++++++++++++++++++++++++++ 9 files changed, 346 insertions(+), 4 deletions(-) create mode 100644 net/smc/smc_hs_bpf.c create mode 100644 net/smc/smc_hs_bpf.h
include/net/netns/smc.h +3 -0
@@ -17,6 +17,9 @@ struct netns_smc {#ifdef CONFIG_SYSCTL struct ctl_table_header *smc_hdr;#endif +#if IS_ENABLED (CONFIG_SMC_HS_CTRL_BPF ) +struct smc_hs_ctrl __rcu *hs_ctrl; +#endif /* CONFIG_SMC_HS_CTRL_BPF */ unsigned int sysctl_autocorking_size;unsigned int sysctl_smcr_buf_type;int sysctl_smcr_testlink_time;
include/net/smc.h +53 -0
63 lines not on this page · raw message
net/ipv4/tcp_output.c +14 -4
@@ -40,6 +40,7 @@#include <net/tcp.h> #include <net/mptcp.h> #include <net/proto_memory.h> +#include <net/smc.h> #include <linux/compiler.h> #include <linux/gfp.h>
@@ -764,14 +765,18 @@ static void tcp_options_write(struct tcphdr *th, struct tcp_sock *tp,mptcp_options_write (th, ptr, tp, opts); } -static void smc_set_option (const struct tcp_sock *tp, +static void smc_set_option (struct tcp_sock *tp,struct tcp_out_options *opts,unsigned int *remaining) {#if IS_ENABLED (CONFIG_SMC ) +struct sock *sk = &tp->inet_conn.icsk_inet.sk;if (static_branch_unlikely (&tcp_have_smc)) {if (tp->syn_smc) { -if (*remaining >=TCPOLEN_EXP_SMC_BASE_ALIGNED ) { + tp->syn_smc = !!smc_call_hsbpf (1 , sk, syn_option, tp); +/* re-check syn_smc */ +if (tp->syn_smc && + *remaining >=TCPOLEN_EXP_SMC_BASE_ALIGNED ) { opts->options |=OPTION_SMC ; *remaining -=TCPOLEN_EXP_SMC_BASE_ALIGNED ; }
@@ -781,14 +786,19 @@ static void smc_set_option(const struct tcp_sock *tp, }static void smc_set_option_cond (const struct tcp_sock *tp, -const struct inet_request_sock *ireq, +struct inet_request_sock *ireq,struct tcp_out_options *opts,unsigned int *remaining) {#if IS_ENABLED (CONFIG_SMC ) +const struct sock *sk = &tp->inet_conn.icsk_inet.sk;if (static_branch_unlikely (&tcp_have_smc)) {if (tp->syn_smc && ireq->smc_ok) { -if (*remaining >=TCPOLEN_EXP_SMC_BASE_ALIGNED ) { + ireq->smc_ok = !!smc_call_hsbpf (1 , sk, synack_option, + tp, ireq); +/* re-check smc_ok */ +if (ireq->smc_ok && + *remaining >=TCPOLEN_EXP_SMC_BASE_ALIGNED ) { opts->options |=OPTION_SMC ; *remaining -=TCPOLEN_EXP_SMC_BASE_ALIGNED ; }
net/smc/Kconfig +12 -0
@@ -33,3 +33,15 @@ config SMC_LO of architecture or hardware. if unsure, say N. + +config SMC_HS_CTRL_BPF + bool "Generic eBPF hook for SMC handshake flow" + depends on SMC && BPF_SYSCALL + default n + help + SMC_HS_CTRL_BPF enables support to register generic eBPF hook for SMC + handshake flow, which offer much greater flexibility in modifying the behavior + of the SMC protocol stack compared to a complete kernel-based approach. Select + this option if you want filtring the handshake process via eBPF programs. + + if unsure, say N.
net/smc/Makefile +1 -0
@@ -7,3 +7,4 @@ smc-y += smc_cdc.o smc_tx.o smc_rx.o smc_close.o smc_ism.o smc_netlink.o smc_sta smc-y += smc_tracepoint.o smc_inet.o smc-$(CONFIG_SYSCTL) += smc_sysctl.o smc-$(CONFIG_SMC_LO) += smc_loopback.o +smc-$(CONFIG_SMC_HS_CTRL_BPF) += smc_hs_bpf.o
net/smc/af_smc.c +11 -0
@@ -59,6 +59,7 @@#include "smc_sysctl.h" #include "smc_loopback.h" #include "smc_inet.h" +#include "smc_hs_bpf.h" static DEFINE_MUTEX (smc_server_lgr_pending);/* serialize link group * creation on server
@@ -3610,8 +3611,18 @@ static int __init smc_init(void)pr_err ("%s: smc_inet_init fails with %d\n" , __func__, rc); goto out_ulp; } + + rc =bpf_smc_hs_ctrl_init (); +if (rc) { +pr_err ("%s: bpf_smc_hs_ctrl_init fails with %d\n" , __func__, + rc); + goto out_inet; + } +static_branch_enable (&tcp_have_smc);return 0 ; +out_inet: +smc_inet_exit (); out_ulp:tcp_unregister_ulp (&smc_ulp_ops); out_lo:
net/smc/smc_hs_bpf.c new file +131 -0
131 lines not on this page · raw message
net/smc/smc_hs_bpf.h new file +31 -0
@@ -0,0 +1,31 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Shared Memory Communications over RDMA (SMC-R) and RoCE +* +* Generic hook for SMC subsystem. +* +* Copyright IBM Corp. 2016 +* Copyright (c) 2024, Alibaba Inc. +* +* Author: D. Wythe <[email protected]> +*/ + +#ifndef __SMC_HS_CTRL +#define __SMC_HS_CTRL + +#include <net/smc.h> + +/* Find hs_ctrl by the target name, which required to be a c-string. +* Return NULL if no such ctrl was found,otherwise, return a valid ctrl. +* +* Note: Caller MUST ensure it's was invoked under rcu_read_lock. +*/ +struct smc_hs_ctrl *smc_hs_ctrl_find_by_name (const char *name); + +#if IS_ENABLED (CONFIG_SMC_HS_CTRL_BPF ) +int bpf_smc_hs_ctrl_init (void ); +#else +static inline int bpf_smc_hs_ctrl_init (void ) {return 0 ; } +#endif /* CONFIG_SMC_HS_CTRL_BPF */ + +#endif /* __SMC_HS_CTRL */
net/smc/smc_sysctl.c +90 -0
126 lines not on this page · raw message
Signature · 1 line
2.45.0
D. Wythe
maintainerPATCH 4/5 libbpf: fix error when st-prefix_ops and ops from differ btf
In reply to D. WytheWhen a struct_ops named xxx_ops was registered by a module, and it will be used in both built-in modules and the module itself, so that the btf_type of xxx_ops will be present in btf_vmlinux instead of in btf_mod, which means that the btf_type of bpf_struct_ops_xxx_ops and xxx_ops will not be in the same btf.
Here are four possible case:
+--------+---------------+-------------+---------------------------------+ | | st_ops_xxx_ops| xxx_ops | | +--------+---------------+-------------+---------------------------------+ | case 0 | btf_vmlinux | bft_vmlinux | be used and reg only in vmlinux | +--------+---------------+-------------+---------------------------------+ | case 1 | btf_vmlinux | bpf_mod | INVALID | +--------+---------------+-------------+---------------------------------+ | case 2 | btf_mod | btf_vmlinux | reg in mod but be used both in | | | | | vmlinux and mod. | +--------+---------------+-------------+---------------------------------+ | case 3 | btf_mod | btf_mod | be used and reg only in mod | +--------+---------------+-------------+---------------------------------+
At present, cases 0, 1, and 3 can be correctly identified, because st_ops_xxx_ops is searched from the same btf with xxx_ops. In order to handle case 2 correctly without affecting other cases, we cannot simply change the search method for st_ops_xxx_ops from find_btf_by_prefix_kind() to find_ksym_btf_id(), because in this way, case 1 will not be recognized anymore.
To address the issue, we always look for st_ops_xxx_ops first, figure out the btf, and then look for xxx_ops with the very btf to avoid such issue.
--- tools/lib/bpf/libbpf.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-)
tools/lib/bpf/libbpf.c +18 -19
@@ -1013,35 +1013,34 @@ find_struct_ops_kern_types(struct bpf_object *obj, const char *tname_raw,const struct btf_member *kern_data_member;struct btf *btf =NULL ;__s32 kern_vtype_id, kern_type_id; -char tname[256 ]; +char tname[256 ], stname[256 ];__u32 i;snprintf (tname,sizeof (tname),"%.*s" , (int )bpf_core_essential_name_len (tname_raw), tname_raw); - kern_type_id =find_ksym_btf_id (obj, tname,BTF_KIND_STRUCT , - &btf, mod_btf); -if (kern_type_id <0 ) { -pr_warn ("struct_ops init_kern: struct %s is not found in kernel BTF\n" , - tname); -return kern_type_id; - } - kern_type =btf__type_by_id (btf, kern_type_id); +snprintf (stname,sizeof (stname),"%s%.*s" ,STRUCT_OPS_VALUE_PREFIX , + (int )strlen (tname), tname); -/* Find the corresponding "map_value" type that will be used -* in map_update(BPF_MAP_TYPE_STRUCT_OPS). For example, -* find "struct bpf_struct_ops_tcp_congestion_ops" from the -* btf_vmlinux. +/* Look for the corresponding "map_value" type that will be used +* in map_update(BPF_MAP_TYPE_STRUCT_OPS) first, figure out the btf +* and the mod_btf. +* For example, find "struct bpf_struct_ops_tcp_congestion_ops". */ - kern_vtype_id =find_btf_by_prefix_kind (btf,STRUCT_OPS_VALUE_PREFIX , - tname,BTF_KIND_STRUCT ); + kern_vtype_id =find_ksym_btf_id (obj, stname,BTF_KIND_STRUCT , &btf, mod_btf);if (kern_vtype_id <0 ) { -pr_warn ("struct_ops init_kern: struct %s%s is not found in kernel BTF\n" , -STRUCT_OPS_VALUE_PREFIX , tname); +pr_warn ("struct_ops init_kern: struct %s is not found in kernel BTF\n" , stname);return kern_vtype_id; } kern_vtype =btf__type_by_id (btf, kern_vtype_id); + kern_type_id =btf__find_by_name_kind (btf, tname,BTF_KIND_STRUCT ); +if (kern_type_id <0 ) { +pr_warn ("struct_ops init_kern: struct %s is not found in kernel BTF\n" , tname); +return kern_type_id; + } + kern_type =btf__type_by_id (btf, kern_type_id); +/* Find "struct tcp_congestion_ops" from * struct bpf_struct_ops_tcp_congestion_ops { * [ ... ]
@@ -1054,8 +1053,8 @@ find_struct_ops_kern_types(struct bpf_object *obj, const char *tname_raw,break ; }if (i ==btf_vlen (kern_vtype)) { -pr_warn ("struct_ops init_kern: struct %s data is not found in struct %s%s\n" , - tname,STRUCT_OPS_VALUE_PREFIX , tname); +pr_warn ("struct_ops init_kern: struct %s data is not found in struct %s\n" , + tname, stname);return -EINVAL ; }
Signature · 1 line
2.45.0
Re: [PATCH bpf-next 1/5] bpf: export necessary sympols for modules with struct_ops
In reply to D. Wythetypo in commit message title? s/sympols/symbols/g
Re: [PATCH bpf-next 2/5] net/smc: fix UAF on smcsk after smc_listen_out()
In reply to D. WytheQuoted 2 lines · D. Wythe
BPF CI testing report a UAF issue:
[..]
Quoted 13 lines
Fixes 3b2dec2603d5 ("net/smc: restructure client and server code in af_smc")Signed-off-by D. Wythe <[email protected]>Reviewed-by Guangguan Wang <[email protected]>--- net/smc/af_smc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)net/smc/af_smc.c +0
-0
net/smc/af_smc.c static void smc_listen_work(struct work_struct *work) · line 2576
Quoted 10 lines
net/smc/af_smc.c +2
-1@@ -2568,8 +2568,9 @@ static void smc_listen_work(struct work_struct *work) goto out_decl; } -smc_listen_out_connected (new_smc);SMC_STAT_SERV_SUCC_INC (sock_net (newclcsock->sk), ini); +/* smc_listen_out() will release smcsk */ +smc_listen_out_connected (new_smc); goto out_free; out_unlock:
As this is a problem fix, you could send it directly to 'net' instead of including it to this series.
kernel test robot
build botRe: [PATCH bpf-next 3/5] net/smc: bpf: Introduce generic hook for handshake flow
In reply to D. Wythekernel test robot noticed the following build warnings:
Hi Wythe,
kernel test robot noticed the following build warnings:
[auto build test WARNING on bpf-next/master]
url: https://github.com/intel-lab-lkp/linux/commits/D-Wythe/bpf-export-necessary-sympols-for-modules-with-struct_ops/20250731-164431 base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master patch link: https://lore.kernel.org/r/20250731084240.86550-4-alibuda%40linux.alibaba.com patch subject: [PATCH bpf-next 3/5] net/smc: bpf: Introduce generic hook for handshake flow config: arm-randconfig-003-20250801 (https://download.01.org/0day-ci/archive/20250801/[email protected]/config) compiler: arm-linux-gnueabi-gcc (GCC) 10.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250801/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
net/ipv4/tcp_output.c: In function 'smc_set_option':
>> net/ipv4/tcp_output.c:773:15: warning: unused variable 'sk' [-Wunused-variable]
773 | struct sock *sk = &tp->inet_conn.icsk_inet.sk;
| ^~
net/ipv4/tcp_output.c: In function 'smc_set_option_cond':
net/ipv4/tcp_output.c:794:21: warning: unused variable 'sk' [-Wunused-variable]
794 | const struct sock *sk = &tp->inet_conn.icsk_inet.sk;
| ^~vim +/sk +773 net/ipv4/tcp_output.c
767
768 static void smc_set_option(struct tcp_sock *tp,
769 struct tcp_out_options *opts,
770 unsigned int *remaining)
771 {
772 #if IS_ENABLED(CONFIG_SMC)
> 773 struct sock *sk = &tp->inet_conn.icsk_inet.sk;
774 if (static_branch_unlikely(&tcp_have_smc)) {
775 if (tp->syn_smc) {
776 tp->syn_smc = !!smc_call_hsbpf(1, sk, syn_option, tp);
777 /* re-check syn_smc */
778 if (tp->syn_smc &&
779 *remaining >= TCPOLEN_EXP_SMC_BASE_ALIGNED) {
780 opts->options |= OPTION_SMC;
781 *remaining -= TCPOLEN_EXP_SMC_BASE_ALIGNED;
782 }
783 }
784 }
785 #endif
786 }
787
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
D. Wythe
maintainerRe: [PATCH bpf-next 2/5] net/smc: fix UAF on smcsk after smc_listen_out()
In reply to Alexandra WinterQuoted 28 lines · Alexandra Winter
Quoted 2 lines · D. Wythe
BPF CI testing report a UAF issue:
[..]
Quoted 22 lines
Fixes 3b2dec2603d5 ("net/smc: restructure client and server code in af_smc")Signed-off-by D. Wythe <[email protected]>Reviewed-by Guangguan Wang <[email protected]>--- net/smc/af_smc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)net/smc/af_smc.c +2
-1@@ -2568,8 +2568,9 @@ static void smc_listen_work(struct work_struct *work) goto out_decl; } -smc_listen_out_connected (new_smc);SMC_STAT_SERV_SUCC_INC (sock_net (newclcsock->sk), ini); +/* smc_listen_out() will release smcsk */ +smc_listen_out_connected (new_smc); goto out_free;
Quoted 6 lines
net/smc/af_smc.c static void smc_listen_work(struct work_struct *work) · line 2576
Quoted 1 line
net/smc/af_smc.c +0
-0out_unlock:As this is a problem fix, you could send it directly to 'net' instead of including it to this series.
Hi Alexandra,
Yes, it should be sent to net. But the problem is that if I don't carry this patch, the BPF CI test will always crash. Maybe I should send a copy to both net and bpf-next? Do you have any suggestions?
Best wishes,
D. Wythe
Quoted 1 line
Reviewed-by Alexandra Winter <[email protected]>
D. Wythe
maintainerRe: [PATCH bpf-next 1/5] bpf: export necessary sympols for modules with struct_ops
In reply to Alexandra WinterQuoted 1 line · Alexandra Winter
typo in commit message title? s/sympols/symbols/g
What a mistake... I will fix it in the next series.
Thanks,
D. Wythe
Quoted 3 lines
Re: [PATCH bpf-next 2/5] net/smc: fix UAF on smcsk after smc_listen_out()
In reply to D. WytheQuoted 12 lines · D. Wythe
Quoted 10 lines · Alexandra Winter
Quoted 2 lines · D. Wythe
BPF CI testing report a UAF issue:
[..]
As this is a problem fix, you could send it directly to 'net' instead of including it to this series.
Quoted 8 lines
Hi Alexandra,
Yes, it should be sent to net. But the problem is that if I don't carry this patch, the BPF CI test will always crash. Maybe I should send a copy to both net and bpf-next? Do you have any suggestions?
Best wishes,
D. Wythe
I do not have any experience with bpf-next. But typically patches to 'net' are taken after one or two days, if there are no issues. I'd assume they are then picked to net-next and bpf-next(?) almost instantly. Then you would not need it in your bpf series anymore.
Sending a patch to two different mailing lists in parallel sounds like a bad idea to me.
Jakub Kicinski
maintainerRe: [PATCH bpf-next 2/5] net/smc: fix UAF on smcsk after smc_listen_out()
Quoted 8 lines · On Mon, 11 Aug 2025 11:24:50 +0200 Alexandra Winter wrote:
Quoted 3 lines
Yes, it should be sent to net. But the problem is that if I don't carry this patch, the BPF CI test will always crash. Maybe I should send a copy to both net and bpf-next? Do you have any suggestions?
I do not have any experience with bpf-next. But typically patches to 'net' are taken after one or two days, if there are no issues. I'd assume they are then picked to net-next and bpf-next(?) almost instantly. Then you would not need it in your bpf series anymore.
AFAIU the patches which land in net will make it to -next trees after respective PR with fixes. So
patch ->
net ->
[next Thu] Linus ->
[same day] net-next
[at some point] bpf PR ->
Linux
-> bpf-nextWhat gets applied to net should be in net-next in a week, and most -next trees within 2 weeks.
D. Wythe
maintainerRe: [PATCH bpf-next 2/5] net/smc: fix UAF on smcsk after smc_listen_out()
Quoted 22 lines · Jakub Kicinski
Quoted 8 lines · On Mon, 11 Aug 2025 11:24:50 +0200 Alexandra Winter wrote:
Quoted 3 lines
Yes, it should be sent to net. But the problem is that if I don't carry this patch, the BPF CI test will always crash. Maybe I should send a copy to both net and bpf-next? Do you have any suggestions?
I do not have any experience with bpf-next. But typically patches to 'net' are taken after one or two days, if there are no issues. I'd assume they are then picked to net-next and bpf-next(?) almost instantly. Then you would not need it in your bpf series anymore.
AFAIU the patches which land in net will make it to -next trees after respective PR with fixes. So
patch ->
net -> [next Thu] Linus -> [same day] net-next [at some point] bpf PR -> Linux -> bpf-next
Quoted 2 lines
What gets applied to net should be in net-next in a week, and most -next trees within 2 weeks.
That's very helpful.
Based on those infomations, I will send this prerequisite patch to the net tree first. I'll then wait for about two weeks for it to propagate to bpf-next before submitting the rest of my BPF series.
Best regards,
D. Wythe