Netfilter fixes for net
Subsystems (6)
Pablo Neira Ayuso
maintainercover Netfilter fixes for net
Hi Jakub,
The following patchset contains Netfilter fixes for net:
1) Update debugging in IPVS tcp protocol handler to make it easier to understand, from longguang.yue
2) Update TCP tracker to deal with keepalive packet after re-registration, from Franceso Ruggeri.
3) Missing IP6SKB_FRAGMENTED from netfilter fragment reassembly, from Georg Kohmann.
4) Fix bogus packet drop in ebtables nat extensions, from Thimothee Cocault.
5) Fix typo in flowtable documentation.
6) Reset skb timestamp in nft_fwd_netdev.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks.
----------------------------------------------------------------
The following changes since commit df6afe2f7c19349de2ee560dc62ea4d9ad3ff889:
nexthop: Fix performance regression in nexthop deletion (2020-10-19 20:07:15 -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 c77761c8a59405cb7aa44188b30fffe13fbdd02d:
netfilter: nf_fwd_netdev: clear timestamp in forwarding path (2020-10-22 14:49:36 +0200)
----------------------------------------------------------------
Francesco Ruggeri (1):
netfilter: conntrack: connection timeout after re-register
Georg Kohmann (1):
netfilter: Drop fragmented ndisc packets assembled in netfilter
Jeremy Sowden (1):
docs: nf_flowtable: fix typo.
Pablo Neira Ayuso (1):
netfilter: nf_fwd_netdev: clear timestamp in forwarding path
Saeed Mirzamohammadi (1):
netfilter: nftables_offload: KASAN slab-out-of-bounds Read in nft_flow_rule_create
Timothée COCAULT (1):
netfilter: ebtables: Fixes dropping of small packets in bridge nat
longguang.yue (1):
ipvs: adjust the debug info in function set_tcp_state
Documentation/networking/nf_flowtable.rst | 2 +- include/net/netfilter/nf_tables.h | 6 ++++++ net/bridge/netfilter/ebt_dnat.c | 2 +- net/bridge/netfilter/ebt_redirect.c | 2 +- net/bridge/netfilter/ebt_snat.c | 2 +- net/ipv6/netfilter/nf_conntrack_reasm.c | 1 + net/netfilter/ipvs/ip_vs_proto_tcp.c | 10 ++++++---- net/netfilter/nf_conntrack_proto_tcp.c | 19 +++++++++++++------ net/netfilter/nf_dup_netdev.c | 1 + net/netfilter/nf_tables_api.c | 6 +++--- net/netfilter/nf_tables_offload.c | 4 ++-- net/netfilter/nft_fwd_netdev.c | 1 + 12 files changed, 37 insertions(+), 19 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/7 ipvs: adjust the debug info in function set_tcp_state
From: "longguang.yue" <[email protected]>
Outputting client,virtual,dst addresses info when tcp state changes, which makes the connection debug more clear
--- net/netfilter/ipvs/ip_vs_proto_tcp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/netfilter/ipvs/ip_vs_proto_tcp.c +6 -4
@@ -539,8 +539,8 @@ set_tcp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp,if (new_state != cp->state) {struct ip_vs_dest *dest = cp->dest; - IP_VS_DBG_BUF(8, "%s %s [%c%c%c%c] %s:%d->" - "%s:%d state: %s->%s conn->refcnt:%d\n", + IP_VS_DBG_BUF(8, "%s %s [%c%c%c%c] c:%s:%d v:%s:%d " + "d:%s:%d state: %s->%s conn->refcnt:%d\n", pd->pp->name, ((state_off == TCP_DIR_OUTPUT) ? "output " : "input "),
@@ -548,10 +548,12 @@ set_tcp_state(struct ip_vs_proto_data *pd, struct ip_vs_conn *cp, th->fin ?'F' :'.' , th->ack ?'A' :'.' , th->rst ?'R' :'.' , -IP_VS_DBG_ADDR (cp->daf, &cp->daddr), -ntohs (cp->dport),IP_VS_DBG_ADDR (cp->af, &cp->caddr),ntohs (cp->cport), +IP_VS_DBG_ADDR (cp->af, &cp->vaddr), +ntohs (cp->vport), +IP_VS_DBG_ADDR (cp->daf, &cp->daddr), +ntohs (cp->dport),tcp_state_name (cp->state),tcp_state_name (new_state), refcount_read(&cp->refcnt));
Signature · 1 line
2.20.1
Re: [PATCH 1/7] ipvs: adjust the debug info in function set_tcp_state
This series was applied to netdev/net.git (refs/heads/master):
Hello:
This series was applied to netdev/net.git (refs/heads/master):
Quoted 10 lines · On Thu, 22 Oct 2020 19:29:19 +0200 you wrote:
From: "longguang.yue" <[email protected]>
Outputting client,virtual,dst addresses info when tcp state changes, which makes the connection debug more clear
Signed-off-by longguang.yue <[email protected]>Acked-by Julian Anastasov <[email protected]>Signed-off-by Pablo Neira Ayuso <[email protected]>[...]
Here is the summary with links:
- [1/7] ipvs: adjust the debug info in function set_tcp_state
https://git.kernel.org/netdev/net/c/79dce09ab027 - [2/7] netfilter: conntrack: connection timeout after re-register https://git.kernel.org/netdev/net/c/4f25434bccc2 - [3/7] netfilter: Drop fragmented ndisc packets assembled in netfilter https://git.kernel.org/netdev/net/c/68f9f9c2c3b6 - [4/7] netfilter: ebtables: Fixes dropping of small packets in bridge nat https://git.kernel.org/netdev/net/c/63137bc5882a - [5/7] docs: nf_flowtable: fix typo. https://git.kernel.org/netdev/net/c/64747d5ed199 - [6/7] netfilter: nftables_offload: KASAN slab-out-of-bounds Read in nft_flow_rule_create https://git.kernel.org/netdev/net/c/31cc578ae2de - [7/7] netfilter: nf_fwd_netdev: clear timestamp in forwarding path https://git.kernel.org/netdev/net/c/c77761c8a594
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Pablo Neira Ayuso
maintainerPATCH 2/7 netfilter: conntrack: connection timeout after re-register
In reply to Pablo Neira AyusoFrom: Francesco Ruggeri <[email protected]>
If the first packet conntrack sees after a re-register is an outgoing keepalive packet with no data (SEG.SEQ = SND.NXT-1), td_end is set to SND.NXT-1.
When the peer correctly acknowledges SND.NXT, tcp_in_window fails check III (Upper bound for valid (s)ack: sack <= receiver.td_end) and returns false, which cascades into nf_conntrack_in setting skb->_nfct = 0 and in later conntrack iptables rules not matching. In cases where iptables are dropping packets that do not match conntrack rules this can result in idle tcp connections to time out.
v2: adjust td_end when getting the reply rather than when sending out
the keepalive packet.
--- net/netfilter/nf_conntrack_proto_tcp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
net/netfilter/nf_conntrack_proto_tcp.c +13 -6
@@ -541,13 +541,20 @@ static bool tcp_in_window(const struct nf_conn *ct, swin = win << sender->td_scale; sender->td_maxwin = (swin ==0 ?1 : swin); sender->td_maxend = end + sender->td_maxwin; -/* -* We haven't seen traffic in the other direction yet -* but we have to tweak window tracking to pass III -* and IV until that happens. -*/ -if (receiver->td_maxwin ==0 ) +if (receiver->td_maxwin ==0 ) { +/* We haven't seen traffic in the other +* direction yet but we have to tweak window +* tracking to pass III and IV until that +* happens. +*/ receiver->td_end = receiver->td_maxend = sack; + }else if (sack == receiver->td_end +1 ) { +/* Likely a reply to a keepalive. +* Needed for III. +*/ + receiver->td_end++; + } + } } else if (((state->state == TCP_CONNTRACK_SYN_SENT && dir == IP_CT_DIR_ORIGINAL)
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 3/7 netfilter: Drop fragmented ndisc packets assembled in netfilter
In reply to Pablo Neira AyusoFrom: Georg Kohmann <[email protected]>
Fragmented ndisc packets assembled in netfilter not dropped as specified in RFC 6980, section 5. This behaviour breaks TAHI IPv6 Core Conformance Tests v6LC.2.1.22/23, V6LC.2.2.26/27 and V6LC.2.3.18.
Setting IP6SKB_FRAGMENTED flag during reassembly.
References: commit b800c3b966bc ("ipv6: drop fragmented ndisc packets by default (RFC 6980)")
--- net/ipv6/netfilter/nf_conntrack_reasm.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/netfilter/nf_conntrack_reasm.c +1 -0
@@ -355,6 +355,7 @@ static int nf_ct_frag6_reasm(struct frag_queue *fq, struct sk_buff *skb,ipv6_hdr (skb)->payload_len =htons (payload_len);ipv6_change_dsfield (ipv6_hdr (skb),0xff , ecn);IP6CB (skb)->frag_max_size =sizeof (struct ipv6hdr ) + fq->q.max_size; +IP6CB (skb)->flags |=IP6SKB_FRAGMENTED ;/* Yes, and fold redundant checksum back. 8) */ if (skb->ip_summed ==CHECKSUM_COMPLETE )
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 4/7 netfilter: ebtables: Fixes dropping of small packets in bridge nat
In reply to Pablo Neira AyusoFrom: Timothée COCAULT <[email protected]>
Fixes an error causing small packets to get dropped. skb_ensure_writable expects the second parameter to be a length in the ethernet payload.=20 If we want to write the ethernet header (src, dst), we should pass 0. Otherwise, packets with small payloads (< ETH_ALEN) will get dropped.
--- net/bridge/netfilter/ebt_dnat.c | 2 +- net/bridge/netfilter/ebt_redirect.c | 2 +- net/bridge/netfilter/ebt_snat.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
net/bridge/netfilter/ebt_dnat.c +1 -1
@@ -21,7 +21,7 @@ ebt_dnat_tg(struct sk_buff *skb, const struct xt_action_param *par) {const struct ebt_nat_info *info = par->targinfo; -if (skb_ensure_writable (skb,ETH_ALEN )) +if (skb_ensure_writable (skb,0 ))return EBT_DROP ;ether_addr_copy (eth_hdr (skb)->h_dest, info->mac);
net/bridge/netfilter/ebt_redirect.c +1 -1
@@ -21,7 +21,7 @@ ebt_redirect_tg(struct sk_buff *skb, const struct xt_action_param *par) {const struct ebt_redirect_info *info = par->targinfo; -if (skb_ensure_writable (skb,ETH_ALEN )) +if (skb_ensure_writable (skb,0 ))return EBT_DROP ;if (xt_hooknum (par) !=NF_BR_BROUTING )
net/bridge/netfilter/ebt_snat.c +1 -1
@@ -22,7 +22,7 @@ ebt_snat_tg(struct sk_buff *skb, const struct xt_action_param *par) {const struct ebt_nat_info *info = par->targinfo; -if (skb_ensure_writable (skb,ETH_ALEN *2 )) +if (skb_ensure_writable (skb,0 ))return EBT_DROP ;ether_addr_copy (eth_hdr (skb)->h_source, info->mac);
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 5/7 docs: nf_flowtable: fix typo.
In reply to Pablo Neira AyusoFrom: Jeremy Sowden <[email protected]>
"mailined" should be "mainlined."
--- Documentation/networking/nf_flowtable.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/networking/nf_flowtable.rst +1 -1
@@ -109,7 +109,7 @@ More reading This documentation is based on the LWN.net articles [1]_\ [2]_. Rafal Milecki also made a very complete and comprehensive summary called "A state of network acceleration" that describes how things were before this infrastructure was -mailined [3]_ and it also makes a rough summary of this work [4]_. +mainlined [3]_ and it also makes a rough summary of this work [4]_. .. [1] https://lwn.net/Articles/738214/ .. [2] https://lwn.net/Articles/742164/
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 6/7 netfilter: nftables_offload: KASAN slab-out-of-bounds Read in nft_flow_rule_create
In reply to Pablo Neira AyusoFrom: Saeed Mirzamohammadi <[email protected]>
This patch fixes the issue due to:
BUG: KASAN: slab-out-of-bounds in nft_flow_rule_create+0x622/0x6a2 net/netfilter/nf_tables_offload.c:40 Read of size 8 at addr ffff888103910b58 by task syz-executor227/16244
The error happens when expr->ops is accessed early on before performing the boundary check and after nft_expr_next() moves the expr to go out-of-bounds.
This patch checks the boundary condition before expr->ops that fixes the slab-out-of-bounds Read issue.
Add nft_expr_more() and use it to fix this problem.
--- include/net/netfilter/nf_tables.h | 6 ++++++ net/netfilter/nf_tables_api.c | 6 +++--- net/netfilter/nf_tables_offload.c | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-)
include/net/netfilter/nf_tables.h +6 -0
@@ -891,6 +891,12 @@ static inline struct nft_expr *nft_expr_last(const struct nft_rule *rule)return (struct nft_expr *)&rule->data[rule->dlen]; } +static inline bool nft_expr_more (const struct nft_rule *rule, +const struct nft_expr *expr) +{ +return expr !=nft_expr_last (rule) && expr->ops; +} +static inline struct nft_userdata *nft_userdata (const struct nft_rule *rule) {return (void *)&rule->data[rule->dlen];
net/netfilter/nf_tables_api.c +3 -3
@@ -302,7 +302,7 @@ static void nft_rule_expr_activate(const struct nft_ctx *ctx,struct nft_expr *expr; expr =nft_expr_first (rule); -while (expr !=nft_expr_last (rule) && expr->ops) { +while (nft_expr_more (rule, expr)) {if (expr->ops->activate) expr->ops->activate (ctx, expr);
@@ -317,7 +317,7 @@ static void nft_rule_expr_deactivate(const struct nft_ctx *ctx,struct nft_expr *expr; expr =nft_expr_first (rule); -while (expr !=nft_expr_last (rule) && expr->ops) { +while (nft_expr_more (rule, expr)) {if (expr->ops->deactivate) expr->ops->deactivate (ctx, expr, phase);
@@ -3080,7 +3080,7 @@ static void nf_tables_rule_destroy(const struct nft_ctx *ctx,* is called on error from nf_tables_newrule(). */ expr =nft_expr_first (rule); -while (expr !=nft_expr_last (rule) && expr->ops) { +while (nft_expr_more (rule, expr)) { next =nft_expr_next (expr);nf_tables_expr_destroy (ctx, expr); expr = next;
net/netfilter/nf_tables_offload.c +2 -2
@@ -37,7 +37,7 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net,struct nft_expr *expr; expr =nft_expr_first (rule); -while (expr->ops && expr !=nft_expr_last (rule)) { +while (nft_expr_more (rule, expr)) {if (expr->ops->offload_flags &NFT_OFFLOAD_F_ACTION ) num_actions++;
@@ -61,7 +61,7 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net, ctx->net = net; ctx->dep.type =NFT_OFFLOAD_DEP_UNSPEC ; -while (expr->ops && expr !=nft_expr_last (rule)) { +while (nft_expr_more (rule, expr)) {if (!expr->ops->offload) { err = -EOPNOTSUPP ; goto err_out;
Signature · 1 line
2.20.1
Pablo Neira Ayuso
maintainerPATCH 7/7 netfilter: nf_fwd_netdev: clear timestamp in forwarding path
In reply to Pablo Neira AyusoSimilar to 7980d2eabde8 ("ipvs: clear skb->tstamp in forwarding path"). fq qdisc requires tstamp to be cleared in forwarding path.
--- net/netfilter/nf_dup_netdev.c | 1 + net/netfilter/nft_fwd_netdev.c | 1 + 2 files changed, 2 insertions(+)
net/netfilter/nf_dup_netdev.c +1 -0
@@ -19,6 +19,7 @@ static void nf_do_netdev_egress(struct sk_buff *skb, struct net_device *dev)skb_push (skb, skb->mac_len); skb->dev = dev; + skb->tstamp =0 ;dev_queue_xmit (skb); }
net/netfilter/nft_fwd_netdev.c +1 -0
@@ -138,6 +138,7 @@ static void nft_fwd_neigh_eval(const struct nft_expr *expr,return ; skb->dev = dev; + skb->tstamp =0 ;neigh_xmit (neigh_table, dev, addr, skb); out: regs->verdict.code = verdict;
Signature · 1 line
2.20.1
Jakub Kicinski
maintainerQuoted 13 lines · On Thu, 22 Oct 2020 19:29:18 +0200 Pablo Neira Ayuso wrote:
Hi Jakub,
The following patchset contains Netfilter fixes for net:
1) Update debugging in IPVS tcp protocol handler to make it easier to understand, from longguang.yue
2) Update TCP tracker to deal with keepalive packet after re-registration, from Franceso Ruggeri.
3) Missing
IP6SKB_FRAGMENTEDfrom netfilter fragment reassembly, from Georg Kohmann.
Quoted 6 lines
4) Fix bogus packet drop in ebtables nat extensions, from Thimothee Cocault.
5) Fix typo in flowtable documentation.
6) Reset skb timestamp in
nft_fwd_netdev.
Pulled, please remember about that [PATCH net] tag if you can, thanks!