Netfilter fixes for net
Subsystems (3)
Pablo Neira Ayuso
maintainercover Netfilter fixes for net
Hi,
The following patchset contains Netfilter fixes for net:
1) Refetch IP header pointer after pskb_may_pull() in flowtable, from Haishuang Yan.
2) Fix memleak in flowtable offload in nf_flow_table_free(), from Paul Blakey.
3) Set control.addr_type mask in flowtable offload, from Edward Cree.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thank you.
----------------------------------------------------------------
The following changes since commit 3c025b6317272ee8493ee20fa5035c087626af48:
Merge branch 'wireguard-fixes' (2020-03-18 18:51:43 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git HEAD
for you to fetch changes up to 15ff197237e76c4dab06b7b518afaa4ebb1c43e0:
netfilter: flowtable: populate addr_type mask (2020-03-19 21:20:04 +0100)
----------------------------------------------------------------
Edward Cree (1):
netfilter: flowtable: populate addr_type mask
Haishuang Yan (2):
netfilter: flowtable: reload ip{v6}h in nf_flow_nat_ip{v6}
netfilter: flowtable: reload ip{v6}h in nf_flow_tuple_ip{v6}Paul Blakey (1):
netfilter: flowtable: Fix flushing of offloaded flows on free
net/netfilter/nf_flow_table_core.c | 3 +++ net/netfilter/nf_flow_table_ip.c | 14 ++++++++++---- net/netfilter/nf_flow_table_offload.c | 1 + 3 files changed, 14 insertions(+), 4 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/4 netfilter: flowtable: reload ip{v6}h in nf_flow_nat_ip{v6}
From: Haishuang Yan <[email protected]>
Since nf_flow_snat_port and nf_flow_snat_ip{v6} call pskb_may_pull() which may change skb->data, so we need to reload ip{v6}h at the right place.
--- net/netfilter/nf_flow_table_ip.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
net/netfilter/nf_flow_table_ip.c +8 -4
@@ -146,11 +146,13 @@ static int nf_flow_nat_ip(const struct flow_offload *flow, struct sk_buff *skb,if (test_bit (NF_FLOW_SNAT , &flow->flags) && (nf_flow_snat_port (flow, skb, thoff, iph->protocol, dir) <0 || -nf_flow_snat_ip (flow, skb, iph, thoff, dir) <0 )) +nf_flow_snat_ip (flow, skb,ip_hdr (skb), thoff, dir) <0 ))return -1 ; + + iph =ip_hdr (skb);if (test_bit (NF_FLOW_DNAT , &flow->flags) && (nf_flow_dnat_port (flow, skb, thoff, iph->protocol, dir) <0 || -nf_flow_dnat_ip (flow, skb, iph, thoff, dir) <0 )) +nf_flow_dnat_ip (flow, skb,ip_hdr (skb), thoff, dir) <0 ))return -1 ;return 0 ;
@@ -426,11 +428,13 @@ static int nf_flow_nat_ipv6(const struct flow_offload *flow,if (test_bit (NF_FLOW_SNAT , &flow->flags) && (nf_flow_snat_port (flow, skb, thoff, ip6h->nexthdr, dir) <0 || -nf_flow_snat_ipv6 (flow, skb, ip6h, thoff, dir) <0 )) +nf_flow_snat_ipv6 (flow, skb,ipv6_hdr (skb), thoff, dir) <0 ))return -1 ; + + ip6h =ipv6_hdr (skb);if (test_bit (NF_FLOW_DNAT , &flow->flags) && (nf_flow_dnat_port (flow, skb, thoff, ip6h->nexthdr, dir) <0 || -nf_flow_dnat_ipv6 (flow, skb, ip6h, thoff, dir) <0 )) +nf_flow_dnat_ipv6 (flow, skb,ipv6_hdr (skb), thoff, dir) <0 ))return -1 ;return 0 ;
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 2/4 netfilter: flowtable: reload ip{v6}h in nf_flow_tuple_ip{v6}
In reply to Pablo Neira AyusoFrom: Haishuang Yan <[email protected]>
Since pskb_may_pull may change skb->data, so we need to reload ip{v6}h at the right place.
--- net/netfilter/nf_flow_table_ip.c | 2 ++ 1 file changed, 2 insertions(+)
net/netfilter/nf_flow_table_ip.c +2 -0
@@ -191,6 +191,7 @@ static int nf_flow_tuple_ip(struct sk_buff *skb, const struct net_device *dev,if (!pskb_may_pull (skb, thoff +sizeof (*ports)))return -1 ; + iph =ip_hdr (skb); ports = (struct flow_ports *)(skb_network_header (skb) + thoff); tuple->src_v4.s_addr = iph->saddr;
@@ -463,6 +464,7 @@ static int nf_flow_tuple_ipv6(struct sk_buff *skb, const struct net_device *dev,if (!pskb_may_pull (skb, thoff +sizeof (*ports)))return -1 ; + ip6h =ipv6_hdr (skb); ports = (struct flow_ports *)(skb_network_header (skb) + thoff); tuple->src_v6 = ip6h->saddr;
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 3/4 netfilter: flowtable: Fix flushing of offloaded flows on free
In reply to Pablo Neira AyusoFrom: Paul Blakey <[email protected]>
Freeing a flowtable with offloaded flows, the flow are deleted from hardware but are not deleted from the flow table, leaking them, and leaving their offload bit on.
Add a second pass of the disabled gc to delete the these flows from the flow table before freeing it.
--- net/netfilter/nf_flow_table_core.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/nf_flow_table_core.c +3 -0
@@ -554,6 +554,9 @@ void nf_flow_table_free(struct nf_flowtable *flow_table)nf_flow_table_iterate (flow_table, nf_flow_table_do_cleanup,NULL );nf_flow_table_iterate (flow_table, nf_flow_offload_gc_step, flow_table);nf_flow_table_offload_flush (flow_table); +if (nf_flowtable_hw_offload (flow_table)) +nf_flow_table_iterate (flow_table, nf_flow_offload_gc_step, + flow_table);rhashtable_destroy (&flow_table->rhashtable); }EXPORT_SYMBOL_GPL (nf_flow_table_free);
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 4/4 netfilter: flowtable: populate addr_type mask
In reply to Pablo Neira AyusoFrom: Edward Cree <[email protected]>
nf_flow_rule_match() sets control.addr_type in key, so needs to also set
the corresponding mask. An exact match is wanted, so mask is all ones.
--- net/netfilter/nf_flow_table_offload.c | 1 + 1 file changed, 1 insertion(+)
net/netfilter/nf_flow_table_offload.c +1 -0
@@ -87,6 +87,7 @@ static int nf_flow_rule_match(struct nf_flow_match *match,default :return -EOPNOTSUPP ; } + mask->control.addr_type =0xffff ; match->dissector.used_keys |=BIT (key->control.addr_type); mask->basic.n_proto =0xffff ;
Signature · 1 line
2.11.0
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Fri, 20 Mar 2020 14:51:30 +0100
Quoted 9 lines
The following patchset contains Netfilter fixes for net:
1) Refetch IP header pointer after
pskb_may_pull()in flowtable, from Haishuang Yan.2) Fix memleak in flowtable offload in
nf_flow_table_free(), from Paul Blakey.3) Set control.addr_type mask in flowtable offload, from Edward Cree.
Pulled, thanks Pablo.