Skip to content

Commit 3bfc778

Browse files
committed
Florian Westphal says: ==================== Netfilter fixes for net The following patchset contains Netfilter fixes for *net*: 1) I managed to add a null dereference crash in nft_set_pipapo in the current development cycle, was not caught by CI because the avx2 implementation is fine, but selftest splats when run on non-avx2 host. 2) Fix the ipvs estimater kthread affinity, was incorrect since 6.14. From Frederic Weisbecker. 3) nf_tables should not allow to add a device to a flowtable or netdev chain more than once -- reject this. From Pablo Neira Ayuso. This has been broken for long time, blamed commit dates from v5.8. * tag 'nf-25-08-13' of https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: nf_tables: reject duplicate device on updates ipvs: Fix estimator kthreads preferred affinity netfilter: nft_set_pipapo: fix null deref for empty set ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents d7e8259 + cf5fb87 commit 3bfc778

File tree

5 files changed

+48
-4
lines changed

5 files changed

+48
-4
lines changed

include/net/ip_vs.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,14 @@ static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
11631163
return housekeeping_cpumask(HK_TYPE_KTHREAD);
11641164
}
11651165

1166+
static inline const struct cpumask *sysctl_est_preferred_cpulist(struct netns_ipvs *ipvs)
1167+
{
1168+
if (ipvs->est_cpulist_valid)
1169+
return ipvs->sysctl_est_cpulist;
1170+
else
1171+
return NULL;
1172+
}
1173+
11661174
static inline int sysctl_est_nice(struct netns_ipvs *ipvs)
11671175
{
11681176
return ipvs->sysctl_est_nice;
@@ -1270,6 +1278,11 @@ static inline const struct cpumask *sysctl_est_cpulist(struct netns_ipvs *ipvs)
12701278
return housekeeping_cpumask(HK_TYPE_KTHREAD);
12711279
}
12721280

1281+
static inline const struct cpumask *sysctl_est_preferred_cpulist(struct netns_ipvs *ipvs)
1282+
{
1283+
return NULL;
1284+
}
1285+
12731286
static inline int sysctl_est_nice(struct netns_ipvs *ipvs)
12741287
{
12751288
return IPVS_EST_NICE;

kernel/kthread.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,7 @@ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask)
893893

894894
return ret;
895895
}
896+
EXPORT_SYMBOL_GPL(kthread_affine_preferred);
896897

897898
/*
898899
* Re-affine kthreads according to their preferences

net/netfilter/ipvs/ip_vs_est.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ int ip_vs_est_kthread_start(struct netns_ipvs *ipvs,
265265
}
266266

267267
set_user_nice(kd->task, sysctl_est_nice(ipvs));
268-
set_cpus_allowed_ptr(kd->task, sysctl_est_cpulist(ipvs));
268+
if (sysctl_est_preferred_cpulist(ipvs))
269+
kthread_affine_preferred(kd->task, sysctl_est_preferred_cpulist(ipvs));
269270

270271
pr_info("starting estimator thread %d...\n", kd->id);
271272
wake_up_process(kd->task);

net/netfilter/nf_tables_api.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,6 +2803,7 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
28032803
struct nft_chain *chain = ctx->chain;
28042804
struct nft_chain_hook hook = {};
28052805
struct nft_stats __percpu *stats = NULL;
2806+
struct nftables_pernet *nft_net;
28062807
struct nft_hook *h, *next;
28072808
struct nf_hook_ops *ops;
28082809
struct nft_trans *trans;
@@ -2845,6 +2846,20 @@ static int nf_tables_updchain(struct nft_ctx *ctx, u8 genmask, u8 policy,
28452846
if (nft_hook_list_find(&basechain->hook_list, h)) {
28462847
list_del(&h->list);
28472848
nft_netdev_hook_free(h);
2849+
continue;
2850+
}
2851+
2852+
nft_net = nft_pernet(ctx->net);
2853+
list_for_each_entry(trans, &nft_net->commit_list, list) {
2854+
if (trans->msg_type != NFT_MSG_NEWCHAIN ||
2855+
trans->table != ctx->table ||
2856+
!nft_trans_chain_update(trans))
2857+
continue;
2858+
2859+
if (nft_hook_list_find(&nft_trans_chain_hooks(trans), h)) {
2860+
nft_chain_release_hook(&hook);
2861+
return -EEXIST;
2862+
}
28482863
}
28492864
}
28502865
} else {
@@ -9060,6 +9075,7 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,
90609075
{
90619076
const struct nlattr * const *nla = ctx->nla;
90629077
struct nft_flowtable_hook flowtable_hook;
9078+
struct nftables_pernet *nft_net;
90639079
struct nft_hook *hook, *next;
90649080
struct nf_hook_ops *ops;
90659081
struct nft_trans *trans;
@@ -9076,6 +9092,20 @@ static int nft_flowtable_update(struct nft_ctx *ctx, const struct nlmsghdr *nlh,
90769092
if (nft_hook_list_find(&flowtable->hook_list, hook)) {
90779093
list_del(&hook->list);
90789094
nft_netdev_hook_free(hook);
9095+
continue;
9096+
}
9097+
9098+
nft_net = nft_pernet(ctx->net);
9099+
list_for_each_entry(trans, &nft_net->commit_list, list) {
9100+
if (trans->msg_type != NFT_MSG_NEWFLOWTABLE ||
9101+
trans->table != ctx->table ||
9102+
!nft_trans_flowtable_update(trans))
9103+
continue;
9104+
9105+
if (nft_hook_list_find(&nft_trans_flowtable_hooks(trans), hook)) {
9106+
err = -EEXIST;
9107+
goto err_flowtable_update_hook;
9108+
}
90799109
}
90809110
}
90819111

net/netfilter/nft_set_pipapo.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,9 @@ static struct nft_pipapo_elem *pipapo_get(const struct nft_pipapo_match *m,
426426

427427
local_bh_disable();
428428

429-
if (unlikely(!raw_cpu_ptr(m->scratch)))
430-
goto out;
431-
432429
scratch = *raw_cpu_ptr(m->scratch);
430+
if (unlikely(!scratch))
431+
goto out;
433432

434433
map_index = scratch->map_index;
435434

0 commit comments

Comments
 (0)