netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xfrm: fix a race in xfrm_state_lookup_byspi
@ 2015-04-29  0:42 roy.qing.li
  2015-04-29  5:25 ` Du, Fan
  0 siblings, 1 reply; 3+ messages in thread
From: roy.qing.li @ 2015-04-29  0:42 UTC (permalink / raw)
  To: netdev; +Cc: fan.du, steffen.klassert

From: Li RongQing <roy.qing.li@gmail.com>

The returned xfrm_state should be hold before unlock xfrm_state_lock,
otherwise the returned xfrm_state maybe be released.

Fixes: c454997e6[{pktgen, xfrm} Introduce xfrm_state_lookup_byspi..]
Cc: Fan Du <fan.du@intel.com>
Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
---
 net/xfrm/xfrm_state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index f5e39e3..96688cd 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -927,8 +927,8 @@ struct xfrm_state *xfrm_state_lookup_byspi(struct net *net, __be32 spi,
 			x->id.spi != spi)
 			continue;
 
-		spin_unlock_bh(&net->xfrm.xfrm_state_lock);
 		xfrm_state_hold(x);
+		spin_unlock_bh(&net->xfrm.xfrm_state_lock);
 		return x;
 	}
 	spin_unlock_bh(&net->xfrm.xfrm_state_lock);
-- 
2.1.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] xfrm: fix a race in xfrm_state_lookup_byspi
  2015-04-29  0:42 [PATCH] xfrm: fix a race in xfrm_state_lookup_byspi roy.qing.li
@ 2015-04-29  5:25 ` Du, Fan
  2015-04-30 10:24   ` Steffen Klassert
  0 siblings, 1 reply; 3+ messages in thread
From: Du, Fan @ 2015-04-29  5:25 UTC (permalink / raw)
  To: roy.qing.li, netdev; +Cc: steffen.klassert, Du, Fan


>-----Original Message-----
>From: roy.qing.li@gmail.com [mailto:roy.qing.li@gmail.com]
>Sent: Wednesday, April 29, 2015 8:43 AM
>To: netdev@vger.kernel.org
>Cc: Du, Fan; steffen.klassert@secunet.com
>Subject: [PATCH] xfrm: fix a race in xfrm_state_lookup_byspi
>
>From: Li RongQing <roy.qing.li@gmail.com>
>
>The returned xfrm_state should be hold before unlock xfrm_state_lock,
>otherwise the returned xfrm_state maybe be released.
>
>Fixes: c454997e6[{pktgen, xfrm} Introduce xfrm_state_lookup_byspi..]
>Cc: Fan Du <fan.du@intel.com>
>Signed-off-by: Li RongQing <roy.qing.li@gmail.com>

Acked-by: Fan Du <fan.du@intel.com>
 

>---
> net/xfrm/xfrm_state.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
>index f5e39e3..96688cd 100644
>--- a/net/xfrm/xfrm_state.c
>+++ b/net/xfrm/xfrm_state.c
>@@ -927,8 +927,8 @@ struct xfrm_state *xfrm_state_lookup_byspi(struct net
>*net, __be32 spi,
> 			x->id.spi != spi)
> 			continue;
>
>-		spin_unlock_bh(&net->xfrm.xfrm_state_lock);
> 		xfrm_state_hold(x);
>+		spin_unlock_bh(&net->xfrm.xfrm_state_lock);
> 		return x;
> 	}
> 	spin_unlock_bh(&net->xfrm.xfrm_state_lock);
>--
>2.1.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfrm: fix a race in xfrm_state_lookup_byspi
  2015-04-29  5:25 ` Du, Fan
@ 2015-04-30 10:24   ` Steffen Klassert
  0 siblings, 0 replies; 3+ messages in thread
From: Steffen Klassert @ 2015-04-30 10:24 UTC (permalink / raw)
  To: Du, Fan; +Cc: roy.qing.li, netdev

On Wed, Apr 29, 2015 at 05:25:25AM +0000, Du, Fan wrote:
> 
> >-----Original Message-----
> >From: roy.qing.li@gmail.com [mailto:roy.qing.li@gmail.com]
> >Sent: Wednesday, April 29, 2015 8:43 AM
> >To: netdev@vger.kernel.org
> >Cc: Du, Fan; steffen.klassert@secunet.com
> >Subject: [PATCH] xfrm: fix a race in xfrm_state_lookup_byspi
> >
> >From: Li RongQing <roy.qing.li@gmail.com>
> >
> >The returned xfrm_state should be hold before unlock xfrm_state_lock,
> >otherwise the returned xfrm_state maybe be released.
> >
> >Fixes: c454997e6[{pktgen, xfrm} Introduce xfrm_state_lookup_byspi..]
> >Cc: Fan Du <fan.du@intel.com>
> >Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
> 
> Acked-by: Fan Du <fan.du@intel.com>

Applied to the ipsec tree, thanks a lot!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-04-30 10:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-29  0:42 [PATCH] xfrm: fix a race in xfrm_state_lookup_byspi roy.qing.li
2015-04-29  5:25 ` Du, Fan
2015-04-30 10:24   ` Steffen Klassert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).