Netfilter fixes for net
Subsystems (17)
Pablo Neira Ayuso
maintainercover Netfilter fixes for net
Hi,
The following patchset contains Netfilter fixes for net:
1) Remove the skb_ext_del from nf_reset, and renames it to a more fitting nf_reset_ct(). Patch from Florian Westphal.
2) Fix deadlock in nft_connlimit between packet path updates and the garbage collector.
You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Thanks.
----------------------------------------------------------------
The following changes since commit 9cfc370240c31c7f31f445e69190dd15be8e5d7d:
Merge tag 'mac80211-for-davem-2019-10-01' of git://git.kernel.org/pub/scm/linux/kernel/git/jberg/mac80211 (2019-10-01 09:28:56 -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 34a4c95abd25ab41fb390b985a08a651b1fa0b0f:
netfilter: nft_connlimit: disable bh on garbage collection (2019-10-01 18:42:15 +0200)
----------------------------------------------------------------
Florian Westphal (1):
netfilter: drop bridge nf reset from nf_reset
Pablo Neira Ayuso (1):
netfilter: nft_connlimit: disable bh on garbage collection
drivers/net/ppp/pptp.c | 4 ++-- drivers/net/tun.c | 2 +- drivers/net/virtio_net.c | 2 +- drivers/net/vrf.c | 8 ++++---- drivers/net/wireless/mac80211_hwsim.c | 4 ++-- drivers/staging/octeon/ethernet-tx.c | 6 ++---- include/linux/skbuff.h | 5 +---- net/batman-adv/soft-interface.c | 2 +- net/core/skbuff.c | 2 +- net/dccp/ipv4.c | 2 +- net/ipv4/ip_input.c | 2 +- net/ipv4/ipmr.c | 4 ++-- net/ipv4/netfilter/nf_dup_ipv4.c | 2 +- net/ipv4/raw.c | 2 +- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/udp.c | 4 ++-- net/ipv6/ip6_input.c | 2 +- net/ipv6/netfilter/nf_dup_ipv6.c | 2 +- net/ipv6/raw.c | 2 +- net/l2tp/l2tp_core.c | 2 +- net/l2tp/l2tp_eth.c | 2 +- net/l2tp/l2tp_ip.c | 2 +- net/l2tp/l2tp_ip6.c | 2 +- net/netfilter/ipvs/ip_vs_xmit.c | 2 +- net/netfilter/nft_connlimit.c | 7 ++++++- net/openvswitch/vport-internal_dev.c | 2 +- net/packet/af_packet.c | 4 ++-- net/sctp/input.c | 2 +- net/xfrm/xfrm_input.c | 2 +- net/xfrm/xfrm_interface.c | 2 +- net/xfrm/xfrm_output.c | 2 +- net/xfrm/xfrm_policy.c | 2 +- 32 files changed, 46 insertions(+), 46 deletions(-)
Pablo Neira Ayuso
maintainerPATCH 1/2 netfilter: drop bridge nf reset from nf_reset
From: Florian Westphal <[email protected]>
commit 174e23810cd31
("sk_buff: drop all skb extensions on free and skb scrubbing") made napi recycle always drop skb extensions. The additional skb_ext_del() that is performed via nf_reset on napi skb recycle is not needed anymore.
Most nf_reset() calls in the stack are there so queued skb won't block 'rmmod nf_conntrack' indefinitely.
This removes the skb_ext_del from nf_reset, and renames it to a more fitting nf_reset_ct().
In a few selected places, add a call to skb_ext_reset to make sure that no active extensions remain.
I am submitting this for "net", because we're still early in the release cycle. The patch applies to net-next too, but I think the rename causes needless divergence between those trees.
--- drivers/net/ppp/pptp.c | 4 ++-- drivers/net/tun.c | 2 +- drivers/net/virtio_net.c | 2 +- drivers/net/vrf.c | 8 ++++---- drivers/net/wireless/mac80211_hwsim.c | 4 ++-- drivers/staging/octeon/ethernet-tx.c | 6 ++---- include/linux/skbuff.h | 5 +---- net/batman-adv/soft-interface.c | 2 +- net/core/skbuff.c | 2 +- net/dccp/ipv4.c | 2 +- net/ipv4/ip_input.c | 2 +- net/ipv4/ipmr.c | 4 ++-- net/ipv4/netfilter/nf_dup_ipv4.c | 2 +- net/ipv4/raw.c | 2 +- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/udp.c | 4 ++-- net/ipv6/ip6_input.c | 2 +- net/ipv6/netfilter/nf_dup_ipv6.c | 2 +- net/ipv6/raw.c | 2 +- net/l2tp/l2tp_core.c | 2 +- net/l2tp/l2tp_eth.c | 2 +- net/l2tp/l2tp_ip.c | 2 +- net/l2tp/l2tp_ip6.c | 2 +- net/netfilter/ipvs/ip_vs_xmit.c | 2 +- net/openvswitch/vport-internal_dev.c | 2 +- net/packet/af_packet.c | 4 ++-- net/sctp/input.c | 2 +- net/xfrm/xfrm_input.c | 2 +- net/xfrm/xfrm_interface.c | 2 +- net/xfrm/xfrm_output.c | 2 +- net/xfrm/xfrm_policy.c | 2 +- 31 files changed, 40 insertions(+), 45 deletions(-)
drivers/net/ppp/pptp.c +2 -2
@@ -238,7 +238,7 @@ static int pptp_xmit(struct ppp_channel *chan, struct sk_buff *skb)skb_dst_drop (skb);skb_dst_set (skb, &rt->dst); -nf_reset (skb); +nf_reset_ct (skb); skb->ip_summed =CHECKSUM_NONE ;ip_select_ident (net, skb,NULL );
@@ -358,7 +358,7 @@ static int pptp_rcv(struct sk_buff *skb) po =lookup_chan (htons (header->call_id), iph->saddr);if (po) {skb_dst_drop (skb); -nf_reset (skb); +nf_reset_ct (skb);return sk_receive_skb (sk_pppox (po), skb,0 ); } drop:
drivers/net/tun.c +1 -1
@@ -1104,7 +1104,7 @@ static netdev_tx_t tun_net_xmit(struct sk_buff *skb, struct net_device *dev)*/ skb_orphan (skb); -nf_reset (skb); +nf_reset_ct (skb);if (ptr_ring_produce (&tfile->tx_ring, skb)) goto drop;
drivers/net/virtio_net.c +1 -1
@@ -1585,7 +1585,7 @@ static netdev_tx_t start_xmit(struct sk_buff *skb, struct net_device *dev)/* Don't wait up for transmitted skbs to be freed. */ if (!use_napi) {skb_orphan (skb); -nf_reset (skb); +nf_reset_ct (skb); }/* If running out of space, stop queue to avoid getting packets that we
drivers/net/vrf.c +4 -4
@@ -366,7 +366,7 @@ static int vrf_finish_output6(struct net *net, struct sock *sk,struct neighbour *neigh;int ret; -nf_reset (skb); +nf_reset_ct (skb); skb->protocol =htons (ETH_P_IPV6 ); skb->dev = dev;
@@ -459,7 +459,7 @@ static struct sk_buff *vrf_ip6_out_direct(struct net_device *vrf_dev,/* reset skb device */ if (likely (err ==1 )) -nf_reset (skb); +nf_reset_ct (skb);else skb =NULL ;
@@ -560,7 +560,7 @@ static int vrf_finish_output(struct net *net, struct sock *sk, struct sk_buff *sbool is_v6gw = false;int ret = -EINVAL ; -nf_reset (skb); +nf_reset_ct (skb);/* Be paranoid, rather than too clever. */ if (unlikely (skb_headroom (skb) < hh_len && dev->header_ops)) {
@@ -670,7 +670,7 @@ static struct sk_buff *vrf_ip_out_direct(struct net_device *vrf_dev,/* reset skb device */ if (likely (err ==1 )) -nf_reset (skb); +nf_reset_ct (skb);else skb =NULL ;
drivers/net/wireless/mac80211_hwsim.c +2 -2
@@ -1261,8 +1261,8 @@ static bool mac80211_hwsim_tx_frame_no_nl(struct ieee80211_hw *hw,skb_orphan (skb);skb_dst_drop (skb); skb->mark =0 ; -secpath_reset (skb); -nf_reset (skb); +skb_ext_reset (skb); +nf_reset_ct (skb);/* * Get absolute mactime here so all HWs RX at the "same time", and
drivers/staging/octeon/ethernet-tx.c +2 -4
@@ -349,10 +349,8 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)*/ dst_release (skb_dst (skb));skb_dst_set (skb,NULL ); -#ifdef CONFIG_XFRM -secpath_reset (skb); -#endif -nf_reset (skb); +skb_ext_reset (skb); +nf_reset_ct (skb);#ifdef CONFIG_NET_SCHED skb->tc_index =0 ;
include/linux/skbuff.h +1 -4
@@ -4160,15 +4160,12 @@ static inline void __skb_ext_copy(struct sk_buff *d, const struct sk_buff *s) {}static inline void skb_ext_copy (struct sk_buff *dst,const struct sk_buff *s) {}#endif /* CONFIG_SKB_EXTENSIONS */ -static inline void nf_reset (struct sk_buff *skb) +static inline void nf_reset_ct (struct sk_buff *skb) {#if defined(CONFIG_NF_CONNTRACK ) || defined(CONFIG_NF_CONNTRACK_MODULE )nf_conntrack_put (skb_nfct (skb)); skb->_nfct =0 ;#endif -#if IS_ENABLED (CONFIG_BRIDGE_NETFILTER ) -skb_ext_del (skb,SKB_EXT_BRIDGE_NF ); -#endif }static inline void nf_reset_trace (struct sk_buff *skb)
net/batman-adv/soft-interface.c +1 -1
@@ -436,7 +436,7 @@ void batadv_interface_rx(struct net_device *soft_iface,/* clean the netfilter state now that the batman-adv header has been * removed */ -nf_reset (skb); +nf_reset_ct (skb);if (unlikely (!pskb_may_pull (skb,ETH_HLEN ))) goto dropped;
net/core/skbuff.c +1 -1
@@ -5120,7 +5120,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet) skb->ignore_df =0 ;skb_dst_drop (skb);skb_ext_reset (skb); -nf_reset (skb); +nf_reset_ct (skb);nf_reset_trace (skb);#ifdef CONFIG_NET_SWITCHDEV
net/dccp/ipv4.c +1 -1
@@ -871,7 +871,7 @@ static int dccp_v4_rcv(struct sk_buff *skb)if (!xfrm4_policy_check (sk,XFRM_POLICY_IN , skb)) goto discard_and_relse; -nf_reset (skb); +nf_reset_ct (skb);return __sk_receive_skb (sk, skb,1 , dh->dccph_doff *4 , refcounted);
net/ipv4/ip_input.c +1 -1
@@ -199,7 +199,7 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol)kfree_skb (skb);return ; } -nf_reset (skb); +nf_reset_ct (skb); } ret =INDIRECT_CALL_2 (ipprot->handler, tcp_v4_rcv, udp_rcv, skb);
net/ipv4/ipmr.c +2 -2
@@ -1794,7 +1794,7 @@ static void ip_encap(struct net *net, struct sk_buff *skb,ip_send_check (iph);memset (&(IPCB (skb)->opt),0 ,sizeof (IPCB (skb)->opt)); -nf_reset (skb); +nf_reset_ct (skb); } static inline int ipmr_forward_finish(struct net *net, struct sock *sk,
@@ -2140,7 +2140,7 @@ int ip_mr_input(struct sk_buff *skb) mroute_sk =rcu_dereference (mrt->mroute_sk);if (mroute_sk) { -nf_reset (skb); +nf_reset_ct (skb);raw_rcv (mroute_sk, skb);return 0 ; }
net/ipv4/netfilter/nf_dup_ipv4.c +1 -1
@@ -65,7 +65,7 @@ void nf_dup_ipv4(struct net *net, struct sk_buff *skb, unsigned int hooknum,#if IS_ENABLED (CONFIG_NF_CONNTRACK )/* Avoid counting cloned packets towards the original connection. */ -nf_reset (skb); +nf_reset_ct (skb);nf_ct_set (skb,NULL ,IP_CT_UNTRACKED );#endif /*
net/ipv4/raw.c +1 -1
@@ -332,7 +332,7 @@ int raw_rcv(struct sock *sk, struct sk_buff *skb)kfree_skb (skb);return NET_RX_DROP ; } -nf_reset (skb); +nf_reset_ct (skb);skb_push (skb, skb->data -skb_network_header (skb));
net/ipv4/tcp_ipv4.c +1 -1
@@ -1916,7 +1916,7 @@ int tcp_v4_rcv(struct sk_buff *skb)if (tcp_v4_inbound_md5_hash (sk, skb)) goto discard_and_relse; -nf_reset (skb); +nf_reset_ct (skb);if (tcp_filter (sk, skb)) goto discard_and_relse;
net/ipv4/udp.c +2 -2
@@ -1969,7 +1969,7 @@ static int udp_queue_rcv_one_skb(struct sock *sk, struct sk_buff *skb)*/ if (!xfrm4_policy_check (sk,XFRM_POLICY_IN , skb)) goto drop; -nf_reset (skb); +nf_reset_ct (skb);if (static_branch_unlikely (&udp_encap_needed_key) && up->encap_type) {int (*encap_rcv)(struct sock *sk,struct sk_buff *skb);
@@ -2298,7 +2298,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,if (!xfrm4_policy_check (NULL ,XFRM_POLICY_IN , skb)) goto drop; -nf_reset (skb); +nf_reset_ct (skb);/* No socket. Drop packet silently, if checksum is wrong */ if (udp_lib_checksum_complete (skb))
net/ipv6/ip6_input.c +1 -1
@@ -371,7 +371,7 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,/* Free reference early: we don't need it any more, and it may hold ip_conntrack module loaded indefinitely. */ -nf_reset (skb); +nf_reset_ct (skb);skb_postpull_rcsum (skb,skb_network_header (skb),skb_network_header_len (skb));
net/ipv6/netfilter/nf_dup_ipv6.c +1 -1
@@ -54,7 +54,7 @@ void nf_dup_ipv6(struct net *net, struct sk_buff *skb, unsigned int hooknum,return ;#if IS_ENABLED (CONFIG_NF_CONNTRACK ) -nf_reset (skb); +nf_reset_ct (skb);nf_ct_set (skb,NULL ,IP_CT_UNTRACKED );#endif if (hooknum == NF_INET_PRE_ROUTING ||
net/ipv6/raw.c +1 -1
@@ -215,7 +215,7 @@ static bool ipv6_raw_deliver(struct sk_buff *skb, int nexthdr)/* Not releasing hash table! */ if (clone) { -nf_reset (clone); +nf_reset_ct (clone);rawv6_rcv (sk, clone); } }
net/l2tp/l2tp_core.c +1 -1
@@ -1078,7 +1078,7 @@ int l2tp_xmit_skb(struct l2tp_session *session, struct sk_buff *skb, int hdr_lenmemset (&(IPCB (skb)->opt),0 ,sizeof (IPCB (skb)->opt));IPCB (skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE |IPSKB_XFRM_TRANSFORMED |IPSKB_REROUTED ); -nf_reset (skb); +nf_reset_ct (skb);bh_lock_sock (sk);if (sock_owned_by_user (sk)) {
net/l2tp/l2tp_eth.c +1 -1
@@ -151,7 +151,7 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb, skb->ip_summed =CHECKSUM_NONE ;skb_dst_drop (skb); -nf_reset (skb); +nf_reset_ct (skb);rcu_read_lock (); dev =rcu_dereference (spriv->dev);
net/l2tp/l2tp_ip.c +1 -1
@@ -193,7 +193,7 @@ static int l2tp_ip_recv(struct sk_buff *skb)if (!xfrm4_policy_check (sk,XFRM_POLICY_IN , skb)) goto discard_put; -nf_reset (skb); +nf_reset_ct (skb);return sk_receive_skb (sk, skb,1 );
net/l2tp/l2tp_ip6.c +1 -1
@@ -206,7 +206,7 @@ static int l2tp_ip6_recv(struct sk_buff *skb)if (!xfrm6_policy_check (sk,XFRM_POLICY_IN , skb)) goto discard_put; -nf_reset (skb); +nf_reset_ct (skb);return sk_receive_skb (sk, skb,1 );
net/netfilter/ipvs/ip_vs_xmit.c +1 -1
@@ -613,7 +613,7 @@ static inline int ip_vs_tunnel_xmit_prepare(struct sk_buff *skb,if (unlikely (cp->flags &IP_VS_CONN_F_NFCT )) ret =ip_vs_confirm_conntrack (skb);if (ret ==NF_ACCEPT ) { -nf_reset (skb); +nf_reset_ct (skb);skb_forward_csum (skb); }return ret;
net/openvswitch/vport-internal_dev.c +1 -1
@@ -237,7 +237,7 @@ static netdev_tx_t internal_dev_recv(struct sk_buff *skb) }skb_dst_drop (skb); -nf_reset (skb); +nf_reset_ct (skb);secpath_reset (skb); skb->pkt_type =PACKET_HOST ;
net/packet/af_packet.c +2 -2
@@ -1821,7 +1821,7 @@ static int packet_rcv_spkt(struct sk_buff *skb, struct net_device *dev,skb_dst_drop (skb);/* drop conntrack reference */ -nf_reset (skb); +nf_reset_ct (skb); spkt = &PACKET_SKB_CB (skb)->sa.pkt;
@@ -2121,7 +2121,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,skb_dst_drop (skb);/* drop conntrack reference */ -nf_reset (skb); +nf_reset_ct (skb);spin_lock (&sk->sk_receive_queue.lock); po->stats.stats1.tp_packets++;
net/sctp/input.c +1 -1
@@ -201,7 +201,7 @@ int sctp_rcv(struct sk_buff *skb)if (!xfrm_policy_check (sk,XFRM_POLICY_IN , skb, family)) goto discard_release; -nf_reset (skb); +nf_reset_ct (skb);if (sk_filter (sk, skb)) goto discard_release;
net/xfrm/xfrm_input.c +1 -1
@@ -706,7 +706,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)if (err) goto drop; -nf_reset (skb); +nf_reset_ct (skb);if (decaps) { sp =skb_sec_path (skb);
net/xfrm/xfrm_interface.c +1 -1
@@ -185,7 +185,7 @@ static void xfrmi_scrub_packet(struct sk_buff *skb, bool xnet) skb->skb_iif =0 ; skb->ignore_df =0 ;skb_dst_drop (skb); -nf_reset (skb); +nf_reset_ct (skb);nf_reset_trace (skb);if (!xnet)
net/xfrm/xfrm_output.c +1 -1
@@ -502,7 +502,7 @@ int xfrm_output_resume(struct sk_buff *skb, int err)struct net *net =xs_net (skb_dst (skb)->xfrm);while (likely ((err =xfrm_output_one (skb, err)) ==0 )) { -nf_reset (skb); +nf_reset_ct (skb); err =skb_dst (skb)->ops->local_out (net, skb->sk, skb);if (unlikely (err !=1 ))
net/xfrm/xfrm_policy.c +1 -1
@@ -2808,7 +2808,7 @@ static void xfrm_policy_queue_process(struct timer_list *t)continue ; } -nf_reset (skb); +nf_reset_ct (skb);skb_dst_drop (skb);skb_dst_set (skb, dst);
Signature · 1 line
2.11.0
Pablo Neira Ayuso
maintainerPATCH 2/2 netfilter: nft_connlimit: disable bh on garbage collection
In reply to Pablo Neira AyusoBH must be disabled when invoking nf_conncount_gc_list() to perform garbage collection, otherwise deadlock might happen.
nf_conncount_add+0x1f/0x50 [nf_conncount] nft_connlimit_eval+0x4c/0xe0 [nft_connlimit] nft_dynset_eval+0xb5/0x100 [nf_tables] nft_do_chain+0xea/0x420 [nf_tables] ? sch_direct_xmit+0x111/0x360 ? noqueue_init+0x10/0x10 ? __qdisc_run+0x84/0x510 ? tcp_packet+0x655/0x1610 [nf_conntrack] ? ip_finish_output2+0x1a7/0x430 ? tcp_error+0x130/0x150 [nf_conntrack] ? nf_conntrack_in+0x1fc/0x4c0 [nf_conntrack] nft_do_chain_ipv4+0x66/0x80 [nf_tables] nf_hook_slow+0x44/0xc0 ip_rcv+0xb5/0xd0 ? ip_rcv_finish_core.isra.19+0x360/0x360 __netif_receive_skb_one_core+0x52/0x70 netif_receive_skb_internal+0x34/0xe0 napi_gro_receive+0xba/0xe0 e1000_clean_rx_irq+0x1e9/0x420 [e1000e] e1000e_poll+0xbe/0x290 [e1000e] net_rx_action+0x149/0x3b0 __do_softirq+0xde/0x2d8 irq_exit+0xba/0xc0 do_IRQ+0x85/0xd0 common_interrupt+0xf/0xf </IRQ> RIP: 0010:nf_conncount_gc_list+0x3b/0x130 [nf_conncount]
--- net/netfilter/nft_connlimit.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
net/netfilter/nft_connlimit.c +6 -1
@@ -218,8 +218,13 @@ static void nft_connlimit_destroy_clone(const struct nft_ctx *ctx,static bool nft_connlimit_gc (struct net *net,const struct nft_expr *expr) {struct nft_connlimit *priv =nft_expr_priv (expr); +bool ret; -return nf_conncount_gc_list (net, &priv->list); +local_bh_disable (); + ret =nf_conncount_gc_list (net, &priv->list); +local_bh_enable (); + +return ret; }static struct nft_expr_type nft_connlimit_type;
Signature · 1 line
2.11.0
David Miller
maintainerFrom: Pablo Neira Ayuso <[email protected]>
Date: Wed, 2 Oct 2019 20:53:43 +0200
Quoted 11 lines
The following patchset contains Netfilter fixes for net:
1) Remove the
skb_ext_delfromnf_reset, and renames it to a more fittingnf_reset_ct(). Patch from Florian Westphal.2) Fix deadlock in
nft_connlimitbetween packet path updates and the garbage collector.You can pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git
Pulled, thanks Pablo.