pull request (net): ipsec 2017-10-09
Subsystems (3)
Steffen Klassert
maintainerPATCH 2/4 xfrm: Fix negative device refcount on offload failure.
In reply to Steffen KlassertReset the offload device at the xfrm_state if the device was not able to offload the state. Otherwise we drop the device refcount twice.
--- net/xfrm/xfrm_device.c | 1 + 1 file changed, 1 insertion(+)
net/xfrm/xfrm_device.c +1 -0
@@ -91,6 +91,7 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x, }if (!dev->xfrmdev_ops || !dev->xfrmdev_ops->xdo_dev_state_add) { + xso->dev =NULL ;dev_put (dev);return 0 ; }
Signature · 1 line
2.7.4
Steffen Klassert
maintainerPATCH 1/4 xfrm: Fix deletion of offloaded SAs on failure.
In reply to Steffen KlassertWhen we off load a SA, it gets pushed to the NIC before we can add it. In case of a failure, we don't delete this SA from the NIC. Fix this by calling xfrm_dev_state_delete on failure.
--- net/xfrm/xfrm_user.c | 1 + 1 file changed, 1 insertion(+)
net/xfrm/xfrm_user.c +1 -0
@@ -657,6 +657,7 @@ static int xfrm_add_sa(struct sk_buff *skb, struct nlmsghdr *nlh,if (err <0 ) { x->km.state =XFRM_STATE_DEAD ; +xfrm_dev_state_delete (x);__xfrm_state_put (x); goto out; }
Signature · 1 line
2.7.4
Steffen Klassert
maintainer1) Fix some error paths of the IPsec offloading API.
2) Fix a NULL pointer dereference when IPsec is used with vti. From Alexey Kodanev.
3) Don't call xfrm_policy_cache_flush under xfrm_state_lock, it triggers several locking warnings. From Artem Savkov.
Please pull or let me know if there are problems.
Thanks!
The following changes since commit 1f4f554a72be0d8c164c2f5bc6ba939a1c624fb4:
net: qualcomm: rmnet: Fix a double free (2017-09-09 14:33:27 -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 dd269db84908d4d3f7c0efed85bf9d8939fb0b9b:
xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock (2017-09-28 09:39:05 +0200)
----------------------------------------------------------------
Alexey Kodanev (1):
vti: fix NULL dereference in xfrm_input()
Artem Savkov (1):
xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock
Steffen Klassert (2):
xfrm: Fix deletion of offloaded SAs on failure.
xfrm: Fix negative device refcount on offload failure.
net/xfrm/xfrm_device.c | 1 + net/xfrm/xfrm_input.c | 6 ++++-- net/xfrm/xfrm_state.c | 4 ++-- net/xfrm/xfrm_user.c | 1 + 4 files changed, 8 insertions(+), 4 deletions(-)
Steffen Klassert
maintainerPATCH 4/4 xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock
From: Artem Savkov <[email protected]>
I might be wrong but it doesn't look like xfrm_state_lock is required for xfrm_policy_cache_flush and calling it under this lock triggers both "sleeping function called from invalid context" and "possible circular locking dependency detected" warnings on flush.
--- net/xfrm/xfrm_state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/xfrm/xfrm_state.c +2 -2
@@ -732,12 +732,12 @@ int xfrm_state_flush(struct net *net, u8 proto, bool task_valid) } } } +out: +spin_unlock_bh (&net->xfrm.xfrm_state_lock);if (cnt) { err =0 ;xfrm_policy_cache_flush (); } -out: -spin_unlock_bh (&net->xfrm.xfrm_state_lock);return err; }EXPORT_SYMBOL (xfrm_state_flush);
Signature · 1 line
2.7.4
Steffen Klassert
maintainerPATCH 3/4 vti: fix NULL dereference in xfrm_input()
In reply to Steffen KlassertFrom: Alexey Kodanev <[email protected]>
Can be reproduced with LTP tests:
# icmp-uni-vti.sh -p ah -a sha256 -m tunnel -S fffffffe -k 1 -s 10
IPv4:
RIP: 0010:xfrm_input+0x7f9/0x870 ... Call Trace: <IRQ> vti_input+0xaa/0x110 [ip_vti] ? skb_free_head+0x21/0x40 vti_rcv+0x33/0x40 [ip_vti] xfrm4_ah_rcv+0x33/0x60 ip_local_deliver_finish+0x94/0x1e0 ip_local_deliver+0x6f/0xe0 ? ip_route_input_noref+0x28/0x50 ...
# icmp-uni-vti.sh -6 -p ah -a sha256 -m tunnel -S fffffffe -k 1 -s 10 IPv6: RIP: 0010:xfrm_input+0x7f9/0x870 ... Call Trace: <IRQ> xfrm6_rcv_tnl+0x3c/0x40 vti6_rcv+0xd5/0xe0 [ip6_vti] xfrm6_ah_rcv+0x33/0x60 ip6_input_finish+0xee/0x460 ip6_input+0x3f/0xb0 ip6_rcv_finish+0x45/0xa0 ipv6_rcv+0x34b/0x540
xfrm_input() invokes xfrm_rcv_cb() -> vti_rcv_cb(), the last callback might call skb_scrub_packet(), which in turn can reset secpath.
Fix it by adding a check that skb->sp is not NULL.
--- net/xfrm/xfrm_input.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/xfrm/xfrm_input.c +4 -2
@@ -429,7 +429,8 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)nf_reset (skb);if (decaps) { - skb->sp->olen =0 ; +if (skb->sp) + skb->sp->olen =0 ;skb_dst_drop (skb);gro_cells_receive (&gro_cells, skb);return 0 ;
@@ -440,7 +441,8 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) err = x->inner_mode->afinfo->transport_finish (skb, xfrm_gro || async);if (xfrm_gro) { - skb->sp->olen =0 ; +if (skb->sp) + skb->sp->olen =0 ;skb_dst_drop (skb);gro_cells_receive (&gro_cells, skb);return err;
Signature · 1 line
2.7.4
David Miller
maintainerFrom: Steffen Klassert <[email protected]>
Date: Mon, 9 Oct 2017 09:16:35 +0200
Quoted 9 lines
1) Fix some error paths of the IPsec offloading API.
2) Fix a NULL pointer dereference when IPsec is used with vti. From Alexey Kodanev.
3) Don't call
xfrm_policy_cache_flushunderxfrm_state_lock, it triggers several locking warnings. From Artem Savkov.Please pull or let me know if there are problems.
Pulled, thank you.