[PATCH xfrm v1] xfrm: fix error flow in case of add state fails

Subsystems: networking [general], networking [ipsec], the rest

STALE3154d

3 messages, 3 authors, 2018-01-19 · open the first message on its own page

[PATCH xfrm v1] xfrm: fix error flow in case of add state fails

From: Aviad Yehezkel <hidden>
Date: 2018-01-18 13:42:13

If add state fails in case of device offload, netdev refcount
will be negative since gc task is attempting to dev_free this state.
This is fixed by putting NULL in state dev field.

Signed-off-by: Aviad Yehezkel <redacted>
Signed-off-by: Boris Pismeny <redacted>
---
 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 fb3f920..cd2b7d3 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -109,6 +109,7 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
 
 	err = dev->xfrmdev_ops->xdo_dev_state_add(x);
 	if (err) {
+		xso->dev = NULL;
 		dev_put(dev);
 		return err;
 	}
-- 
2.7.4

Re: [PATCH xfrm v1] xfrm: fix error flow in case of add state fails

From: Shannon Nelson <hidden>
Date: 2018-01-18 17:25:55

On 1/18/2018 5:41 AM, Aviad Yehezkel wrote:
If add state fails in case of device offload, netdev refcount
will be negative since gc task is attempting to dev_free this state.
This is fixed by putting NULL in state dev field.

Signed-off-by: Aviad Yehezkel <redacted>
Signed-off-by: Boris Pismeny <redacted>
Thanks - I was wondering about that a couple of days ago and hadn't 
gotten back to it.

Signed-off-by: Shannon Nelson <redacted>
quoted hunk
---
  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 fb3f920..cd2b7d3 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -109,6 +109,7 @@ int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
  
  	err = dev->xfrmdev_ops->xdo_dev_state_add(x);
  	if (err) {
+		xso->dev = NULL;
  		dev_put(dev);
  		return err;
  	}

Re: [PATCH xfrm v1] xfrm: fix error flow in case of add state fails

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: 2018-01-19 10:06:36

On Thu, Jan 18, 2018 at 03:41:51PM +0200, Aviad Yehezkel wrote:
If add state fails in case of device offload, netdev refcount
will be negative since gc task is attempting to dev_free this state.
This is fixed by putting NULL in state dev field.

Signed-off-by: Aviad Yehezkel <redacted>
Signed-off-by: Boris Pismeny <redacted>
Applied, thanks!
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help