xfrm: fix a race in xfrm_state_lookup_byspi
Subsystems (3)
PATCH 1/1 xfrm: fix a race in xfrm_state_lookup_byspi
From: Li RongQing <[email protected]>
The returned xfrm_state should be hold before unlock xfrm_state_lock, otherwise the returned xfrm_state maybe be released.
--- net/xfrm/xfrm_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/xfrm/xfrm_state.c +1 -1
@@ -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);
Signature · 1 line
2.1.0
Quoted 8 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Wednesday, April 29, 2015 8:43 AM
To: [email protected]
Cc: Du, Fan; [email protected]
Subject: [PATCH] xfrm: fix a race inxfrm_state_lookup_byspi
Quoted 8 lines
From: Li RongQing <[email protected]>
The returned
xfrm_stateshould be hold before unlockxfrm_state_lock, otherwise the returnedxfrm_statemaybe be released.Fixes c454997e6[{pktgen, xfrm} Introduce xfrm_state_lookup_byspi..]Cc Fan Du <[email protected]>Signed-off-by Li RongQing <[email protected]>
Quoted 21 lines
---
net/xfrm/xfrm_state.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)net/xfrm/xfrm_state.c +1
-1@@ -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
Quoted 10 lines · Fan
Quoted 10 lines
-----Original Message-----
From: [email protected] [mailto:[email protected]]
Sent: Wednesday, April 29, 2015 8:43 AM
To: [email protected]
Cc: Du, Fan; [email protected]
Subject: [PATCH] xfrm: fix a race inxfrm_state_lookup_byspiFrom: Li RongQing <[email protected]>
Quoted 8 lines
Quoted 6 lines
The returned
xfrm_stateshould be hold before unlockxfrm_state_lock, otherwise the returnedxfrm_statemaybe be released.Fixes c454997e6[{pktgen, xfrm} Introduce xfrm_state_lookup_byspi..]Cc Fan Du <[email protected]>Signed-off-by Li RongQing <[email protected]>Acked-by Fan Du <[email protected]>
Applied to the ipsec tree, thanks a lot!