* [PATCH net-2.6] key: Free dumping state on socket close
@ 2008-10-01 10:55 Timo Teräs
2008-10-01 12:34 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Timo Teräs @ 2008-10-01 10:55 UTC (permalink / raw)
To: netdev
Fix a xfrm_{state,policy}_walk leak if pfkey socket is closed while
dumping is on-going.
Signed-off-by: Timo Teras <timo.teras@iki.fi>
---
Should go to -stable too.
net/key/af_key.c | 30 +++++++++++++++++++-----------
1 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/net/key/af_key.c b/net/key/af_key.c
index d628df9..b7f5a1c 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -73,22 +73,18 @@ static int pfkey_can_dump(struct sock *sk)
return 0;
}
-static int pfkey_do_dump(struct pfkey_sock *pfk)
+static void pfkey_terminate_dump(struct pfkey_sock *pfk)
{
- int rc;
-
- rc = pfk->dump.dump(pfk);
- if (rc == -ENOBUFS)
- return 0;
-
- pfk->dump.done(pfk);
- pfk->dump.dump = NULL;
- pfk->dump.done = NULL;
- return rc;
+ if (pfk->dump.dump) {
+ pfk->dump.done(pfk);
+ pfk->dump.dump = NULL;
+ pfk->dump.done = NULL;
+ }
}
static void pfkey_sock_destruct(struct sock *sk)
{
+ pfkey_terminate_dump(pfkey_sk(sk));
skb_queue_purge(&sk->sk_receive_queue);
if (!sock_flag(sk, SOCK_DEAD)) {
@@ -310,6 +306,18 @@ static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation,
return err;
}
+static int pfkey_do_dump(struct pfkey_sock *pfk)
+{
+ int rc;
+
+ rc = pfk->dump.dump(pfk);
+ if (rc == -ENOBUFS)
+ return 0;
+
+ pfkey_terminate_dump(pfk);
+ return rc;
+}
+
static inline void pfkey_hdr_dup(struct sadb_msg *new, struct sadb_msg *orig)
{
*new = *orig;
--
1.5.4.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-2.6] key: Free dumping state on socket close
2008-10-01 10:55 [PATCH net-2.6] key: Free dumping state on socket close Timo Teräs
@ 2008-10-01 12:34 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2008-10-01 12:34 UTC (permalink / raw)
To: timo.teras; +Cc: netdev
From: Timo Teräs <timo.teras@iki.fi>
Date: Wed, 01 Oct 2008 13:55:15 +0300
> Fix a xfrm_{state,policy}_walk leak if pfkey socket is closed while
> dumping is on-going.
>
> Signed-off-by: Timo Teras <timo.teras@iki.fi>
> ---
> Should go to -stable too.
Applied and queued for -stable, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-10-01 12:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-01 10:55 [PATCH net-2.6] key: Free dumping state on socket close Timo Teräs
2008-10-01 12:34 ` David Miller
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).