netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eugene Surovegin <ebs@ebshome.net>
To: netdev@oss.sgi.com
Subject: [IPSEC] add missing flow_cache_genid update to xfrm_policy_delete()
Date: Thu, 5 Aug 2004 00:14:59 -0700	[thread overview]
Message-ID: <20040805071459.GA31551@gate.ebshome.net> (raw)

Hi!

I think there is a missing atomic_inc(&flow_cache_genid) in 
xfrm_policy.c::xfrm_policy_delete().

We were experiencing system lockups I think I tracked down to the stale 
xfrm policy in the flow cache. 

Here is our scenario:

policy timer expired -> xfrm_policy_timer() -> xfrm_policy_delete() -> 
xfrm_policy_kill() (here policy->dead is set to 1).

Note that none of these calls increment flow_cache_genid.

Some time later xfrm_lookup() is called (in my case it happened in softirq 
context). flow_cache_lookup() returns policy from the flow cache (i.e. 
resolver xfrm_policy_lookup() is NOT called) and this policy happens to be 
the one previously killed (i.e. dead == 1). This will cause infinite loop 
in xfrm_lookup().

Attached patch is against recent 2.6 BK, although I debugged this problem 
on 2.4 + IPSec backport. From quick look 2.6 still needs this fix (but I 
couldn't test 2.6 on our hw).

Also, I think xfrm_sk_policy_insert() doesn't require similar change, but 
I'm not 100% sure. Could IPSec gurus confirm this? 

Signed-off-by: Eugene Surovegin <ebs@ebshome.net>

===== net/xfrm/xfrm_policy.c 1.52 vs edited =====
--- 1.52/net/xfrm/xfrm_policy.c	2004-07-23 13:23:33 -07:00
+++ edited/net/xfrm/xfrm_policy.c	2004-08-04 18:18:45 -07:00
@@ -536,8 +536,10 @@
 	write_lock_bh(&xfrm_policy_lock);
 	pol = __xfrm_policy_unlink(pol, dir);
 	write_unlock_bh(&xfrm_policy_lock);
-	if (pol)
+	if (pol){
+		atomic_inc(&flow_cache_genid);
 		xfrm_policy_kill(pol);
+	}	
 }
 
 int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol)

             reply	other threads:[~2004-08-05  7:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-05  7:14 Eugene Surovegin [this message]
2004-08-05 12:01 ` [IPSEC] add missing flow_cache_genid update to xfrm_policy_delete() Herbert Xu
2004-08-05 16:01   ` Eugene Surovegin
2004-08-05 21:24     ` Herbert Xu
2004-08-09 23:51       ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040805071459.GA31551@gate.ebshome.net \
    --to=ebs@ebshome.net \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).