diff mbox series

[net] net: netfilter: move nf flowtable bpf initialization in nf_flow_table_module_init()

Message ID 20240911-nf-flowtable-bpf-modprob-fix-v1-1-f9fc075aafc3@kernel.org (mailing list archive)
State Accepted
Commit 3e705251d998c9688be0e7e0526c250fec24d233
Delegated to: Netdev Maintainers
Headers show
Series [net] net: netfilter: move nf flowtable bpf initialization in nf_flow_table_module_init() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 17 this patch: 17
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-09-12--12-00 (tests: 762)

Commit Message

Lorenzo Bianconi Sept. 11, 2024, 3:37 p.m. UTC
Move nf flowtable bpf initialization in nf_flow_table module load
routine since nf_flow_table_bpf is part of nf_flow_table module and not
nf_flow_table_inet one. This patch allows to avoid the following kernel
warning running the reproducer below:

$modprobe nf_flow_table_inet
$rmmod nf_flow_table_inet
$modprobe nf_flow_table_inet
modprobe: ERROR: could not insert 'nf_flow_table_inet': Invalid argument

[  184.081501] ------------[ cut here ]------------
[  184.081527] WARNING: CPU: 0 PID: 1362 at kernel/bpf/btf.c:8206 btf_populate_kfunc_set+0x23c/0x330
[  184.081550] CPU: 0 UID: 0 PID: 1362 Comm: modprobe Kdump: loaded Not tainted 6.11.0-0.rc5.22.el10.x86_64 #1
[  184.081553] Hardware name: Red Hat OpenStack Compute, BIOS 1.14.0-1.module+el8.4.0+8855+a9e237a9 04/01/2014
[  184.081554] RIP: 0010:btf_populate_kfunc_set+0x23c/0x330
[  184.081558] RSP: 0018:ff22cfb38071fc90 EFLAGS: 00010202
[  184.081559] RAX: 0000000000000001 RBX: 0000000000000001 RCX: 0000000000000000
[  184.081560] RDX: 000000000000006e RSI: ffffffff95c00000 RDI: ff13805543436350
[  184.081561] RBP: ffffffffc0e22180 R08: ff13805543410808 R09: 000000000001ec00
[  184.081562] R10: ff13805541c8113c R11: 0000000000000010 R12: ff13805541b83c00
[  184.081563] R13: ff13805543410800 R14: 0000000000000001 R15: ffffffffc0e2259a
[  184.081564] FS:  00007fa436c46740(0000) GS:ff1380557ba00000(0000) knlGS:0000000000000000
[  184.081569] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  184.081570] CR2: 000055e7b3187000 CR3: 0000000100c48003 CR4: 0000000000771ef0
[  184.081571] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[  184.081572] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[  184.081572] PKRU: 55555554
[  184.081574] Call Trace:
[  184.081575]  <TASK>
[  184.081578]  ? show_trace_log_lvl+0x1b0/0x2f0
[  184.081580]  ? show_trace_log_lvl+0x1b0/0x2f0
[  184.081582]  ? __register_btf_kfunc_id_set+0x199/0x200
[  184.081585]  ? btf_populate_kfunc_set+0x23c/0x330
[  184.081586]  ? __warn.cold+0x93/0xed
[  184.081590]  ? btf_populate_kfunc_set+0x23c/0x330
[  184.081592]  ? report_bug+0xff/0x140
[  184.081594]  ? handle_bug+0x3a/0x70
[  184.081596]  ? exc_invalid_op+0x17/0x70
[  184.081597]  ? asm_exc_invalid_op+0x1a/0x20
[  184.081601]  ? btf_populate_kfunc_set+0x23c/0x330
[  184.081602]  __register_btf_kfunc_id_set+0x199/0x200
[  184.081605]  ? __pfx_nf_flow_inet_module_init+0x10/0x10 [nf_flow_table_inet]
[  184.081607]  do_one_initcall+0x58/0x300
[  184.081611]  do_init_module+0x60/0x230
[  184.081614]  __do_sys_init_module+0x17a/0x1b0
[  184.081617]  do_syscall_64+0x7d/0x160
[  184.081620]  ? __count_memcg_events+0x58/0xf0
[  184.081623]  ? handle_mm_fault+0x234/0x350
[  184.081626]  ? do_user_addr_fault+0x347/0x640
[  184.081630]  ? clear_bhb_loop+0x25/0x80
[  184.081633]  ? clear_bhb_loop+0x25/0x80
[  184.081634]  ? clear_bhb_loop+0x25/0x80
[  184.081637]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
[  184.081639] RIP: 0033:0x7fa43652e4ce
[  184.081647] RSP: 002b:00007ffe8213be18 EFLAGS: 00000246 ORIG_RAX: 00000000000000af
[  184.081649] RAX: ffffffffffffffda RBX: 000055e7b3176c20 RCX: 00007fa43652e4ce
[  184.081650] RDX: 000055e7737fde79 RSI: 0000000000003990 RDI: 000055e7b3185380
[  184.081651] RBP: 000055e7737fde79 R08: 0000000000000007 R09: 000055e7b3179bd0
[  184.081651] R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000040000
[  184.081652] R13: 000055e7b3176fa0 R14: 0000000000000000 R15: 000055e7b3179b80

