stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Konstantinos Kolelis <k.kolelis@sirrix.com>,
	Steffen Klassert <steffen.klassert@secunet.com>
Subject: [PATCH 3.14 23/37] xfrm: Generate queueing routes only from route lookup functions
Date: Mon, 13 Oct 2014 04:24:20 +0200	[thread overview]
Message-ID: <20141013022401.256638435@linuxfoundation.org> (raw)
In-Reply-To: <20141013022400.286360067@linuxfoundation.org>

3.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Steffen Klassert <steffen.klassert@secunet.com>

[ Upstream commit b8c203b2d2fc961bafd53b41d5396bbcdec55998 ]

Currently we genarate a queueing route if we have matching policies
but can not resolve the states and the sysctl xfrm_larval_drop is
disabled. Here we assume that dst_output() is called to kill the
queued packets. Unfortunately this assumption is not true in all
cases, so it is possible that these packets leave the system unwanted.

We fix this by generating queueing routes only from the
route lookup functions, here we can guarantee a call to
dst_output() afterwards.

Fixes: a0073fe18e71 ("xfrm: Add a state resolution packet queue")
Reported-by: Konstantinos Kolelis <k.kolelis@sirrix.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/net/dst.h      |    1 +
 net/xfrm/xfrm_policy.c |   32 ++++++++++++++++++++++++--------
 2 files changed, 25 insertions(+), 8 deletions(-)

--- a/include/net/dst.h
+++ b/include/net/dst.h
@@ -466,6 +466,7 @@ void dst_init(void);
 /* Flags for xfrm_lookup flags argument. */
 enum {
 	XFRM_LOOKUP_ICMP = 1 << 0,
+	XFRM_LOOKUP_QUEUE = 1 << 1,
 };
 
 struct flowi;
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -41,6 +41,11 @@
 
 static struct dst_entry *xfrm_policy_sk_bundles;
 
+struct xfrm_flo {
+	struct dst_entry *dst_orig;
+	u8 flags;
+};
+
 static DEFINE_SPINLOCK(xfrm_policy_afinfo_lock);
 static struct xfrm_policy_afinfo __rcu *xfrm_policy_afinfo[NPROTO]
 						__read_mostly;
