Commit 3fac8ce
netfilter: nf_tables: double hook unregistration in netns path
commit f9a4300 upstream.
[ This backport includes ab5e5c0 ("netfilter: nf_tables: use
kfree_rcu(ptr, rcu) to release hooks in clean_net path") ]
__nft_release_hooks() is called from pre_netns exit path which
unregisters the hooks, then the NETDEV_UNREGISTER event is triggered
which unregisters the hooks again.
[ 565.221461] WARNING: CPU: 18 PID: 193 at net/netfilter/core.c:495 __nf_unregister_net_hook+0x247/0x270
[...]
[ 565.246890] CPU: 18 PID: 193 Comm: kworker/u64:1 Tainted: G E 5.18.0-rc7+ #27
[ 565.253682] Workqueue: netns cleanup_net
[ 565.257059] RIP: 0010:__nf_unregister_net_hook+0x247/0x270
[...]
[ 565.297120] Call Trace:
[ 565.300900] <TASK>
[ 565.304683] nf_tables_flowtable_event+0x16a/0x220 [nf_tables]
[ 565.308518] raw_notifier_call_chain+0x63/0x80
[ 565.312386] unregister_netdevice_many+0x54f/0xb50
Unregister and destroy netdev hook from netns pre_exit via kfree_rcu
so the NETDEV_UNREGISTER path see unregistered hooks.
Fixes: 767d121 ("netfilter: nftables: fix possible UAF over chains from packet path in netns")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent e51f308 commit 3fac8ce
1 file changed
+41
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
| 306 | + | |
| 307 | + | |
307 | 308 | | |
308 | | - | |
| 309 | + | |
309 | 310 | | |
310 | | - | |
| 311 | + | |
311 | 312 | | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
312 | 318 | | |
313 | 319 | | |
314 | 320 | | |
| |||
334 | 340 | | |
335 | 341 | | |
336 | 342 | | |
337 | | - | |
338 | | - | |
339 | | - | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
340 | 347 | | |
341 | 348 | | |
342 | 349 | | |
| |||
351 | 358 | | |
352 | 359 | | |
353 | 360 | | |
354 | | - | |
| 361 | + | |
| 362 | + | |
355 | 363 | | |
356 | 364 | | |
357 | 365 | | |
358 | 366 | | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
359 | 374 | | |
360 | 375 | | |
361 | 376 | | |
| |||
6822 | 6837 | | |
6823 | 6838 | | |
6824 | 6839 | | |
6825 | | - | |
6826 | | - | |
| 6840 | + | |
| 6841 | + | |
| 6842 | + | |
6827 | 6843 | | |
6828 | | - | |
| 6844 | + | |
6829 | 6845 | | |
6830 | | - | |
| 6846 | + | |
6831 | 6847 | | |
| 6848 | + | |
| 6849 | + | |
| 6850 | + | |
| 6851 | + | |
| 6852 | + | |
| 6853 | + | |
| 6854 | + | |
| 6855 | + | |
| 6856 | + | |
| 6857 | + | |
| 6858 | + | |
6832 | 6859 | | |
6833 | 6860 | | |
6834 | 6861 | | |
| |||
9472 | 9499 | | |
9473 | 9500 | | |
9474 | 9501 | | |
9475 | | - | |
| 9502 | + | |
9476 | 9503 | | |
9477 | | - | |
| 9504 | + | |
| 9505 | + | |
9478 | 9506 | | |
9479 | 9507 | | |
9480 | 9508 | | |
| |||
0 commit comments