Return-Path: Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:50380 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942AbbEDXOG (ORCPT ); Mon, 4 May 2015 19:14:06 -0400 Message-ID: <1430781234.4113.208.camel@decadent.org.uk> Subject: Re: [PATCH -stable 3.2.x] ipvs: rerouting to local clients is not needed anymore From: Ben Hutchings To: Pablo Neira Ayuso Cc: stable@vger.kernel.org, Julian Anastasov Date: Tue, 05 May 2015 00:13:54 +0100 In-Reply-To: <1425994033-11438-4-git-send-email-pablo@netfilter.org> References: <1425994033-11438-1-git-send-email-pablo@netfilter.org> <1425994033-11438-4-git-send-email-pablo@netfilter.org> Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="=-cKZ81H/GX3pAfYd+q8rL" Mime-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: --=-cKZ81H/GX3pAfYd+q8rL Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2015-03-10 at 14:27 +0100, Pablo Neira Ayuso wrote: > From: Julian Anastasov >=20 > [ backport from upstream commit 579eb62ac35845686a7c4286c0a820b4eb1f96aa = ] >=20 > commit f5a41847acc5 ("ipvs: move ip_route_me_harder for ICMP") > from 2.6.37 introduced ip_route_me_harder() call for responses to > local clients, so that we can provide valid rt_src after SNAT. > It was used by TCP to provide valid daddr for ip_send_reply(). > After commit 0a5ebb8000c5 ("ipv4: Pass explicit daddr arg to > ip_send_reply()." from 3.0 this rerouting is not needed anymore > and should be avoided, especially in LOCAL_IN. >=20 > Fixes 3.12.33 crash in xfrm reported by Florian Wiessner: > "3.12.33 - BUG xfrm_selector_match+0x25/0x2f6" >=20 > Cc: stable@vger.kernel.org # 3.2.x > Signed-off-by: Julian Anastasov > Acked-by: Simon Horman Queued up for 3.2, thanks. Ben. > --- >=20 > net/netfilter/ipvs/ip_vs_core.c | 32 +++++++++++++++++++++----------- > 1 file changed, 21 insertions(+), 11 deletions(-) >=20 > diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_c= ore.c > index 6dc7d7d..d864aaf 100644 > --- a/net/netfilter/ipvs/ip_vs_core.c > +++ b/net/netfilter/ipvs/ip_vs_core.c > @@ -662,16 +662,24 @@ static inline int ip_vs_gather_frags_v6(struct sk_b= uff *skb, u_int32_t user) > } > #endif > =20 > -static int ip_vs_route_me_harder(int af, struct sk_buff *skb) > +static int ip_vs_route_me_harder(int af, struct sk_buff *skb, > + unsigned int hooknum) > { > + if (!sysctl_snat_reroute(skb)) > + return 0; > + /* Reroute replies only to remote clients (FORWARD and LOCAL_OUT) */ > + if (NF_INET_LOCAL_IN =3D=3D hooknum) > + return 0; > #ifdef CONFIG_IP_VS_IPV6 > if (af =3D=3D AF_INET6) { > - if (sysctl_snat_reroute(skb) && ip6_route_me_harder(skb) !=3D 0) > + struct dst_entry *dst =3D skb_dst(skb); > + > + if (dst->dev && !(dst->dev->flags & IFF_LOOPBACK) && > + ip6_route_me_harder(skb) !=3D 0) > return 1; > } else > #endif > - if ((sysctl_snat_reroute(skb) || > - skb_rtable(skb)->rt_flags & RTCF_LOCAL) && > + if (!(skb_rtable(skb)->rt_flags & RTCF_LOCAL) && > ip_route_me_harder(skb, RTN_LOCAL) !=3D 0) > return 1; > =20 > @@ -782,7 +790,8 @@ static int handle_response_icmp(int af, struct sk_buf= f *skb, > union nf_inet_addr *snet, > __u8 protocol, struct ip_vs_conn *cp, > struct ip_vs_protocol *pp, > - unsigned int offset, unsigned int ihl) > + unsigned int offset, unsigned int ihl, > + unsigned int hooknum) > { > unsigned int verdict =3D NF_DROP; > =20 > @@ -812,7 +821,7 @@ static int handle_response_icmp(int af, struct sk_buf= f *skb, > #endif > ip_vs_nat_icmp(skb, pp, cp, 1); > =20 > - if (ip_vs_route_me_harder(af, skb)) > + if (ip_vs_route_me_harder(af, skb, hooknum)) > goto out; > =20 > /* do the statistics and put it back */ > @@ -908,7 +917,7 @@ static int ip_vs_out_icmp(struct sk_buff *skb, int *r= elated, > =20 > snet.ip =3D iph->saddr; > return handle_response_icmp(AF_INET, skb, &snet, cih->protocol, cp, > - pp, offset, ihl); > + pp, offset, ihl, hooknum); > } > =20 > #ifdef CONFIG_IP_VS_IPV6 > @@ -985,7 +994,8 @@ static int ip_vs_out_icmp_v6(struct sk_buff *skb, int= *related, > =20 > ipv6_addr_copy(&snet.in6, &iph->saddr); > return handle_response_icmp(AF_INET6, skb, &snet, cih->nexthdr, cp, > - pp, offset, sizeof(struct ipv6hdr)); > + pp, offset, sizeof(struct ipv6hdr), > + hooknum); > } > #endif > =20 > @@ -1018,7 +1028,7 @@ static inline int is_tcp_reset(const struct sk_buff= *skb, int nh_len) > */ > static unsigned int > handle_response(int af, struct sk_buff *skb, struct ip_vs_proto_data *pd= , > - struct ip_vs_conn *cp, int ihl) > + struct ip_vs_conn *cp, int ihl, unsigned int hooknum) > { > struct ip_vs_protocol *pp =3D pd->pp; > =20 > @@ -1056,7 +1066,7 @@ handle_response(int af, struct sk_buff *skb, struct= ip_vs_proto_data *pd, > * if it came from this machine itself. So re-compute > * the routing information. > */ > - if (ip_vs_route_me_harder(af, skb)) > + if (ip_vs_route_me_harder(af, skb, hooknum)) > goto drop; > =20 > IP_VS_DBG_PKT(10, af, pp, skb, 0, "After SNAT"); > @@ -1169,7 +1179,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff *skb= , int af) > cp =3D pp->conn_out_get(af, skb, &iph, iph.len, 0); > =20 > if (likely(cp)) > - return handle_response(af, skb, pd, cp, iph.len); > + return handle_response(af, skb, pd, cp, iph.len, hooknum); > if (sysctl_nat_icmp_send(net) && > (pp->protocol =3D=3D IPPROTO_TCP || > pp->protocol =3D=3D IPPROTO_UDP || --=20 Ben Hutchings Once a job is fouled up, anything done to improve it makes it worse. --=-cKZ81H/GX3pAfYd+q8rL Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIVAwUAVUf9N+e/yOyVhhEJAQoJVBAAzkscGeUjkdw0a+e/nc3WpyVEOCFkTsHW f5F2UcdlE5ShFwGZF12dP/mKTdoIHAdk4UdPkYwKN63UUEKAlPlZgm2UeXLdFkwJ DrYVb0bFUHEiFqZ6NGN+ZExSNiYVfsJs2QfJcd0niArJbFI4TbqKplos3805H6Fi WCfjp2C77OpV37l3Qg29+giDgxhfW2r2+J0jSWxwqvkGoeBqZgFZBk/VpJxCBGPF Z5T/JRHWOcg1acrf3mSdOnKy+HaSiBLo5L702q3Dn1g+0cFBvXxC7ekx/0yGiYuN Q4idTfYqIjlBj3DVnmTGjDFzEW4aAmufQREmSR66rfSQUZourNdWB4ZrPfkoouh/ /+06ItZoJdeikTF04Q8z8LwhCE5ELigHUUBkjP7C9qSGP+R4qMzT0In1zcbytr9a am7y05lwELQnNUpEVVlDTqqsvJlVH/23az6YbNRxgRL8PA7kwW9pHCoUMEFtfZWr +miIYHi3Y2Uz4Ae7Ip64L+5xpIgVX57+APankEtBYW9ZOExGWJ7xPhge7HoSvs5C qoAh1S/ImzD5COCnC4bvLEnR6oNNSoOyuhBHmbICUs3Jqo3T0pAzfClVQRVtZMMv jYChVxrY6LTXGg1/yJXfFKdpU/rr7Kk7A5Mn7F8ImDYAtersqSQYRoUuEaHThVi1 wUD11pXXrhU= =Pu7k -----END PGP SIGNATURE----- --=-cKZ81H/GX3pAfYd+q8rL--