@@ -1889,13 +1894,14 @@ static int xdst_queue_output(struct sk_b
 }
 
 static struct xfrm_dst *xfrm_create_dummy_bundle(struct net *net,
-						 struct dst_entry *dst,
+						 struct xfrm_flo *xflo,
 						 const struct flowi *fl,
 						 int num_xfrms,
 						 u16 family)
 {
 	int err;
 	struct net_device *dev;
+	struct dst_entry *dst;
 	struct dst_entry *dst1;
 	struct xfrm_dst *xdst;
 
@@ -1903,9 +1909,12 @@ static struct xfrm_dst *xfrm_create_dumm
 	if (IS_ERR(xdst))
 		return xdst;
 
-	if (net->xfrm.sysctl_larval_drop || num_xfrms <= 0)
+	if (!(xflo->flags & XFRM_LOOKUP_QUEUE) ||
+	    net->xfrm.sysctl_larval_drop ||
+	    num_xfrms <= 0)
 		return xdst;
 
+	dst = xflo->dst_orig;
 	dst1 = &xdst->u.dst;
 	dst_hold(dst);
 	xdst->route = dst;
@@ -1947,7 +1956,7 @@ static struct flow_cache_object *
 xfrm_bundle_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir,
 		   struct flow_cache_object *oldflo, void *ctx)
 {
-	struct dst_entry *dst_orig = (struct dst_entry *)ctx;
+	struct xfrm_flo *xflo = (struct xfrm_flo *)ctx;
 	struct xfrm_policy *pols[XFRM_POLICY_TYPE_MAX];
 	struct xfrm_dst *xdst, *new_xdst;
 	int num_pols = 0, num_xfrms = 0, i, err, pol_dead;
@@ -1988,7 +1997,8 @@ xfrm_bundle_lookup(struct net *net, cons
 			goto make_dummy_bundle;
 	}
 
-	new_xdst = xfrm_resolve_and_create_bundle(pols, num_pols, fl, family, dst_orig);
+	new_xdst = xfrm_resolve_and_create_bundle(pols, num_pols, fl, family,
+						  xflo->dst_orig);
 	if (IS_ERR(new_xdst)) {
 		err = PTR_ERR(new_xdst);
 		if (err != -EAGAIN)
@@ -2022,7 +2032,7 @@ make_dummy_bundle:
 	/* We found policies, but there's no bundles to instantiate:
 	 * either because the policy blocks, has no transformations or
 	 * we could not build template (no xfrm_states).*/
-	xdst = xfrm_create_dummy_bundle(net, dst_orig, fl, num_xfrms, family);
+	xdst = xfrm_create_dummy_bundle(net, xflo, fl, num_xfrms, family);
 	if (IS_ERR(xdst)) {
 		xfrm_pols_put(pols, num_pols);
 		return ERR_CAST(xdst);
@@ -2121,13 +2131,18 @@ struct dst_entry *xfrm_lookup(struct net
 	}
 
 	if (xdst == NULL) {
+		struct xfrm_flo xflo;
+
+		xflo.dst_orig = dst_orig;
+		xflo.flags = flags;
+
 		/* To accelerate a bit...  */
 		if ((dst_orig->flags & DST_NOXFRM) ||
 		    !net->xfrm.policy_count[XFRM_POLICY_OUT])
 			goto nopol;
 
 		flo = flow_cache_lookup(net, fl, family, dir,
-					xfrm_bundle_lookup, dst_orig);
+					xfrm_bundle_lookup, &xflo);
 		if (flo == NULL)
 			goto nopol;
 		if (IS_ERR(flo)) {
@@ -2219,7 +2234,8 @@ struct dst_entry *xfrm_lookup_route(stru
 				    const struct flowi *fl,
 				    struct sock *sk, int flags)
 {
-	struct dst_entry *dst = xfrm_lookup(net, dst_orig, fl, sk, flags);
+	struct dst_entry *dst = xfrm_lookup(net, dst_orig, fl, sk,
+					    flags | XFRM_LOOKUP_QUEUE);
 
 	if (IS_ERR(dst) && PTR_ERR(dst) == -EREMOTE)
 		return make_blackhole(net, dst_orig->ops->family, dst_orig);
@@ -2493,7 +2509,7 @@ int __xfrm_route_forward(struct sk_buff
 
 	skb_dst_force(skb);
 
-	dst = xfrm_lookup(net, skb_dst(skb), &fl, NULL, 0);
+	dst = xfrm_lookup(net, skb_dst(skb), &fl, NULL, XFRM_LOOKUP_QUEUE);
 	if (IS_ERR(dst)) {
 		res = 0;
 		dst = NULL;



  parent reply	other threads:[~2014-10-13  2:24 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-13  2:23 [PATCH 3.14 00/37] 3.14.22-stable review Greg Kroah-Hartman
2014-10-13  2:23 ` [PATCH 3.14 01/37] netlink: reset network header before passing to taps Greg Kroah-Hartman
2014-10-13  2:23 ` [PATCH 3.14 02/37] rtnetlink: fix VF info size Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 03/37] net: Always untag vlan-tagged traffic on input Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 04/37] myri10ge: check for DMA mapping errors Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 05/37] i40e: Dont stop driver probe when querying DCB config fails Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 06/37] tcp: dont use timestamp from repaired skb-s to calculate RTT (v2) Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 07/37] sit: Fix ipip6_tunnel_lookup device matching criteria Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 08/37] tcp: fix tcp_release_cb() to dispatch via address family for mtu_reduced() Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 09/37] tcp: fix ssthresh and undo for consecutive short FRTO episodes Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 10/37] packet: handle too big packets for PACKET_V3 Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 11/37] openvswitch: fix panic with multiple vlan headers Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 12/37] vxlan: fix incorrect initializer in union vxlan_addr Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 13/37] l2tp: fix race while getting PMTU on PPP pseudo-wire Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 14/37] ipv6: fix rtnl locking in setsockopt for anycast and multicast Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 15/37] bonding: fix div by zero while enslaving and transmitting Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 16/37] ipv6: restore the behavior of ipv6_sock_ac_drop() Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 17/37] bridge: Check if vlan filtering is enabled only once Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 18/37] bridge: Fix br_should_learn to check vlan_enabled Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 19/37] net: allow macvlans to move to net namespace Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 20/37] tg3: Work around HW/FW limitations with vlan encapsulated frames Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 21/37] tg3: Allow for recieve of full-size 8021AD frames Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 22/37] xfrm: Generate blackhole routes only from route lookup functions Greg Kroah-Hartman
2014-10-13  2:24 ` Greg Kroah-Hartman [this message]
2014-10-13  2:24 ` [PATCH 3.14 24/37] macvtap: Fix race between device delete and open Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 25/37] Revert "net/macb: add pinctrl consumer support" Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 26/37] gro: fix aggregation for skb using frag_list Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 27/37] hyperv: Fix a bug in netvsc_start_xmit() Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 28/37] ip6_gre: fix flowi6_proto value in xmit path Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 29/37] team: avoid race condition in scheduling delayed work Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 30/37] sctp: handle association restarts when the socket is closed Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 31/37] tcp: fixing TLPs FIN recovery Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 32/37] USB: Add device quirk for ASUS T100 Base Station keyboard Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 33/37] USB: serial: cp210x: added Ketra N1 wireless interface support Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 34/37] USB: cp210x: add support for Seluxit USB dongle Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 35/37] usb: musb: dsps: kill OTG timer on suspend Greg Kroah-Hartman
2014-10-13  2:24 ` [PATCH 3.14 36/37] crypto: caam - fix addressing of struct member Greg Kroah-Hartman
2014-10-14  8:31   ` Cristian Stoica
2014-10-14  8:38     ` Greg Kroah-Hartman
2014-10-14  8:48       ` Cristian Stoica
2014-10-13  2:24 ` [PATCH 3.14 37/37] serial: 8250: Add Quark X1000 to 8250_pci.c Greg Kroah-Hartman
2014-10-13 15:18 ` [PATCH 3.14 00/37] 3.14.22-stable review Guenter Roeck
2014-10-13 20:31 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141013022401.256638435@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=k.kolelis@sirrix.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).