From: Patrick McHardy <kaber@trash.net>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: "David S. Miller" <davem@davemloft.net>,
Linux Netdev List <netdev@vger.kernel.org>
Subject: [XFRM]: Fix leak of expired xfrm_states
Date: Mon, 26 Nov 2007 16:05:27 +0100 [thread overview]
Message-ID: <474AE0B7.5010709@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 112 bytes --]
This patch fixes a xfrm_state leak, which appears to be a
regression from the reference count simplifications.
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1176 bytes --]
commit 817252c2a475371f9764883c7d0f0cde63b3cfe8
Author: Patrick McHardy <kaber@trash.net>
Date: Mon Nov 26 16:00:50 2007 +0100
[XFRM]: Fix leak of expired xfrm_states
The xfrm_timer calls __xfrm_state_delete, which drops the final reference
manually without triggering destruction of the state.
Signed-off-by: Patrick McHardy <kaber@trash.net>
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index 224b44e..11e9a48 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -416,7 +416,7 @@ static inline unsigned long make_jiffies(long secs)
static void xfrm_timer_handler(unsigned long data)
{
- struct xfrm_state *x = (struct xfrm_state*)data;
+ struct xfrm_state *x = (struct xfrm_state*)data, *del = NULL;
unsigned long now = get_seconds();
long next = LONG_MAX;
int warn = 0;
@@ -479,6 +479,8 @@ expired:
goto resched;
}
+ del = x;
+ xfrm_state_hold(del);
err = __xfrm_state_delete(x);
if (!err && x->id.spi)
km_state_expired(x, 1, 0);
@@ -488,6 +490,8 @@ expired:
out:
spin_unlock(&x->lock);
+ if (del)
+ xfrm_state_put(del);
}
static void xfrm_replay_timer_handler(unsigned long data);
next reply other threads:[~2007-11-26 15:06 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-26 15:05 Patrick McHardy [this message]
2007-11-26 15:46 ` [XFRM]: Fix leak of expired xfrm_states Herbert Xu
2007-11-26 15:51 ` Patrick McHardy
2007-11-26 15:54 ` Herbert Xu
2007-11-26 15:56 ` Patrick McHardy
2007-11-26 16:22 ` Herbert Xu
2007-11-26 16:52 ` Patrick McHardy
2007-11-27 3:11 ` Herbert Xu
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=474AE0B7.5010709@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
/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).