Skip to content

Commit 775c73d

Browse files
author
Paolo Abeni
committed
Merge branch 'main' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net The following patchset contains Netfilter fixes for net: 1) Restore ctnetlink zero mark in events and dump, from Ivan Delalande. 2) Fix deadlock due to missing disabled bh in tproxy, from Florian Westphal. 3) Safer maximum chain load in conntrack, from Eric Dumazet. * 'main' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: conntrack: adopt safer max chain length netfilter: tproxy: fix deadlock due to missing BH disable netfilter: ctnetlink: revert to dumping mark regardless of event type ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 757b56a + c77737b commit 775c73d

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

include/net/netfilter/nf_tproxy.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ static inline bool nf_tproxy_sk_is_transparent(struct sock *sk)
1717
return false;
1818
}
1919

20+
static inline void nf_tproxy_twsk_deschedule_put(struct inet_timewait_sock *tw)
21+
{
22+
local_bh_disable();
23+
inet_twsk_deschedule_put(tw);
24+
local_bh_enable();
25+
}
26+
2027
/* assign a socket to the skb -- consumes sk */
2128
static inline void nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk)
2229
{

net/ipv4/netfilter/nf_tproxy_ipv4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ nf_tproxy_handle_time_wait4(struct net *net, struct sk_buff *skb,
3838
hp->source, lport ? lport : hp->dest,
3939
skb->dev, NF_TPROXY_LOOKUP_LISTENER);
4040
if (sk2) {
41-
inet_twsk_deschedule_put(inet_twsk(sk));
41+
nf_tproxy_twsk_deschedule_put(inet_twsk(sk));
4242
sk = sk2;
4343
}
4444
}

net/ipv6/netfilter/nf_tproxy_ipv6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ nf_tproxy_handle_time_wait6(struct sk_buff *skb, int tproto, int thoff,
6363
lport ? lport : hp->dest,
6464
skb->dev, NF_TPROXY_LOOKUP_LISTENER);
6565
if (sk2) {
66-
inet_twsk_deschedule_put(inet_twsk(sk));
66+
nf_tproxy_twsk_deschedule_put(inet_twsk(sk));
6767
sk = sk2;
6868
}
6969
}

net/netfilter/nf_conntrack_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ static DEFINE_MUTEX(nf_conntrack_mutex);
9696
#define GC_SCAN_MAX_DURATION msecs_to_jiffies(10)
9797
#define GC_SCAN_EXPIRED_MAX (64000u / HZ)
9898

99-
#define MIN_CHAINLEN 8u
100-
#define MAX_CHAINLEN (32u - MIN_CHAINLEN)
99+
#define MIN_CHAINLEN 50u
100+
#define MAX_CHAINLEN (80u - MIN_CHAINLEN)
101101

102102
static struct conntrack_gc_work conntrack_gc_work;
103103

net/netfilter/nf_conntrack_netlink.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,12 @@ 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, const struct nf_conn *ct)
331+
static int ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct,
332+
bool dump)
332333
{
333334
u32 mark = READ_ONCE(ct->mark);
334335

335-
if (!mark)
336+
if (!mark && !dump)
336337
return 0;
337338

338339
if (nla_put_be32(skb, CTA_MARK, htonl(mark)))
@@ -343,7 +344,7 @@ static int ctnetlink_dump_mark(struct sk_buff *skb, const struct nf_conn *ct)
343344
return -1;
344345
}
345346
#else
346-
#define ctnetlink_dump_mark(a, b) (0)
347+
#define ctnetlink_dump_mark(a, b, c) (0)
347348
#endif
348349

349350
#ifdef CONFIG_NF_CONNTRACK_SECMARK
@@ -548,7 +549,7 @@ static int ctnetlink_dump_extinfo(struct sk_buff *skb,
548549
static int ctnetlink_dump_info(struct sk_buff *skb, struct nf_conn *ct)
549550
{
550551
if (ctnetlink_dump_status(skb, ct) < 0 ||
551-
ctnetlink_dump_mark(skb, ct) < 0 ||
552+
ctnetlink_dump_mark(skb, ct, true) < 0 ||
552553
ctnetlink_dump_secctx(skb, ct) < 0 ||
553554
ctnetlink_dump_id(skb, ct) < 0 ||
554555
ctnetlink_dump_use(skb, ct) < 0 ||
@@ -831,8 +832,7 @@ ctnetlink_conntrack_event(unsigned int events, const struct nf_ct_event *item)
831832
}
832833

833834
#ifdef CONFIG_NF_CONNTRACK_MARK
834-
if (events & (1 << IPCT_MARK) &&
835-
ctnetlink_dump_mark(skb, ct) < 0)
835+
if (ctnetlink_dump_mark(skb, ct, events & (1 << IPCT_MARK)))
836836
goto nla_put_failure;
837837
#endif
838838
nlmsg_end(skb, nlh);
@@ -2735,7 +2735,7 @@ static int __ctnetlink_glue_build(struct sk_buff *skb, struct nf_conn *ct)
27352735
goto nla_put_failure;
27362736

27372737
#ifdef CONFIG_NF_CONNTRACK_MARK
2738-
if (ctnetlink_dump_mark(skb, ct) < 0)
2738+
if (ctnetlink_dump_mark(skb, ct, true) < 0)
27392739
goto nla_put_failure;
27402740
#endif
27412741
if (ctnetlink_dump_labels(skb, ct) < 0)

0 commit comments

Comments
 (0)