Skip to content

Commit d68d7d2

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net 1) Check for interval validity in all concatenation fields in nft_set_pipapo, from Stefano Brivio. 2) Missing preemption disabled in conntrack and flowtable stat updates, from Xin Long. 3) Fix compilation warning when CONFIG_NF_CONNTRACK_MARK=n. Except for 3) which was a bug introduced in a recent fix in 6.1-rc - anything else, broken for several releases. * git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: ctnetlink: fix compilation warning after data race fixes in ct mark netfilter: conntrack: fix using __this_cpu_add in preemptible netfilter: flowtable_offload: fix using __this_cpu_add in preemptible netfilter: nft_set_pipapo: Actually validate intervals in fields after the first one ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 6c681f8 + 1feeae0 commit d68d7d2

File tree

4 files changed

+19
-17
lines changed

4 files changed

+19
-17
lines changed

net/netfilter/nf_conntrack_core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -891,7 +891,7 @@ nf_conntrack_hash_check_insert(struct nf_conn *ct)
891891
zone = nf_ct_zone(ct);
892892

893893
if (!nf_ct_ext_valid_pre(ct->ext)) {
894-
NF_CT_STAT_INC(net, insert_failed);
894+
NF_CT_STAT_INC_ATOMIC(net, insert_failed);
895895
return -ETIMEDOUT;
896896
}
897897

@@ -938,7 +938,7 @@ nf_conntrack_hash_check_insert(struct nf_conn *ct)
938938

939939
if (!nf_ct_ext_valid_post(ct->ext)) {
940940
nf_ct_kill(ct);
941-
NF_CT_STAT_INC(net, drop);
941+
NF_CT_STAT_INC_ATOMIC(net, drop);
942942
return -ETIMEDOUT;
943943
}
944944

@@ -1275,7 +1275,7 @@ __nf_conntrack_confirm(struct sk_buff *skb)
12751275
*/
12761276
if (!nf_ct_ext_valid_post(ct->ext)) {
12771277
nf_ct_kill(ct);
1278-
NF_CT_STAT_INC(net, drop);
1278+
NF_CT_STAT_INC_ATOMIC(net, drop);
12791279
return NF_DROP;
12801280
}
12811281

net/netfilter/nf_conntrack_netlink.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,13 @@ ctnetlink_dump_timestamp(struct sk_buff *skb, const struct nf_conn *ct)
328328
}
329329

330330
#ifdef CONFIG_NF_CONNTRACK_MARK
331-
static int ctnetlink_dump_mark(struct sk_buff *skb, u32 mark)
331+
static int ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct)
332332
{
333+
u32 mark = READ_ONCE(ct->mark);
334+
335+
if (!mark)
336+
return 0;
337+
333338
if (nla_put_be32(skb, CTA_MARK, htonl(mark)))
334339
goto nla_put_failure;
335340
return 0;
@@ -543,7 +548,7 @@ static int ctnetlink_dump_extinfo(struct sk_buff *skb,
543548
static int ctnetlink_dump_info(struct sk_buff *skb, struct nf_conn *ct)
544549
{
545550
if (ctnetlink_dump_status(skb, ct) < 0 ||
546-
ctnetlink_dump_mark(skb, READ_ONCE(ct->mark)) < 0 ||
551+
ctnetlink_dump_mark(skb, ct) < 0 ||
547552
ctnetlink_dump_secctx(skb, ct) < 0 ||
548553
ctnetlink_dump_id(skb, ct) < 0 ||
549554
ctnetlink_dump_use(skb, ct) < 0 ||
@@ -722,7 +727,6 @@ ctnetlink_conntrack_event(unsigned int events, const struct nf_ct_event *item)
722727
struct sk_buff *skb;
723728
unsigned int type;
724729
unsigned int flags = 0, group;
725-
u32 mark;
726730
int err;
727731

728732
if (events & (1 << IPCT_DESTROY)) {
@@ -827,9 +831,8 @@ ctnetlink_conntrack_event(unsigned int events, const struct nf_ct_event *item)
827831
}
828832

829833
#ifdef CONFIG_NF_CONNTRACK_MARK
830-
mark = READ_ONCE(ct->mark);
831-
if ((events & (1 << IPCT_MARK) || mark) &&
832-
ctnetlink_dump_mark(skb, mark) < 0)
834+
if (events & (1 << IPCT_MARK) &&
835+
ctnetlink_dump_mark(skb, ct) < 0)
833836
goto nla_put_failure;
834837
#endif
835838
nlmsg_end(skb, nlh);
@@ -2671,7 +2674,6 @@ static int __ctnetlink_glue_build(struct sk_buff *skb, struct nf_conn *ct)
26712674
{
26722675
const struct nf_conntrack_zone *zone;
26732676
struct nlattr *nest_parms;
2674-
u32 mark;
26752677

26762678
zone = nf_ct_zone(ct);
26772679

@@ -2733,8 +2735,7 @@ static int __ctnetlink_glue_build(struct sk_buff *skb, struct nf_conn *ct)
27332735
goto nla_put_failure;
27342736

27352737
#ifdef CONFIG_NF_CONNTRACK_MARK
2736-
mark = READ_ONCE(ct->mark);
2737-
if (mark && ctnetlink_dump_mark(skb, mark) < 0)
2738+
if (ctnetlink_dump_mark(skb, ct) < 0)
27382739
goto nla_put_failure;
27392740
#endif
27402741
if (ctnetlink_dump_labels(skb, ct) < 0)

net/netfilter/nf_flow_table_offload.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,13 +997,13 @@ static void flow_offload_queue_work(struct flow_offload_work *offload)
997997
struct net *net = read_pnet(&offload->flowtable->net);
998998

999999
if (offload->cmd == FLOW_CLS_REPLACE) {
1000-
NF_FLOW_TABLE_STAT_INC(net, count_wq_add);
1000+
NF_FLOW_TABLE_STAT_INC_ATOMIC(net, count_wq_add);
10011001
queue_work(nf_flow_offload_add_wq, &offload->work);
10021002
} else if (offload->cmd == FLOW_CLS_DESTROY) {
1003-
NF_FLOW_TABLE_STAT_INC(net, count_wq_del);
1003+
NF_FLOW_TABLE_STAT_INC_ATOMIC(net, count_wq_del);
10041004
queue_work(nf_flow_offload_del_wq, &offload->work);
10051005
} else {
1006-
NF_FLOW_TABLE_STAT_INC(net, count_wq_stats);
1006+
NF_FLOW_TABLE_STAT_INC_ATOMIC(net, count_wq_stats);
10071007
queue_work(nf_flow_offload_stats_wq, &offload->work);
10081008
}
10091009
}

net/netfilter/nft_set_pipapo.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,7 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
11621162
struct nft_pipapo_match *m = priv->clone;
11631163
u8 genmask = nft_genmask_next(net);
11641164
struct nft_pipapo_field *f;
1165+
const u8 *start_p, *end_p;
11651166
int i, bsize_max, err = 0;
11661167

11671168
if (nft_set_ext_exists(ext, NFT_SET_EXT_KEY_END))
@@ -1202,9 +1203,9 @@ static int nft_pipapo_insert(const struct net *net, const struct nft_set *set,
12021203
}
12031204

12041205
/* Validate */
1206+
start_p = start;
1207+
end_p = end;
12051208
nft_pipapo_for_each_field(f, i, m) {
1206-
const u8 *start_p = start, *end_p = end;
1207-
12081209
if (f->rules >= (unsigned long)NFT_PIPAPO_RULE0_MAX)
12091210
return -ENOSPC;
12101211

0 commit comments

Comments
 (0)