Skip to content

Commit fd5ce20

Browse files
committed
netfilter: nf_tables: remove catchall element in GC sync path
subsystem-update netfilter: centos-stream-9 cfd9694 cve CVE-2023-6111 commit-author Pablo Neira Ayuso <pablo@netfilter.org> commit 93995bf upstream-diff Used the cleanly applying 9.4 backport 54e39cc The expired catchall element is not deactivated and removed from GC sync path. This path holds mutex so just call nft_setelem_data_deactivate() and nft_setelem_catchall_remove() before queueing the GC work. Fixes: 4a9e12e ("netfilter: nft_set_pipapo: call nft_trans_gc_queue_sync() in catchall GC") Reported-by: lonial con <kongln9170@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> (cherry picked from commit 93995bf) Signed-off-by: Marcin Wcisło <marcin.wcislo@conclusive.pl>
1 parent 667c97b commit fd5ce20

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

net/netfilter/nf_tables_api.c

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6168,6 +6168,12 @@ static int nft_setelem_deactivate(const struct net *net,
61686168
return ret;
61696169
}
61706170

6171+
static void nft_setelem_catchall_destroy(struct nft_set_elem_catchall *catchall)
6172+
{
6173+
list_del_rcu(&catchall->list);
6174+
kfree_rcu(catchall, rcu);
6175+
}
6176+
61716177
static void nft_setelem_catchall_remove(const struct net *net,
61726178
const struct nft_set *set,
61736179
const struct nft_set_elem *elem)
@@ -6176,8 +6182,7 @@ static void nft_setelem_catchall_remove(const struct net *net,
61766182

61776183
list_for_each_entry_safe(catchall, next, &set->catchall_list, list) {
61786184
if (catchall->elem == elem->priv) {
6179-
list_del_rcu(&catchall->list);
6180-
kfree_rcu(catchall, rcu);
6185+
nft_setelem_catchall_destroy(catchall);
61816186
break;
61826187
}
61836188
}
@@ -9163,11 +9168,12 @@ static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
91639168
unsigned int gc_seq,
91649169
bool sync)
91659170
{
9166-
struct nft_set_elem_catchall *catchall;
9171+
struct nft_set_elem_catchall *catchall, *next;
91679172
const struct nft_set *set = gc->set;
9173+
struct nft_elem_priv *elem_priv;
91689174
struct nft_set_ext *ext;
91699175

9170-
list_for_each_entry_rcu(catchall, &set->catchall_list, list) {
9176+
list_for_each_entry_safe(catchall, next, &set->catchall_list, list) {
91719177
ext = nft_set_elem_ext(set, catchall->elem);
91729178

91739179
if (!nft_set_elem_expired(ext))
@@ -9185,7 +9191,17 @@ static struct nft_trans_gc *nft_trans_gc_catchall(struct nft_trans_gc *gc,
91859191
if (!gc)
91869192
return NULL;
91879193

9188-
nft_trans_gc_elem_add(gc, catchall->elem);
9194+
elem_priv = catchall->elem;
9195+
if (sync) {
9196+
struct nft_set_elem elem = {
9197+
.priv = elem_priv,
9198+
};
9199+
9200+
nft_setelem_data_deactivate(gc->net, gc->set, &elem);
9201+
nft_setelem_catchall_destroy(catchall);
9202+
}
9203+
9204+
nft_trans_gc_elem_add(gc, elem_priv);
91899205
}
91909206

91919207
return gc;

0 commit comments

Comments
 (0)