Fixes: 391bb6594fd3 ("netfilter: Add bpf_xdp_flow_lookup kfunc")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
---
 net/netfilter/nf_flow_table_core.c | 6 ++++++
 net/netfilter/nf_flow_table_inet.c | 2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)


---
base-commit: d1aaaa2e0a6742b2bc4d851eb1a2b6390dbde2d9
change-id: 20240911-nf-flowtable-bpf-modprob-fix-2796fb448681

Best regards,

Comments

Florian Westphal Sept. 11, 2024, 3:42 p.m. UTC | #1
Lorenzo Bianconi <lorenzo@kernel.org> wrote:
> Move nf flowtable bpf initialization in nf_flow_table module load
> routine since nf_flow_table_bpf is part of nf_flow_table module and not
> nf_flow_table_inet one. This patch allows to avoid the following kernel
> warning running the reproducer below:
> 
> $modprobe nf_flow_table_inet
> $rmmod nf_flow_table_inet
> $modprobe nf_flow_table_inet
> modprobe: ERROR: could not insert 'nf_flow_table_inet': Invalid argument

LGTM, thanks Lorenzo.

Acked-by: Florian Westphal <fw@strlen.de>
Pablo Neira Ayuso Sept. 11, 2024, 10:26 p.m. UTC | #2
On Wed, Sep 11, 2024 at 05:37:30PM +0200, Lorenzo Bianconi wrote:
> Move nf flowtable bpf initialization in nf_flow_table module load
> routine since nf_flow_table_bpf is part of nf_flow_table module and not
> nf_flow_table_inet one. This patch allows to avoid the following kernel
> warning running the reproducer below:

Targeting a net tree, here is my tag:

Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Paolo Abeni Sept. 12, 2024, 1:39 p.m. UTC | #3
On 9/11/24 17:37, Lorenzo Bianconi wrote:
> Move nf flowtable bpf initialization in nf_flow_table module load
> routine since nf_flow_table_bpf is part of nf_flow_table module and not
> nf_flow_table_inet one. This patch allows to avoid the following kernel
> warning running the reproducer below:
> 
> $modprobe nf_flow_table_inet
> $rmmod nf_flow_table_inet
> $modprobe nf_flow_table_inet
> modprobe: ERROR: could not insert 'nf_flow_table_inet': Invalid argument
> 
> [  184.081501] ------------[ cut here ]------------
> [  184.081527] WARNING: CPU: 0 PID: 1362 at kernel/bpf/btf.c:8206 btf_populate_kfunc_set+0x23c/0x330
> [  184.081550] CPU: 0 UID: 0 PID: 1362 Comm: modprobe Kdump: loaded Not tainted 6.11.0-0.rc5.22.el10.x86_64 #1
> [  184.081553] Hardware name: Red Hat OpenStack Compute, BIOS 1.14.0-1.module+el8.4.0+8855+a9e237a9 04/01/2014
> [  184.081554] RIP: 0010:btf_populate_kfunc_set+0x23c/0x330
> [  184.081558] RSP: 0018:ff22cfb38071fc90 EFLAGS: 00010202
> [  184.081559] RAX: 0000000000000001 RBX: 0000000000000001 RCX: 0000000000000000
> [  184.081560] RDX: 000000000000006e RSI: ffffffff95c00000 RDI: ff13805543436350
> [  184.081561] RBP: ffffffffc0e22180 R08: ff13805543410808 R09: 000000000001ec00
> [  184.081562] R10: ff13805541c8113c R11: 0000000000000010 R12: ff13805541b83c00
> [  184.081563] R13: ff13805543410800 R14: 0000000000000001 R15: ffffffffc0e2259a
> [  184.081564] FS:  00007fa436c46740(0000) GS:ff1380557ba00000(0000) knlGS:0000000000000000
> [  184.081569] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [  184.081570] CR2: 000055e7b3187000 CR3: 0000000100c48003 CR4: 0000000000771ef0
> [  184.081571] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> [  184.081572] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> [  184.081572] PKRU: 55555554
> [  184.081574] Call Trace:
> [  184.081575]  <TASK>
> [  184.081578]  ? show_trace_log_lvl+0x1b0/0x2f0
> [  184.081580]  ? show_trace_log_lvl+0x1b0/0x2f0
> [  184.081582]  ? __register_btf_kfunc_id_set+0x199/0x200
> [  184.081585]  ? btf_populate_kfunc_set+0x23c/0x330
> [  184.081586]  ? __warn.cold+0x93/0xed
> [  184.081590]  ? btf_populate_kfunc_set+0x23c/0x330
> [  184.081592]  ? report_bug+0xff/0x140
> [  184.081594]  ? handle_bug+0x3a/0x70
> [  184.081596]  ? exc_invalid_op+0x17/0x70
> [  184.081597]  ? asm_exc_invalid_op+0x1a/0x20
> [  184.081601]  ? btf_populate_kfunc_set+0x23c/0x330
> [  184.081602]  __register_btf_kfunc_id_set+0x199/0x200
> [  184.081605]  ? __pfx_nf_flow_inet_module_init+0x10/0x10 [nf_flow_table_inet]
> [  184.081607]  do_one_initcall+0x58/0x300
> [  184.081611]  do_init_module+0x60/0x230
> [  184.081614]  __do_sys_init_module+0x17a/0x1b0
> [  184.081617]  do_syscall_64+0x7d/0x160
> [  184.081620]  ? __count_memcg_events+0x58/0xf0
> [  184.081623]  ? handle_mm_fault+0x234/0x350
> [  184.081626]  ? do_user_addr_fault+0x347/0x640
> [  184.081630]  ? clear_bhb_loop+0x25/0x80
> [  184.081633]  ? clear_bhb_loop+0x25/0x80
> [  184.081634]  ? clear_bhb_loop+0x25/0x80
> [  184.081637]  entry_SYSCALL_64_after_hwframe+0x76/0x7e
> [  184.081639] RIP: 0033:0x7fa43652e4ce
> [  184.081647] RSP: 002b:00007ffe8213be18 EFLAGS: 00000246 ORIG_RAX: 00000000000000af
> [  184.081649] RAX: ffffffffffffffda RBX: 000055e7b3176c20 RCX: 00007fa43652e4ce
> [  184.081650] RDX: 000055e7737fde79 RSI: 0000000000003990 RDI: 000055e7b3185380
> [  184.081651] RBP: 000055e7737fde79 R08: 0000000000000007 R09: 000055e7b3179bd0
> [  184.081651] R10: 0000000000000001 R11: 0000000000000246 R12: 0000000000040000
> [  184.081652] R13: 000055e7b3176fa0 R14: 0000000000000000 R15: 000055e7b3179b80
> 
> Fixes: 391bb6594fd3 ("netfilter: Add bpf_xdp_flow_lookup kfunc")
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>

