Skip to content

Commit 57afa44

Browse files
committed
netfilter: nf_tables: Fix potential data-race in __nft_obj_type_get()
jira LE-1907 cve CVE-2024-27019 Rebuild_History Non-Buildable kernel-4.18.0-553.16.1.el8_10 commit-author Ziyang Xuan <[email protected]> commit d78d867 Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-4.18.0-553.16.1.el8_10/d78d867d.failed nft_unregister_obj() can concurrent with __nft_obj_type_get(), and there is not any protection when iterate over nf_tables_objects list in __nft_obj_type_get(). Therefore, there is potential data-race of nf_tables_objects list entry. Use list_for_each_entry_rcu() to iterate over nf_tables_objects list in __nft_obj_type_get(), and use rcu_read_lock() in the caller nft_obj_type_get() to protect the entire type query process. Fixes: e500924 ("netfilter: nf_tables: add stateful objects") Signed-off-by: Ziyang Xuan <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> (cherry picked from commit d78d867) Signed-off-by: Jonathan Maple <[email protected]> # Conflicts: # net/netfilter/nf_tables_api.c
1 parent d9d0c8e commit 57afa44

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
netfilter: nf_tables: Fix potential data-race in __nft_obj_type_get()
2+
3+
jira LE-1907
4+
cve CVE-2024-27019
5+
Rebuild_History Non-Buildable kernel-4.18.0-553.16.1.el8_10
6+
commit-author Ziyang Xuan <[email protected]>
7+
commit d78d867dcea69c328db30df665be5be7d0148484
8+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
9+
Will be included in final tarball splat. Ref for failed cherry-pick at:
10+
ciq/ciq_backports/kernel-4.18.0-553.16.1.el8_10/d78d867d.failed
11+
12+
nft_unregister_obj() can concurrent with __nft_obj_type_get(),
13+
and there is not any protection when iterate over nf_tables_objects
14+
list in __nft_obj_type_get(). Therefore, there is potential data-race
15+
of nf_tables_objects list entry.
16+
17+
Use list_for_each_entry_rcu() to iterate over nf_tables_objects
18+
list in __nft_obj_type_get(), and use rcu_read_lock() in the caller
19+
nft_obj_type_get() to protect the entire type query process.
20+
21+
Fixes: e50092404c1b ("netfilter: nf_tables: add stateful objects")
22+
Signed-off-by: Ziyang Xuan <[email protected]>
23+
Signed-off-by: Pablo Neira Ayuso <[email protected]>
24+
(cherry picked from commit d78d867dcea69c328db30df665be5be7d0148484)
25+
Signed-off-by: Jonathan Maple <[email protected]>
26+
27+
# Conflicts:
28+
# net/netfilter/nf_tables_api.c
29+
diff --cc net/netfilter/nf_tables_api.c
30+
index abc82fddd260,f11d0c0a2c73..000000000000
31+
--- a/net/netfilter/nf_tables_api.c
32+
+++ b/net/netfilter/nf_tables_api.c
33+
@@@ -6135,7 -7611,11 +6135,15 @@@ static const struct nft_object_type *__
34+
{
35+
const struct nft_object_type *type;
36+
37+
++<<<<<<< HEAD
38+
+ list_for_each_entry(type, &nf_tables_objects, list) {
39+
++=======
40+
+ list_for_each_entry_rcu(type, &nf_tables_objects, list) {
41+
+ if (type->family != NFPROTO_UNSPEC &&
42+
+ type->family != family)
43+
+ continue;
44+
+
45+
++>>>>>>> d78d867dcea6 (netfilter: nf_tables: Fix potential data-race in __nft_obj_type_get())
46+
if (objtype == type->type)
47+
return type;
48+
}
49+
@@@ -6147,9 -7627,13 +6155,18 @@@ nft_obj_type_get(struct net *net, u32 o
50+
{
51+
const struct nft_object_type *type;
52+
53+
++<<<<<<< HEAD
54+
+ type = __nft_obj_type_get(objtype);
55+
+ if (type != NULL && try_module_get(type->owner))
56+
++=======
57+
+ rcu_read_lock();
58+
+ type = __nft_obj_type_get(objtype, family);
59+
+ if (type != NULL && try_module_get(type->owner)) {
60+
+ rcu_read_unlock();
61+
++>>>>>>> d78d867dcea6 (netfilter: nf_tables: Fix potential data-race in __nft_obj_type_get())
62+
return type;
63+
+ }
64+
+ rcu_read_unlock();
65+
66+
lockdep_nfnl_nft_mutex_not_held();
67+
#ifdef CONFIG_MODULES
68+
* Unmerged path net/netfilter/nf_tables_api.c

0 commit comments

Comments
 (0)