* pull request (net): ipsec 2017-10-09
@ 2017-10-09 7:16 Steffen Klassert
2017-10-09 7:16 ` [PATCH 1/4] xfrm: Fix deletion of offloaded SAs on failure Steffen Klassert
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Steffen Klassert @ 2017-10-09 7:16 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
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_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(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/4] xfrm: Fix deletion of offloaded SAs on failure.
2017-10-09 7:16 pull request (net): ipsec 2017-10-09 Steffen Klassert
@ 2017-10-09 7:16 ` Steffen Klassert
2017-10-09 7:16 ` [PATCH 2/4] xfrm: Fix negative device refcount on offload failure Steffen Klassert
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2017-10-09 7:16 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
When 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.
Fixes: d77e38e612a0 ("xfrm: Add an IPsec hardware offloading API")
Reported-by: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_user.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 2bfbd91..b997f13 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -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;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/4] xfrm: Fix negative device refcount on offload failure.
2017-10-09 7:16 pull request (net): ipsec 2017-10-09 Steffen Klassert
2017-10-09 7:16 ` [PATCH 1/4] xfrm: Fix deletion of offloaded SAs on failure Steffen Klassert
@ 2017-10-09 7:16 ` Steffen Klassert
2017-10-09 7:16 ` [PATCH 3/4] vti: fix NULL dereference in xfrm_input() Steffen Klassert
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2017-10-09 7:16 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
Reset the offload device at the xfrm_state if the device was
not able to offload the state. Otherwise we drop the device
refcount twice.
Fixes: d77e38e612a0 ("xfrm: Add an IPsec hardware offloading API")
Reported-by: Shannon Nelson <shannon.nelson@oracle.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_device.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
index acf0010..30e5746 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -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;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/4] vti: fix NULL dereference in xfrm_input()
2017-10-09 7:16 pull request (net): ipsec 2017-10-09 Steffen Klassert
2017-10-09 7:16 ` [PATCH 1/4] xfrm: Fix deletion of offloaded SAs on failure Steffen Klassert
2017-10-09 7:16 ` [PATCH 2/4] xfrm: Fix negative device refcount on offload failure Steffen Klassert
@ 2017-10-09 7:16 ` Steffen Klassert
2017-10-09 7:16 ` [PATCH 4/4] xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock Steffen Klassert
2017-10-09 16:44 ` pull request (net): ipsec 2017-10-09 David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2017-10-09 7:16 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
From: Alexey Kodanev <alexey.kodanev@oracle.com>
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.
Fixes: 7e9e9202bccc ("xfrm: Clear RX SKB secpath xfrm_offload")
Signed-off-by: Alexey Kodanev <alexey.kodanev@oracle.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_input.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 2515cd2..8ac9d32 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -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;
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 4/4] xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock
2017-10-09 7:16 pull request (net): ipsec 2017-10-09 Steffen Klassert
` (2 preceding siblings ...)
2017-10-09 7:16 ` [PATCH 3/4] vti: fix NULL dereference in xfrm_input() Steffen Klassert
@ 2017-10-09 7:16 ` Steffen Klassert
2017-10-09 16:44 ` pull request (net): ipsec 2017-10-09 David Miller
4 siblings, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2017-10-09 7:16 UTC (permalink / raw)
To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev
From: Artem Savkov <asavkov@redhat.com>
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.
Fixes: ec30d78c14a8 xfrm: add xdst pcpu cache
Signed-off-by: Artem Savkov <asavkov@redhat.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
net/xfrm/xfrm_state.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 0dab1cd..1221347 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -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);
--
2.7.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: pull request (net): ipsec 2017-10-09
2017-10-09 7:16 pull request (net): ipsec 2017-10-09 Steffen Klassert
` (3 preceding siblings ...)
2017-10-09 7:16 ` [PATCH 4/4] xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock Steffen Klassert
@ 2017-10-09 16:44 ` David Miller
4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-10-09 16:44 UTC (permalink / raw)
To: steffen.klassert; +Cc: herbert, netdev
From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Mon, 9 Oct 2017 09:16:35 +0200
> 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_flush under xfrm_state_lock,
> it triggers several locking warnings. From Artem Savkov.
>
> Please pull or let me know if there are problems.
Pulled, thank you.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-10-09 16:44 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-09 7:16 pull request (net): ipsec 2017-10-09 Steffen Klassert
2017-10-09 7:16 ` [PATCH 1/4] xfrm: Fix deletion of offloaded SAs on failure Steffen Klassert
2017-10-09 7:16 ` [PATCH 2/4] xfrm: Fix negative device refcount on offload failure Steffen Klassert
2017-10-09 7:16 ` [PATCH 3/4] vti: fix NULL dereference in xfrm_input() Steffen Klassert
2017-10-09 7:16 ` [PATCH 4/4] xfrm: don't call xfrm_policy_cache_flush under xfrm_state_lock Steffen Klassert
2017-10-09 16:44 ` pull request (net): ipsec 2017-10-09 David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.