[3.19.y-ckt stable] Patch "xfrm: fix a race in xfrm_state_lookup_byspi" has been added to staging queue

Kamal Mostafa kamal at canonical.com
Tue Jul 7 00:11:18 UTC 2015


This is a note to let you know that I have just added a patch titled

    xfrm: fix a race in xfrm_state_lookup_byspi

to the linux-3.19.y-queue branch of the 3.19.y-ckt extended stable tree 
which can be found at:

    http://kernel.ubuntu.com/git/ubuntu/linux.git/log/?h=linux-3.19.y-queue

This patch is scheduled to be released in version 3.19.8-ckt3.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.19.y-ckt tree, see
https://wiki.ubuntu.com/Kernel/Dev/ExtendedStable

Thanks.
-Kamal

------

>From df249a1042a5077c8115fdaf6a1f0b6b61ee447b Mon Sep 17 00:00:00 2001
From: Li RongQing <roy.qing.li at gmail.com>
Date: Wed, 29 Apr 2015 08:42:44 +0800
Subject: xfrm: fix a race in xfrm_state_lookup_byspi

commit bdddbf6996c0b9299efc97b8f66e06286f3aa8c9 upstream.

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 at intel.com>
Signed-off-by: Li RongQing <roy.qing.li at gmail.com>
Acked-by: Fan Du <fan.du at intel.com>
Signed-off-by: Steffen Klassert <steffen.klassert at secunet.com>
Signed-off-by: Kamal Mostafa <kamal at canonical.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 de971b6..27348f0 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);
--
1.9.1





More information about the kernel-team mailing list