The reported CI failures looks like an independent flake.

Since already acked by the relevant parties, accepting this a little 
lower the 24H grace period to land into todays PR.

Cheers,

/P
patchwork-bot+netdevbpf@kernel.org Sept. 12, 2024, 1:50 p.m. UTC | #4
Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Wed, 11 Sep 2024 17:37:30 +0200 you wrote:
> Move nf flowtable bpf initialization in nf_flow_table module load
> routine since nf_flow_table_bpf is part of nf_flow_table module and not
> nf_flow_table_inet one. This patch allows to avoid the following kernel
> warning running the reproducer below:
> 
> $modprobe nf_flow_table_inet
> $rmmod nf_flow_table_inet
> $modprobe nf_flow_table_inet
> modprobe: ERROR: could not insert 'nf_flow_table_inet': Invalid argument
> 
> [...]

Here is the summary with links:
  - [net] net: netfilter: move nf flowtable bpf initialization in nf_flow_table_module_init()
    https://git.kernel.org/netdev/net/c/3e705251d998

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
index 5c1ff07eaee0..df72b0376970 100644
--- a/net/netfilter/nf_flow_table_core.c
+++ b/net/netfilter/nf_flow_table_core.c
@@ -670,8 +670,14 @@  static int __init nf_flow_table_module_init(void)
 	if (ret)
 		goto out_offload;
 
+	ret = nf_flow_register_bpf();
+	if (ret)
+		goto out_bpf;
+
 	return 0;
 
+out_bpf:
+	nf_flow_table_offload_exit();
 out_offload:
 	unregister_pernet_subsys(&nf_flow_table_net_ops);
 	return ret;
diff --git a/net/netfilter/nf_flow_table_inet.c b/net/netfilter/nf_flow_table_inet.c
index 8b541a080342..b0f199171932 100644
--- a/net/netfilter/nf_flow_table_inet.c
+++ b/net/netfilter/nf_flow_table_inet.c
@@ -101,7 +101,7 @@  static int __init nf_flow_inet_module_init(void)
 	nft_register_flowtable_type(&flowtable_ipv6);
 	nft_register_flowtable_type(&flowtable_inet);
 
-	return nf_flow_register_bpf();
+	return 0;
 }
 
 static void __exit nf_flow_inet_module_exit(void)