pull request (net): ipsec 2015-03-16
Subsystems (3)
Steffen Klassert
maintainer1) Fix the network header offset in _decode_session6 when multiple IPv6 extension headers are present. From Hajime Tazaki.
2) Fix an interfamily tunnel crash. We set outer mode protocol too early and may dispatch to the wrong address family. Move the setting of the outer mode protocol behind the last accessing of the inner mode to fix the crash.
3) Most callers of xfrm_lookup() expect that dst_orig is released on error. But xfrm_lookup_route() may need dst_orig to handle certain error cases. So introduce a flag that tells what should be done in case of error. From Huaibin Wang.
Please pull or let me know if there are problems.
Thanks!
The following changes since commit 59343cd7c4809cf7598789e1cd14563780ae4239:
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2015-01-27 13:55:36 -0800)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec.git master
for you to fetch changes up to ac37e2515c1a89c477459a2020b6bfdedabdb91b:
xfrm: release dst_orig in case of error in xfrm_lookup() (2015-02-12 07:10:56 +0100)
----------------------------------------------------------------
Hajime Tazaki (1):
xfrm6: Fix a offset value for network header in _decode_session6
Steffen Klassert (1):
xfrm: Fix local error reporting crash with interfamily tunnels
huaibin Wang (1):
xfrm: release dst_orig in case of error in xfrm_lookup()
include/net/dst.h | 1 + net/ipv4/xfrm4_output.c | 2 +- net/ipv6/xfrm6_output.c | 2 +- net/ipv6/xfrm6_policy.c | 1 + net/xfrm/xfrm_policy.c | 12 ++++++------ 5 files changed, 10 insertions(+), 8 deletions(-)
Steffen Klassert
maintainerPATCH 1/3 xfrm6: Fix a offset value for network header in _decode_session6
From: Hajime Tazaki <[email protected]>
When a network-layer header has multiple IPv6 extension headers, then offset for mobility header goes wrong. This regression breaks an xfrm policy lookup for a particular receive packet. Binding update packets of Mobile IPv6 are all discarded without this fix.
--- net/ipv6/xfrm6_policy.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/xfrm6_policy.c +1 -0
@@ -200,6 +200,7 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)#if IS_ENABLED (CONFIG_IPV6_MIP6 )case IPPROTO_MH : + offset +=ipv6_optlen (exthdr);if (!onlyproto &&pskb_may_pull (skb, nh + offset +3 - skb->data)) {struct ip6_mh *mh;
Signature · 1 line
1.9.1
Steffen Klassert
maintainerPATCH 2/3 xfrm: Fix local error reporting crash with interfamily tunnels
In reply to Steffen KlassertWe set the outer mode protocol too early. As a result, the local error handler might dispatch to the wrong address family and report the error to a wrong socket type. We fix this by setting the outer protocol to the skb after we accessed the inner mode for the last time, right before we do the atcual encapsulation where we switch finally to the outer mode.
--- net/ipv4/xfrm4_output.c | 2 +- net/ipv6/xfrm6_output.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
net/ipv4/xfrm4_output.c +1 -1
@@ -63,6 +63,7 @@ int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb)return err;IPCB (skb)->flags |=IPSKB_XFRM_TUNNEL_SIZE ; + skb->protocol =htons (ETH_P_IP );return x->outer_mode->output2 (x, skb); }
@@ -71,7 +72,6 @@ EXPORT_SYMBOL(xfrm4_prepare_output);int xfrm4_output_finish (struct sk_buff *skb) {memset (IPCB (skb),0 ,sizeof (*IPCB (skb))); - skb->protocol =htons (ETH_P_IP );#ifdef CONFIG_NETFILTER IPCB (skb)->flags |=IPSKB_XFRM_TRANSFORMED ;
net/ipv6/xfrm6_output.c +1 -1
@@ -114,6 +114,7 @@ int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb)return err; skb->ignore_df =1 ; + skb->protocol =htons (ETH_P_IPV6 );return x->outer_mode->output2 (x, skb); }
@@ -122,7 +123,6 @@ EXPORT_SYMBOL(xfrm6_prepare_output);int xfrm6_output_finish (struct sk_buff *skb) {memset (IP6CB (skb),0 ,sizeof (*IP6CB (skb))); - skb->protocol =htons (ETH_P_IPV6 );#ifdef CONFIG_NETFILTER IP6CB (skb)->flags |=IP6SKB_XFRM_TRANSFORMED ;
Signature · 1 line
1.9.1
Steffen Klassert
maintainerPATCH 3/3 xfrm: release dst_orig in case of error in xfrm_lookup()
In reply to Steffen KlassertFrom: huaibin Wang <[email protected]>
dst_orig should be released on error. Function like __xfrm_route_forward() expects that behavior.
Since a recent commit, xfrm_lookup() may also be called by xfrm_lookup_route(), which expects the opposite.
Let's introduce a new flag (XFRM_LOOKUP_KEEP_DST_REF) to tell what should be done in case of error.
--- include/net/dst.h | 1 + net/xfrm/xfrm_policy.c | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-)
include/net/dst.h +1 -0
@@ -481,6 +481,7 @@ void dst_init(void);enum {XFRM_LOOKUP_ICMP =1 <<0 ,XFRM_LOOKUP_QUEUE =1 <<1 , +XFRM_LOOKUP_KEEP_DST_REF =1 <<2 , };struct flowi ;
net/xfrm/xfrm_policy.c +6 -6
@@ -2269,11 +2269,9 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,* have the xfrm_state's. We need to wait for KM to * negotiate new SA's or bail out with error.*/ if (net->xfrm.sysctl_larval_drop) { -dst_release (dst); -xfrm_pols_put (pols, drop_pols);XFRM_INC_STATS (net,LINUX_MIB_XFRMOUTNOSTATES ); - -return ERR_PTR (-EREMOTE ); + err = -EREMOTE ; + goto error; } err = -EAGAIN ;
@@ -2324,7 +2322,8 @@ nopol: error:dst_release (dst); dropdst: -dst_release (dst_orig); +if (!(flags &XFRM_LOOKUP_KEEP_DST_REF )) +dst_release (dst_orig);xfrm_pols_put (pols, drop_pols);return ERR_PTR (err); }
@@ -2338,7 +2337,8 @@ struct dst_entry *xfrm_lookup_route(struct net *net, struct dst_entry *dst_orig, struct sock *sk, int flags) {struct dst_entry *dst =xfrm_lookup (net, dst_orig, fl, sk, - flags |XFRM_LOOKUP_QUEUE ); + flags |XFRM_LOOKUP_QUEUE | +XFRM_LOOKUP_KEEP_DST_REF );if (IS_ERR (dst) &&PTR_ERR (dst) == -EREMOTE )return make_blackhole (net, dst_orig->ops->family, dst_orig);
Signature · 1 line
1.9.1
David Miller
maintainerFrom: Steffen Klassert <[email protected]>
Date: Mon, 16 Mar 2015 07:52:21 +0100
Quoted 10 lines
1) Fix the network header offset in
_decode_session6when multiple IPv6 extension headers are present. From Hajime Tazaki.2) Fix an interfamily tunnel crash. We set outer mode protocol too early and may dispatch to the wrong address family. Move the setting of the outer mode protocol behind the last accessing of the inner mode to fix the crash.
Quoted 7 lines
3) Most callers of
xfrm_lookup()expect thatdst_origis released on error. Butxfrm_lookup_route()may needdst_origto handle certain error cases. So introduce a flag that tells what should be done in case of error. From Huaibin Wang.Please pull or let me know if there are problems.
Pulled, thanks a lot.