pull request (net): ipsec 2015-10-22
Subsystems (3)
Steffen Klassert
maintainer1) Fix IPsec pre-encap fragmentation for GSO packets. From Herbert Xu.
2) Fix some header checks in _decode_session6.
We skip the header informations if the data pointer points already behind the header in question for some protocols. This is because we call pskb_may_pull with a negative value converted to unsigened int from pskb_may_pull in this case. Skipping the header informations can lead to incorrect policy lookups. From Mathias Krause.
3) Allow to change the replay threshold and expiry timer of a state without having to set other attributes like replay counter and byte lifetime. Changing these other attributes may break the SA. From Michael Rossberg.
4) Fix pmtu discovery for local generated packets. We may fail dispatch to the inner address family. As a reault, the local error handler is not called and the mtu value is not reported back to userspace.
Please pull or let me know if there are problems.
Thanks!
The following changes since commit 724a7636ad026a3a68f3fc626ccd04111f65cfd9:
Merge branch 'sctp-fixes' (2015-09-03 15:43:06 -0700)
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 ca064bd89363a6e7e71b1c5226ff1b718957a9d4:
xfrm: Fix pmtu discovery for local generated packets. (2015-10-19 10:30:05 +0200)
----------------------------------------------------------------
Herbert Xu (1):
ipv6: Fix IPsec pre-encap fragmentation check
Mathias Krause (1):
xfrm6: Fix ICMPv6 and MH header checks in _decode_session6
Michael Rossberg (1):
xfrm: Fix state threshold configuration from userspace
Steffen Klassert (1):
xfrm: Fix pmtu discovery for local generated packets.
net/ipv4/xfrm4_output.c | 2 ++ net/ipv6/xfrm6_output.c | 18 ++++++++++++------ net/ipv6/xfrm6_policy.c | 6 ++++-- net/xfrm/xfrm_user.c | 4 +++- 4 files changed, 21 insertions(+), 9 deletions(-)
Steffen Klassert
maintainerPATCH 1/4 ipv6: Fix IPsec pre-encap fragmentation check
From: Herbert Xu <[email protected]>
The IPv6 IPsec pre-encap path performs fragmentation for tunnel-mode packets. That is, we perform fragmentation pre-encap rather than post-encap.
A check was added later to ensure that proper MTU information is passed back for locally generated traffic. Unfortunately this check was performed on all IPsec packets, including transport-mode packets.
What's more, the check failed to take GSO into account.
The end result is that transport-mode GSO packets get dropped at the check.
This patch fixes it by moving the tunnel mode check forward as well as adding the GSO check.
--- net/ipv6/xfrm6_output.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-)
net/ipv6/xfrm6_output.c +11 -6
@@ -136,6 +136,7 @@ static int __xfrm6_output(struct sock *sk, struct sk_buff *skb)struct dst_entry *dst =skb_dst (skb);struct xfrm_state *x = dst->xfrm;int mtu; +bool toobig;#ifdef CONFIG_NETFILTER if (!x) {
@@ -144,25 +145,29 @@ static int __xfrm6_output(struct sock *sk, struct sk_buff *skb) }#endif +if (x->props.mode !=XFRM_MODE_TUNNEL ) + goto skip_frag; +if (skb->protocol ==htons (ETH_P_IPV6 )) mtu =ip6_skb_dst_mtu (skb);else mtu =dst_mtu (skb_dst (skb)); -if (skb->len > mtu &&xfrm6_local_dontfrag (skb)) { + toobig = skb->len > mtu && !skb_is_gso (skb); + +if (toobig &&xfrm6_local_dontfrag (skb)) {xfrm6_local_rxpmtu (skb, mtu);return -EMSGSIZE ; - }else if (!skb->ignore_df && skb->len > mtu && skb->sk) { + }else if (!skb->ignore_df && toobig && skb->sk) {xfrm_local_error (skb, mtu);return -EMSGSIZE ; } -if (x->props.mode ==XFRM_MODE_TUNNEL && - ((skb->len > mtu && !skb_is_gso (skb)) || -dst_allfrag (skb_dst (skb)))) { +if (toobig ||dst_allfrag (skb_dst (skb)))return ip6_fragment (sk, skb, x->outer_mode->afinfo->output_finish); - } + +skip_frag:return x->outer_mode->afinfo->output_finish (sk, skb); }
Signature · 1 line
1.9.1
Steffen Klassert
maintainerPATCH 2/4 xfrm6: Fix ICMPv6 and MH header checks in _decode_session6
In reply to Steffen KlassertFrom: Mathias Krause <[email protected]>
Ensure there's enough data left prior calling pskb_may_pull(). If skb->data was already advanced, we'll call pskb_may_pull() with a negative value converted to unsigned int -- leading to a huge positive value. That won't matter in practice as pskb_may_pull() will likely fail in this case, but it leads to underflow reports on kernels handling such kind of over-/underflows, e.g. a PaX enabled kernel instrumented with the size_overflow plugin.
--- net/ipv6/xfrm6_policy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/ipv6/xfrm6_policy.c +4 -2
@@ -178,7 +178,8 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)return ;case IPPROTO_ICMPV6 : -if (!onlyproto &&pskb_may_pull (skb, nh + offset +2 - skb->data)) { +if (!onlyproto && (nh + offset +2 < skb->data || +pskb_may_pull (skb, nh + offset +2 - skb->data))) {u8 *icmp; nh =skb_network_header (skb);
@@ -192,7 +193,8 @@ _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)) { +if (!onlyproto && (nh + offset +3 < skb->data || +pskb_may_pull (skb, nh + offset +3 - skb->data))) {struct ip6_mh *mh; nh =skb_network_header (skb);
Signature · 1 line
1.9.1
Steffen Klassert
maintainerPATCH 4/4 xfrm: Fix pmtu discovery for local generated packets.
In reply to Steffen KlassertCommit 044a832a777 ("xfrm: Fix local error reporting crash with interfamily tunnels") moved the setting of skb->protocol behind the last access of the inner mode family to fix an interfamily crash. Unfortunately now skb->protocol might not be set at all, so we fail dispatch to the inner address family. As a reault, the local error handler is not called and the mtu value is not reported back to userspace.
We fix this by setting skb->protocol on message size errors before we call xfrm_local_error.
--- net/ipv4/xfrm4_output.c | 2 ++ net/ipv6/xfrm6_output.c | 1 + 2 files changed, 3 insertions(+)
net/ipv4/xfrm4_output.c +2 -0
@@ -30,6 +30,8 @@ static int xfrm4_tunnel_check_size(struct sk_buff *skb) mtu =dst_mtu (skb_dst (skb));if (skb->len > mtu) { + skb->protocol =htons (ETH_P_IP ); +if (skb->sk)xfrm_local_error (skb, mtu);else
net/ipv6/xfrm6_output.c +1 -0
@@ -79,6 +79,7 @@ static int xfrm6_tunnel_check_size(struct sk_buff *skb)if (!skb->ignore_df && skb->len > mtu) { skb->dev = dst->dev; + skb->protocol =htons (ETH_P_IPV6 );if (xfrm6_local_dontfrag (skb))xfrm6_local_rxpmtu (skb, mtu);
Signature · 1 line
1.9.1
Steffen Klassert
maintainerPATCH 3/4 xfrm: Fix state threshold configuration from userspace
In reply to Steffen KlassertFrom: Michael Rossberg <[email protected]>
Allow to change the replay threshold (XFRMA_REPLAY_THRESH) and expiry timer (XFRMA_ETIMER_THRESH) of a state without having to set other attributes like replay counter and byte lifetime. Changing these other values while traffic flows will break the state.
--- net/xfrm/xfrm_user.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/xfrm/xfrm_user.c +3 -1
@@ -1928,8 +1928,10 @@ static int xfrm_new_ae(struct sk_buff *skb, struct nlmsghdr *nlh,struct nlattr *rp = attrs[XFRMA_REPLAY_VAL ];struct nlattr *re = attrs[XFRMA_REPLAY_ESN_VAL ];struct nlattr *lt = attrs[XFRMA_LTIME_VAL ]; +struct nlattr *et = attrs[XFRMA_ETIMER_THRESH ]; +struct nlattr *rt = attrs[XFRMA_REPLAY_THRESH ]; -if (!lt && !rp && !re) +if (!lt && !rp && !re && !et && !rt)return err;/* pedantic mode - thou shalt sayeth replaceth */
Signature · 1 line
1.9.1
David Miller
maintainerFrom: Steffen Klassert <[email protected]>
Date: Thu, 22 Oct 2015 08:07:15 +0200
Quoted 16 lines
1) Fix IPsec pre-encap fragmentation for GSO packets. From Herbert Xu.
2) Fix some header checks in
_decode_session6.
We skip the header informations if the data pointer points already behind the header in question for some protocols. This is because we callpskb_may_pullwith a negative value converted to unsigened int frompskb_may_pullin this case. Skipping the header informations can lead to incorrect policy lookups. From Mathias Krause.3) Allow to change the replay threshold and expiry timer of a state without having to set other attributes like replay counter and byte lifetime. Changing these other attributes may break the SA. From Michael Rossberg.
Quoted 6 lines
4) Fix pmtu discovery for local generated packets. We may fail dispatch to the inner address family. As a reault, the local error handler is not called and the mtu value is not reported back to userspace.
Please pull or let me know if there are problems.
Pulled, thanks a lot Steffen.